summaryrefslogtreecommitdiffstats
path: root/roles/openshift_facts/library
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2016-11-08 15:34:15 -0500
committerGitHub <noreply@github.com>2016-11-08 15:34:15 -0500
commit9e90b0085b1203830164c7ea515e69236f16de76 (patch)
treef6bc352be8a8550b2676ffd8cd1e486d3e1c0a37 /roles/openshift_facts/library
parenta10e68b03db0e318e960a2f13f5f30ccb59b8d09 (diff)
downloadopenshift-9e90b0085b1203830164c7ea515e69236f16de76.tar.gz
openshift-9e90b0085b1203830164c7ea515e69236f16de76.tar.bz2
openshift-9e90b0085b1203830164c7ea515e69236f16de76.tar.xz
openshift-9e90b0085b1203830164c7ea515e69236f16de76.zip
Revert "Revert openshift.node.nodename changes"
Diffstat (limited to 'roles/openshift_facts/library')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 537b6c60f..6d2b81c1f 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -148,6 +148,7 @@ def hostname_valid(hostname):
if (not hostname or
hostname.startswith('localhost') or
hostname.endswith('localdomain') or
+ hostname.endswith('novalocal') or
len(hostname.split('.')) < 2):
return False
@@ -362,12 +363,15 @@ def normalize_openstack_facts(metadata, facts):
facts['network']['ip'] = local_ipv4
facts['network']['public_ip'] = metadata['ec2_compat']['public-ipv4']
- # TODO: verify local hostname makes sense and is resolvable
- facts['network']['hostname'] = metadata['hostname']
-
- # TODO: verify that public hostname makes sense and is resolvable
- pub_h = metadata['ec2_compat']['public-hostname']
- facts['network']['public_hostname'] = pub_h
+ for f_var, h_var, ip_var in [('hostname', 'hostname', 'local-ipv4'),
+ ('public_hostname', 'public-hostname', 'public-ipv4')]:
+ try:
+ if socket.gethostbyname(metadata['ec2_compat'][h_var]) == metadata['ec2_compat'][ip_var]:
+ facts['network'][f_var] = metadata['ec2_compat'][h_var]
+ else:
+ facts['network'][f_var] = metadata['ec2_compat'][ip_var]
+ except socket.gaierror:
+ facts['network'][f_var] = metadata['ec2_compat'][ip_var]
return facts
@@ -936,6 +940,14 @@ def set_sdn_facts_if_unset(facts, system_facts):
return facts
+def set_nodename(facts):
+ if 'node' in facts and 'common' in facts:
+ if 'cloudprovider' in facts and facts['cloudprovider']['kind'] == 'openstack':
+ facts['node']['nodename'] = facts['provider']['metadata']['hostname'].replace('.novalocal', '')
+ else:
+ facts['node']['nodename'] = facts['common']['hostname'].lower()
+ return facts
+
def migrate_oauth_template_facts(facts):
"""
Migrate an old oauth template fact to a newer format if it's present.
@@ -1312,7 +1324,7 @@ def apply_provider_facts(facts, provider_facts):
facts['common'][h_var] = choose_hostname(
[provider_facts['network'].get(h_var)],
- facts['common'][ip_var]
+ facts['common'][h_var]
)
facts['provider'] = provider_facts
@@ -1795,6 +1807,7 @@ class OpenShiftFacts(object):
facts = set_proxy_facts(facts)
if not safe_get_bool(facts['common']['is_containerized']):
facts = set_installed_variant_rpm_facts(facts)
+ facts = set_nodename(facts)
return dict(openshift=facts)
def get_defaults(self, roles, deployment_type, deployment_subtype):