Allow tests run for IPv6 only BMC
Changed:
Replaced gethostbyname with getaddrinfo. gethostbyname only returns
IPv4 addresses, so, if target has only IPv6 address, socket.gaierror
is thrown. getaddrinfo returns all IPv4 and IPv6. The code still
prefers IPv4.
Tested:
Ran against IPv6 only BMC, it worked.
Change-Id: I47b59e05506dda14cdd8d60c8b1db98e86c1bd39
Signed-off-by: Igor Kanyuka <ifelmail@gmail.com>
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
index 82b10fd..84410f9 100644
--- a/lib/bmc_network_utils.py
+++ b/lib/bmc_network_utils.py
@@ -31,7 +31,7 @@
ip_list = list()
stdout = subprocess.check_output(["hostname", "--all-fqdns"], shell=True)
host_fqdns = stdout.decode("utf-8").strip()
- ip_address = socket.gethostbyname(str(host_fqdns))
+ ip_address = gm.get_first_host_addr(host_fqdns)
ip_list.append(ip_address)
return ip_list