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/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
+
+###############################################################################