diff options
author | Brenton Leanhardt <bleanhar@redhat.com> | 2015-11-05 16:03:46 -0500 |
---|---|---|
committer | Brenton Leanhardt <bleanhar@redhat.com> | 2015-11-05 16:03:46 -0500 |
commit | d01f131de68bf88e4e3fb4c81450922a30285804 (patch) | |
tree | a66fbc3644903bb934a9f0d502bfad31a2006124 /roles/openshift_facts | |
parent | 4037c37c5f505f9f3017fe92b10db009e85d863d (diff) | |
parent | f8618fc13af95613de5f022dd1855af7309c7d7c (diff) | |
download | openshift-d01f131de68bf88e4e3fb4c81450922a30285804.tar.gz openshift-d01f131de68bf88e4e3fb4c81450922a30285804.tar.bz2 openshift-d01f131de68bf88e4e3fb4c81450922a30285804.tar.xz openshift-d01f131de68bf88e4e3fb4c81450922a30285804.zip |
Merge pull request #815 from detiber/fixMTU
Bug 1277592 - SDN MTU has hardcoded default
Diffstat (limited to 'roles/openshift_facts')
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 1b2ba6be3..23016fe31 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -597,11 +597,12 @@ def set_deployment_facts_if_unset(facts): return facts -def set_sdn_facts_if_unset(facts): +def set_sdn_facts_if_unset(facts, system_facts): """ Set sdn facts if not already present in facts dict Args: facts (dict): existing facts + system_facts (dict): ansible_facts Returns: dict: the facts dict updated with the generated sdn facts if they were not already present @@ -620,9 +621,18 @@ def set_sdn_facts_if_unset(facts): if 'sdn_host_subnet_length' not in facts['master']: facts['master']['sdn_host_subnet_length'] = '8' - if 'node' in facts: - if 'sdn_mtu' not in facts['node']: - facts['node']['sdn_mtu'] = '1450' + if 'node' in facts and 'sdn_mtu' not in facts['node']: + node_ip = facts['common']['ip'] + + # default MTU if interface MTU cannot be detected + facts['node']['sdn_mtu'] = '1450' + + for val in system_facts.itervalues(): + if isinstance(val, dict) and 'mtu' in val: + mtu = val['mtu'] + + if 'ipv4' in val and val['ipv4'].get('address') == node_ip: + facts['node']['sdn_mtu'] = str(mtu - 50) return facts @@ -893,7 +903,7 @@ class OpenShiftFacts(object): facts = set_master_selectors(facts) facts = set_metrics_facts_if_unset(facts) facts = set_identity_providers_if_unset(facts) - facts = set_sdn_facts_if_unset(facts) + facts = set_sdn_facts_if_unset(facts, self.system_facts) facts = set_deployment_facts_if_unset(facts) facts = set_aggregate_facts(facts) return dict(openshift=facts) |