Modify MAC and Verify BMC Reinitializing Linklocal
Changes:
Modify MAC and Verify BMC Reinitializing Linklocal
Tested:
Ran and Tested on BMC Environment.
Change-Id: Ic65a2fe6c67d04a9b6026071c8ad19fd3679a717
Signed-off-by: Sweta Potthuri <spotthur@in.ibm.com>
diff --git a/lib/bmc_network_utils.robot b/lib/bmc_network_utils.robot
index 8cfb367..3188c4f 100644
--- a/lib/bmc_network_utils.robot
+++ b/lib/bmc_network_utils.robot
@@ -934,3 +934,60 @@
# Check if newly added DNS server is configured on BMC.
CLI Get and Verify Name Servers ${static_name_servers} ${valid_status_codes}
+
+Configure MAC Settings
+ [Documentation] Configure MAC settings via Redfish.
+ [Arguments] ${mac_address} ${valid_status_code}=${HTTP_OK}
+
+ # Description of argument(s):
+ # mac_address MAC address of BMC.
+ # valid_status_code Expected response code, default is ${HTTP_OK}.
+
+ ${active_channel_config}= Get Active Channel Config
+ ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
+
+ Redfish.Login
+ ${payload}= Create Dictionary MACAddress=${mac_address}
+
+ Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{payload}
+ ... valid_status_codes=[${valid_status_code},${HTTP_NO_CONTENT},${HTTP_INTERNAL_SERVER_ERROR}]
+
+ # After any modification on network interface, BMC restarts network
+ # Note: Network restart takes around 15-18s after patch request processing.
+ Sleep ${NETWORK_TIMEOUT}s
+
+ Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
+
+ # Verify whether new MAC address is populated on BMC system.
+ # It should not allow to configure invalid settings.
+ ${status}= Run Keyword And Return Status
+ ... Validate MAC On BMC ${mac_address}
+
+ IF ${valid_status_code} == ${HTTP_BAD_REQUEST}
+ Should Be Equal ${status} ${False}
+ ... msg=Allowing the configuration of an invalid MAC.
+ ELSE
+ Should Be Equal ${status} ${True}
+ ... msg=Not allowing the configuration of a valid MAC.
+ END
+
+ Verify MAC Address Via FW_Env ${mac_address} ${valid_status_code}
+
+Verify MAC Address Via FW_Env
+ [Documentation] Verify MAC address on FW_Env.
+ [Arguments] ${mac_address} ${valid_status_code}=${HTTP_OK}
+
+ # Description of argument(s):
+ # mac_address MAC address of BMC.
+ # valid_status_code Expected response code, default is ${HTTP_OK}.
+
+ ${status}= Run Keyword And Return Status
+ ... Validate MAC On FW_Env ${mac_address}
+
+ IF ${valid_status_code} == ${HTTP_BAD_REQUEST}
+ Should Be Equal ${status} ${False}
+ ... msg=Allowing the configuration of an invalid MAC.
+ ELSE
+ Should Be Equal ${status} ${True}
+ ... msg=Not allowing the configuration of a valid MAC.
+ END