Move keywords to lib/utils.robot

This commit moves keywords in update_mac.robot to lib/utils.robot.
These keywords can be now reused in other scripts where this
functionality is needed.

Change-Id: I0d34aab12aa69242ed022eb73aa1eea5ce61bab6
Signed-off-by: Sunil M <sunilmam@us.ibm.com>
diff --git a/lib/utils.robot b/lib/utils.robot
index 64afb23..fd376c2 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -2,12 +2,14 @@
 Resource                ../lib/resource.txt
 Resource                ../lib/rest_client.robot
 Resource                ../lib/connection_client.robot
+Resource                ../extended/obmc_boot_test_resource.robot
 Library                 DateTime
 Library                 Process
 Library                 OperatingSystem
 Library                 gen_print.py
 Library                 gen_robot_print.py
 Library                 gen_cmd.py
+Library                 gen_robot_keyword.py
 
 *** Variables ***
 ${SYSTEM_SHUTDOWN_TIME}       ${5}
@@ -33,6 +35,8 @@
 ${BOOT_COUNT}    ${0}
 ${count}  ${0}
 ${devicetree_base}  /sys/firmware/devicetree/base/model
+# MAC input from user.
+${MAC_ADDRESS}  ${EMPTY}
 
 # Initialize default debug value to 0.
 ${DEBUG}         ${0}
@@ -915,6 +919,30 @@
     # Set BOOT_TIME variable to current boot time.
     Set Global Variable  ${BOOT_COUNT}  ${count}
 
+Check And Reset MAC
+    [Documentation]  Update BMC with user input MAC address.
+    [Arguments]  ${mac_address}=${MAC_ADDRESS}
+
+    # Description of argument(s):
+    # mac_address  The mac address (e.g. 00:01:6c:80:02:28).
+
+    Should Not Be Empty  ${mac_address}
+    Open Connection And Log In
+    ${bmc_mac_addr}=  Execute Command On BMC  cat /sys/class/net/eth0/address
+    Run Keyword If  '${mac_address}' != '${bmc_mac_addr}'
+    ...  Set MAC Address
+
+Set MAC Address
+    [Documentation]  Update eth0 with input MAC address.
+    [Arguments]  ${mac_address}=${MAC_ADDRESS}
+
+    # Description of argument(s):
+    # mac_address  The mac address (e.g. 00:01:6c:80:02:28).
+    Write  fw_setenv ethaddr ${mac_address}
+    Run Key U  OBMC Boot Test \ OBMC Reboot (off)
+    ${bmc_mac_addr}=  Execute Command On BMC  cat /sys/class/net/eth0/address
+    Should Be Equal  ${bmc_mac_addr}  ${mac_address}
+
 ###############################################################################
 Delete Error logs
     [Documentation]  Delete error logs.
diff --git a/tools/update_mac.robot b/tools/update_mac.robot
index 2106c04..472fc27 100644
--- a/tools/update_mac.robot
+++ b/tools/update_mac.robot
@@ -1,32 +1,11 @@
 *** Settings ***
 Documentation  Update BMC MAC address with input MAC.
 
-Library   ../lib/gen_robot_keyword.py
 Resource  ../lib/utils.robot
-Resource  ../extended/obmc_boot_test_resource.robot
-
-*** Variables ***
-
-# MAC input from Jenkins job.
-${MAC_ADDRESS}  ${EMPTY}
 
 *** Test Cases ***
 
-Check And Reset MAC
-    [Documentation]  Update BMC with user input MAC address.
+Check And Reset MAC on BMC
+    [Documentation]  Verify and Update BMC MAC address.
 
-    Should Not Be Empty  ${MAC_ADDRESS}
-    Open Connection And Log In
-    ${bmc_mac_addr}=  Execute Command On BMC  cat /sys/class/net/eth0/address
-    Run Keyword If  '${MAC_ADDRESS}' != '${bmc_mac_addr}'
-    ...  Set MAC Address
-
-*** Keywords ***
-
-Set MAC Address
-    [Documentation]  Update eth0 with input MAC address.
-
-    Write  fw_setenv ethaddr ${MAC_ADDRESS}
-    Run Key U  OBMC Boot Test \ OBMC Reboot (off)
-    ${bmc_mac_addr}=  Execute Command On BMC  cat /sys/class/net/eth0/address
-    Should Be Equal  ${bmc_mac_addr}  ${MAC_ADDRESS}
+    Check And Reset MAC