summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2014-03-10 08:50:04 +0100
committerMichal Minar <miminar@redhat.com>2014-03-10 08:50:21 +0100
commitccd7c63b723573570600159e3e3bc1f652ad2159 (patch)
tree7e639abb9b665a61cf86d184c2c3abfed6f2c77b /src
parent8c0e0bf7af61493d069a99bab123d99a16942371 (diff)
downloadopenlmi-providers-ccd7c63b723573570600159e3e3bc1f652ad2159.tar.gz
openlmi-providers-ccd7c63b723573570600159e3e3bc1f652ad2159.tar.xz
openlmi-providers-ccd7c63b723573570600159e3e3bc1f652ad2159.zip
python: fixed SystemName verification
If hostname can not be translated to IP, provider thinks it does not belong to running system. This change makes sure that hostname is properly recognized and no traceback is trown.
Diffstat (limited to 'src')
-rw-r--r--src/python/lmi/providers/__init__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/python/lmi/providers/__init__.py b/src/python/lmi/providers/__init__.py
index 462890e..6e945a3 100644
--- a/src/python/lmi/providers/__init__.py
+++ b/src/python/lmi/providers/__init__.py
@@ -53,5 +53,11 @@ def is_this_system(system_name):
:rtype: boolean
"""
- return ( socket.gethostbyaddr(system_name)[0]
- == socket.gethostbyaddr(socket.gethostname())[0])
+ try:
+ return ( socket.gethostbyaddr(system_name)[0]
+ == socket.gethostbyaddr(socket.gethostname())[0])
+ except socket.gaierror: # name resolution failed
+ if system_name == socket.gethostname():
+ # hostname can not be translated to IP
+ return True
+ return False