Automation fix for ifconfig command

Changes:
   - New implementaion uses socket module to get the ip address.

Change-Id: I9529b987057f93449e0570571eb5b324487c2eac
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
index c2ea9f8..9b08a5a 100644
--- a/lib/bmc_network_utils.py
+++ b/lib/bmc_network_utils.py
@@ -18,18 +18,24 @@
 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_hostname():
+def get_running_system_ip():
     r"""
-    Get the host name of server from which robot code is running.
+    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()
     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)
 
-    return host_name
+    return ip_list
 
 
 def netmask_prefix_length(netmask):
diff --git a/openpower/ext_interfaces/test_client_identifier.robot b/openpower/ext_interfaces/test_client_identifier.robot
index 92124d1..47ecde5 100644
--- a/openpower/ext_interfaces/test_client_identifier.robot
+++ b/openpower/ext_interfaces/test_client_identifier.robot
@@ -129,13 +129,11 @@
       ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_id}
       Rprint Vars  sessions
       @{words} =  Split String  ${sessions["Oem"]["OpenBMC"]["ClientOriginIP"]}  :
-      ${host_name}=  Get Hostname
-      ${host_name}  ${ip_address}=  Get Host Name IP  host=${host_name}
-      Set Suite Variable  ${ip_address}
+      ${ip_address}=  Get Running System IP
       Set Test Variable  ${temp_ipaddr}  ${words}[-1]
       Valid Value  client  ['${sessions["Oem"]["OpenBMC"]["ClientID"]}']
       Valid Value  sessions["Id"]  ['${session_id}']
-      Valid Value  temp_ipaddr  ['${ip_address}']
+      Valid Value  temp_ipaddr  ${ip_address}
     END