Implementation change of getting server ip
changes:
- Implementation change of getting server ip using socket
- Removed:
Create A Session With ClientID
Get Session Information By ClientID
Verify A Session Created With ClientID
Change-Id: I5c3c6554173cd028580f7f5ecca088626f72a21a
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
index af29b9d..d73a1e1 100644
--- a/lib/bmc_network_utils.py
+++ b/lib/bmc_network_utils.py
@@ -25,15 +25,13 @@
r"""
Get the IP address of server from which robot code is running.
- Example of getaddrinfo:
-
- [(<AddressFamily.AF_INET: X>, <SocketKind.SOCK_STREAM: X>, X, '', ('XX.XX.XX.XX', port)),]
"""
ip_list = list()
- stdout = subprocess.check_output("ip addr show", shell=True)
- stdout = stdout.decode("utf-8")
- ip_list = re.findall(ip_regex, stdout)
+ stdout = subprocess.check_output(['hostname', '--all-fqdns'], shell=True)
+ host_fqdns = stdout.decode("utf-8").strip()
+ ip_address = socket.gethostbyname(str(host_fqdns))
+ ip_list.append(ip_address)
return ip_list