Moved some utils.robot keywords to new bmc_network_utils.robot.
utils.robot has gotten quite messy. Ideally it ought to be broken down
into several smaller files such as:
lib/state.robot
lib/bmc_info_utils.robot
lib/init_state_change.robot
lib/code_update_utils.robot
As part of that solution, lib/bmc_network_utils.robot has been created
to contain the following two keywords which were formerly in
utils.robot:
- Check And Reset MAC
- Set MAC Address
The only user of these functions is tools/update_mac.robot which has
been modified to resource the new file.
This change also serves to fix a problem that was recently introduced
by an addition to utils.robot. The following line had been added:
Resource ../extended/obmc_boot_test_resource.robot
However, when this test is run,
robot ... -v keyword_string:get_state -v lib_file_path:state.py
extended/run_keyword.robot
It failed because of this import/resource loop:
state.py -> utils.robot -> obmc_boot_test_resource.robot -> state.py
etc.
Change-Id: Ib5a7aab87056e9d091a1a37b9e1d69dda801e298
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/extended/standby_bmc.robot b/extended/standby_bmc.robot
index 997c2ab..04ec189 100644
--- a/extended/standby_bmc.robot
+++ b/extended/standby_bmc.robot
@@ -14,6 +14,7 @@
Resource ../lib/utils.robot
Resource ../lib/pdu/pdu.robot
Resource ../lib/state_manager.robot
+Resource ../lib/bmc_network_utils.robot
*** Variables ***
${HOST_SETTING} /org/openbmc/settings/host0
diff --git a/lib/bmc_network_utils.robot b/lib/bmc_network_utils.robot
new file mode 100644
index 0000000..3ea269f
--- /dev/null
+++ b/lib/bmc_network_utils.robot
@@ -0,0 +1,43 @@
+*** Settings ***
+Resource ../lib/utils.robot
+Resource ../lib/connection_client.robot
+Resource ../lib/boot_utils.robot
+
+*** Variables ***
+# MAC input from user.
+${MAC_ADDRESS} ${EMPTY}
+
+
+*** Keywords ***
+
+###############################################################################
+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.lower()}' != '${bmc_mac_addr.lower()}'
+ ... 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}
+ OBMC Reboot (off)
+ ${bmc_mac_addr}= Execute Command On BMC cat /sys/class/net/eth0/address
+ Should Be Equal ${bmc_mac_addr} ${mac_address} ignore_case=True
+
+###############################################################################
diff --git a/lib/utils.robot b/lib/utils.robot
index d558847..569edb3 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -2,7 +2,6 @@
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
@@ -36,8 +35,6 @@
${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}
@@ -934,30 +931,6 @@
# 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 472fc27..baba2a5 100644
--- a/tools/update_mac.robot
+++ b/tools/update_mac.robot
@@ -1,7 +1,7 @@
*** Settings ***
Documentation Update BMC MAC address with input MAC.
-Resource ../lib/utils.robot
+Resource ../lib/bmc_network_utils.robot
*** Test Cases ***