summaryrefslogtreecommitdiffstats
path: root/roles/openshift_facts/library
diff options
context:
space:
mode:
authorSylvain Baubeau <sbaubeau@redhat.com>2015-11-16 17:24:43 +0100
committerSylvain Baubeau <sbaubeau@redhat.com>2016-03-14 10:21:03 +0100
commitb5f00c416b767b167bbd3d8f61f2b9a534aa5432 (patch)
treecb16bdc8134ab1562191a0adf36bda7e7023a6a1 /roles/openshift_facts/library
parentdc8938e01202db0464e54becf4812c3191ce2d51 (diff)
downloadopenshift-b5f00c416b767b167bbd3d8f61f2b9a534aa5432.tar.gz
openshift-b5f00c416b767b167bbd3d8f61f2b9a534aa5432.tar.bz2
openshift-b5f00c416b767b167bbd3d8f61f2b9a534aa5432.tar.xz
openshift-b5f00c416b767b167bbd3d8f61f2b9a534aa5432.zip
Add support for Openstack integration
Diffstat (limited to 'roles/openshift_facts/library')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 0f25881f1..5648c179e 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -296,6 +296,11 @@ def normalize_provider_facts(provider, metadata):
facts = dict(name=provider, metadata=metadata,
network=dict(interfaces=[], ipv6_enabled=False))
+ if os.path.exists('/etc/cloud.conf'):
+ for arg in ('api_server_args', 'controller_args', 'kubelet_args'):
+ facts[arg] = {'cloud-provider': [provider],
+ 'cloud-config': ['/etc/cloud.conf']}
+
if provider == 'gce':
facts = normalize_gce_facts(metadata, facts)
elif provider == 'ec2':
@@ -997,6 +1002,30 @@ def merge_facts(orig, new, additive_facts_to_overwrite, protected_facts_to_overw
return facts
+def merge_provider_facts(facts):
+ """ Recursively merge provider facts dicts
+
+ Args:
+ facts (dict): existing facts
+ Returns:
+ dict: the facts dict updated with the provider config
+ """
+ if 'provider' not in facts:
+ return facts
+ if 'master' in facts:
+ for arg in ('api_server_args', 'controller_args'):
+ facts['master'][arg] = merge_facts(
+ facts['provider'].get(arg, {}),
+ facts['master'].get(arg, {}),
+ [], [])
+ if 'node' in facts:
+ facts['node']['kubelet_args'] = merge_facts(
+ facts['provider'].get('kubelet_args', {}),
+ facts['node'].get('kubelet_args', {}),
+ [], [])
+ return facts
+
+
def save_local_facts(filename, facts):
""" Save local facts
@@ -1209,6 +1238,7 @@ class OpenShiftFacts(object):
local_facts,
additive_facts_to_overwrite,
protected_facts_to_overwrite)
+ facts = merge_provider_facts(facts)
facts['current_config'] = get_current_config(facts)
facts = set_url_facts_if_unset(facts)
facts = set_project_cfg_facts_if_unset(facts)
@@ -1376,7 +1406,7 @@ class OpenShiftFacts(object):
additive_facts_to_overwrite=None,
openshift_env=None,
protected_facts_to_overwrite=None):
- """ Initialize the provider facts
+ """ Initialize the local facts
Args:
facts (dict): local facts to set