From b5f00c416b767b167bbd3d8f61f2b9a534aa5432 Mon Sep 17 00:00:00 2001 From: Sylvain Baubeau Date: Mon, 16 Nov 2015 17:24:43 +0100 Subject: Add support for Openstack integration --- roles/openshift_facts/library/openshift_facts.py | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'roles/openshift_facts/library') 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 -- cgit v1.2.3