diff options
author | Scott Dodson <sdodson@redhat.com> | 2016-10-10 10:44:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-10 10:44:30 -0400 |
commit | c8683028b1c8228a531fac5f1753ff2698b316fc (patch) | |
tree | 98c2708ac00601095cfe7a60ed25061968e835be /roles/openshift_facts | |
parent | 5e07a172850ab6d8701fd4fc3a08a3414ecd37dd (diff) | |
parent | 3cc2d6b019fa8a05ba480a7425cd654aa051355f (diff) | |
download | openshift-c8683028b1c8228a531fac5f1753ff2698b316fc.tar.gz openshift-c8683028b1c8228a531fac5f1753ff2698b316fc.tar.bz2 openshift-c8683028b1c8228a531fac5f1753ff2698b316fc.tar.xz openshift-c8683028b1c8228a531fac5f1753ff2698b316fc.zip |
Merge pull request #2561 from lhuard1A/check_openstack_hostname_are_resovable
Check that OpenStack hostnames are resolvable
Diffstat (limited to 'roles/openshift_facts')
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 9ffd399bc..0ee018c5c 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -364,12 +364,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 |