To get the IP of test bed system
Change-Id: Ie7efb127caa4bed9053f05957a25f1fd56089161
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
index 9b08a5a..af29b9d 100644
--- a/lib/bmc_network_utils.py
+++ b/lib/bmc_network_utils.py
@@ -18,6 +18,8 @@
import json
import bmc_ssh_utils as bsu
+ip_regex = r"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}"
+
def get_running_system_ip():
r"""
@@ -29,11 +31,9 @@
"""
ip_list = list()
- host_name = socket.gethostname()
- temp_ip_list = socket.getaddrinfo(host_name, 80)
- for item in temp_ip_list:
- ip_addr = item[-1][0]
- ip_list.insert(0, ip_addr)
+ stdout = subprocess.check_output("ip addr show", shell=True)
+ stdout = stdout.decode("utf-8")
+ ip_list = re.findall(ip_regex, stdout)
return ip_list