Automation fix for ifconfig command

Changes:
   - ifconfig error message:
     Command 'ifconfig' returned non-zero exit status 127.
   - New implementaion uses socket module to get the hostname.

Change-Id: I3b60efe5b88fb44676b729cb8b28ebb9cf735638
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
index 00a675f..c2ea9f8 100644
--- a/lib/bmc_network_utils.py
+++ b/lib/bmc_network_utils.py
@@ -13,6 +13,7 @@
 import re
 import ipaddress
 import subprocess
+import socket
 from robot.libraries.BuiltIn import BuiltIn
 import json
 import bmc_ssh_utils as bsu
@@ -20,16 +21,15 @@
 ip_regex = r"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}"
 
 
-def get_running_system_ip():
+def get_hostname():
     r"""
-    Get the IP address of server from which robot code is running.
+    Get the host name of server from which robot code is running.
+
     """
 
-    stdout = subprocess.check_output("/sbin/ifconfig", shell=True)
-    stdout = stdout.decode("utf-8")
-    ip_list = re.findall(ip_regex, stdout)
+    host_name = socket.gethostname()
 
-    return ip_list
+    return host_name
 
 
 def netmask_prefix_length(netmask):