summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2015-11-11 10:48:32 -0500
committerBrenton Leanhardt <bleanhar@redhat.com>2015-11-11 10:48:32 -0500
commit962d6bbfeca2998a850cf976f9177080c0b9e594 (patch)
tree84d6eeaf16dfe8ce89d33adfdea58e9634d9407d /roles
parentaa57786422cbf164edc1d1a9041b73606d39bd4d (diff)
parent4c1b0dd4ab8f3a5d4fcfa4ba1501ed374793e77a (diff)
downloadopenshift-962d6bbfeca2998a850cf976f9177080c0b9e594.tar.gz
openshift-962d6bbfeca2998a850cf976f9177080c0b9e594.tar.bz2
openshift-962d6bbfeca2998a850cf976f9177080c0b9e594.tar.xz
openshift-962d6bbfeca2998a850cf976f9177080c0b9e594.zip
Merge pull request #839 from detiber/refactorUpgrade
Refactor upgrade
Diffstat (limited to 'roles')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py71
1 files changed, 36 insertions, 35 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index c108cd422..2e1075aca 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -528,7 +528,6 @@ def set_aggregate_facts(facts):
first_svc_ip = str(IPNetwork(facts['master']['portal_net'])[1])
all_hostnames.add(first_svc_ip)
internal_hostnames.add(first_svc_ip)
- _add_etcd_data_dir_fact(facts)
facts['common']['all_hostnames'] = list(all_hostnames)
facts['common']['internal_hostnames'] = list(internal_hostnames)
@@ -536,7 +535,7 @@ def set_aggregate_facts(facts):
return facts
-def _add_etcd_data_dir_fact(facts):
+def set_etcd_facts_if_unset(facts):
"""
If using embedded etcd, loads the data directory from master-config.yaml.
@@ -544,38 +543,39 @@ def _add_etcd_data_dir_fact(facts):
If anything goes wrong parsing these, the fact will not be set.
"""
- if facts['master']['embedded_etcd']:
- try:
- # Parse master config to find actual etcd data dir:
- master_cfg_path = os.path.join(facts['common']['config_base'],
- 'master/master-config.yaml')
- master_cfg_f = open(master_cfg_path, 'r')
- config = yaml.safe_load(master_cfg_f.read())
- master_cfg_f.close()
-
- facts['master']['etcd_data_dir'] = \
- config['etcdConfig']['storageDirectory']
- # We don't want exceptions bubbling up here:
- # pylint: disable=broad-except
- except Exception:
- pass
- else:
- # Read ETCD_DATA_DIR from /etc/etcd/etcd.conf:
- try:
- # Add a fake section for parsing:
- ini_str = '[root]\n' + open('/etc/etcd/etcd.conf', 'r').read()
- ini_fp = StringIO.StringIO(ini_str)
- config = ConfigParser.RawConfigParser()
- config.readfp(ini_fp)
- etcd_data_dir = config.get('root', 'ETCD_DATA_DIR')
- if etcd_data_dir.startswith('"') and etcd_data_dir.endswith('"'):
- etcd_data_dir = etcd_data_dir[1:-1]
- facts['master']['etcd_data_dir'] = etcd_data_dir
- # We don't want exceptions bubbling up here:
- # pylint: disable=broad-except
- except Exception:
- pass
-
+ if 'etcd' in facts:
+ if 'master' in facts and facts['master']['embedded_etcd']:
+ try:
+ # Parse master config to find actual etcd data dir:
+ master_cfg_path = os.path.join(facts['common']['config_base'],
+ 'master/master-config.yaml')
+ master_cfg_f = open(master_cfg_path, 'r')
+ config = yaml.safe_load(master_cfg_f.read())
+ master_cfg_f.close()
+
+ facts['etcd']['etcd_data_dir'] = \
+ config['etcdConfig']['storageDirectory']
+ # We don't want exceptions bubbling up here:
+ # pylint: disable=broad-except
+ except Exception:
+ pass
+ else:
+ # Read ETCD_DATA_DIR from /etc/etcd/etcd.conf:
+ try:
+ # Add a fake section for parsing:
+ ini_str = '[root]\n' + open('/etc/etcd/etcd.conf', 'r').read()
+ ini_fp = StringIO.StringIO(ini_str)
+ config = ConfigParser.RawConfigParser()
+ config.readfp(ini_fp)
+ etcd_data_dir = config.get('root', 'ETCD_DATA_DIR')
+ if etcd_data_dir.startswith('"') and etcd_data_dir.endswith('"'):
+ etcd_data_dir = etcd_data_dir[1:-1]
+ facts['etcd']['etcd_data_dir'] = etcd_data_dir
+ # We don't want exceptions bubbling up here:
+ # pylint: disable=broad-except
+ except Exception:
+ pass
+ return facts
def set_deployment_facts_if_unset(facts):
""" Set Facts that vary based on deployment_type. This currently
@@ -939,7 +939,7 @@ class OpenShiftFacts(object):
Raises:
OpenShiftFactsUnsupportedRoleError:
"""
- known_roles = ['common', 'master', 'node', 'master_sdn', 'node_sdn', 'dns']
+ known_roles = ['common', 'master', 'node', 'master_sdn', 'node_sdn', 'dns', 'etcd']
def __init__(self, role, filename, local_facts):
self.changed = False
@@ -982,6 +982,7 @@ class OpenShiftFacts(object):
facts = set_deployment_facts_if_unset(facts)
facts = set_version_facts_if_unset(facts)
facts = set_aggregate_facts(facts)
+ facts = set_etcd_facts_if_unset(facts)
return dict(openshift=facts)
def get_defaults(self, roles):