New get_host_name_ip function in gen_misc.py.
Given a host, get_host_name_ip will return a tuple consisting of a host
name and an IP address.
Change-Id: Ia15dd9381491a299efde470a87ade37487884a7c
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_misc.py b/lib/gen_misc.py
index c795b1d..1a8990a 100755
--- a/lib/gen_misc.py
+++ b/lib/gen_misc.py
@@ -10,6 +10,7 @@
import ConfigParser
import StringIO
import re
+import socket
import gen_print as gp
import gen_cmd as gc
@@ -320,3 +321,23 @@
return parm
###############################################################################
+
+
+###############################################################################
+def get_host_name_ip(host):
+
+ r"""
+ Get the host name and the IP address for the given host and return them as
+ a tuple.
+
+ Description of argument(s):
+ host The host name or IP address to be
+ obtained.
+ """
+
+ host_host_name = socket.getfqdn(host)
+ host_ip = socket.gethostbyname(host)
+
+ return host_host_name, host_ip
+
+###############################################################################