Enable test cases for host's network settings

What test cases are added
    - Added test cases to set static and dhcp setting using REST
    - Added test cases to set static and dhcp setting using IPMI
    - Added test case to clear settings using IPMI
    - Added test cases to set invalid settings using both REST and IPMI

Resolves openbmc/openbmc-test-automation#48

Change-Id: Ia9ac56ad884318de703406d070aa7985474fab05
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/lib/utilities.py b/lib/utilities.py
index 980d06b..f316b3b 100755
--- a/lib/utilities.py
+++ b/lib/utilities.py
@@ -3,7 +3,23 @@
 from robot.libraries.BuiltIn import BuiltIn
 import imp
 import string
+import random
 
+def random_mac():
+    r"""
+    Return random mac address in the following format.
+    Example: 00:01:6C:80:02:78
+    """
+    return ":".join(map(lambda x: "%02x" % x, (random.randint(0x00, 0xff)
+        for _ in range(6))))
+
+def random_ip():
+    r"""
+    Return random ip address in the following format.
+    Example: 9.3.128.100
+    """
+    return ".".join(map(str, (random.randint(0, 255)
+        for _ in range(4))))
 
 def get_sensor(module_name, value):
     m = imp.load_source('module.name', module_name)
diff --git a/lib/utils.robot b/lib/utils.robot
index 82fcdbd..76195c3 100644
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -408,3 +408,34 @@
     Execute Command    rm ${file_path}-${LOG_TIME}
 
     [Return]    ${journal_log}
+
+Mac Address To Hex String
+    [Documentation]   Converts MAC address into hex format.
+    ...               Example
+    ...               Given the following MAC: 00:01:6C:80:02:78
+    ...               This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78
+    ...               Description of arguments:
+    ...               i_macaddress  MAC address in the following format 00:01:6C:80:02:78
+    [Arguments]    ${i_macaddress}
+
+    ${mac_hex}=  Catenate  0x${i_macaddress.replace(':', ' 0x')}
+    [return]    ${mac_hex}
+
+IP Address To Hex String
+    [Documentation]   Converts IP address into hex format.
+    ...               Example:
+    ...               Given the following IP: 10.3.164.100
+    ...               This keyword will return: 0xa 0x3 0xa4 0xa0
+    ...               Description of arguments:
+    ...               i_ipaddress  IP address in the following format 10.10.10.10
+    [Arguments]    ${i_ipaddress}
+
+    @{ip}=  Split String  ${i_ipaddress}    .
+    ${index}=  Set Variable  ${0}
+
+    :FOR    ${item}     IN      @{ip}
+    \   ${hex}=  Convert To Hex    ${item}    prefix=0x    lowercase=yes
+    \   Set List Value    ${ip}    ${index}    ${hex}
+    \   ${index}=  Set Variable    ${index + 1}
+    ${ip_hex}=  Catenate    @{ip}
+    [return]    ${ip_hex}