get_host_name_ip: improved failure path for gaierror.
Change-Id: I11187a8e33348d4136119f292fc2ed30a2d1b1ce
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_misc.py b/lib/gen_misc.py
index 1a8990a..a2aafd7 100755
--- a/lib/gen_misc.py
+++ b/lib/gen_misc.py
@@ -331,12 +331,17 @@
a tuple.
Description of argument(s):
- host The host name or IP address to be
- obtained.
+ host The host name or IP address to be obtained.
"""
host_host_name = socket.getfqdn(host)
- host_ip = socket.gethostbyname(host)
+ try:
+ host_ip = socket.gethostbyname(host)
+ except socket.gaierror as my_gaierror:
+ message = "Unable to obtain the host name for the following host:" +\
+ "\n" + gp.sprint_var(host)
+ gp.print_error_report(message)
+ raise my_gaierror
return host_host_name, host_ip