1*** Settings *** 2Resource ../lib/utils.robot 3Resource ../lib/connection_client.robot 4Resource ../lib/boot_utils.robot 5 6*** Variables *** 7# MAC input from user. 8${MAC_ADDRESS} ${EMPTY} 9 10 11*** Keywords *** 12 13############################################################################### 14Check And Reset MAC 15 [Documentation] Update BMC with user input MAC address. 16 [Arguments] ${mac_address}=${MAC_ADDRESS} 17 18 # Description of argument(s): 19 # mac_address The mac address (e.g. 00:01:6c:80:02:28). 20 21 Should Not Be Empty ${mac_address} 22 Open Connection And Log In 23 ${bmc_mac_addr}= Execute Command On BMC cat /sys/class/net/eth0/address 24 Run Keyword If '${mac_address.lower()}' != '${bmc_mac_addr.lower()}' 25 ... Set MAC Address 26 27############################################################################### 28 29 30############################################################################### 31Set MAC Address 32 [Documentation] Update eth0 with input MAC address. 33 [Arguments] ${mac_address}=${MAC_ADDRESS} 34 35 # Description of argument(s): 36 # mac_address The mac address (e.g. 00:01:6c:80:02:28). 37 38 Write fw_setenv ethaddr ${mac_address} 39 OBMC Reboot (off) 40 41 # Take SSH session post BMC reboot. 42 Open Connection And Log In 43 ${bmc_mac_addr}= Execute Command On BMC cat /sys/class/net/eth0/address 44 Should Be Equal ${bmc_mac_addr} ${mac_address} ignore_case=True 45 46############################################################################### 47 48Get BMC IP Info 49 [Documentation] Get system IP address and prefix length. 50 51 Open Connection And Login 52 53 # Get system IP address and prefix length details using "ip addr" 54 # Sample Output of "ip addr": 55 # 1: eth0: <BROADCAST,MULTIAST> mtu 1500 qdisc mq state UP qlen 1000 56 # link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff 57 # inet xx.xx.xx.xx/24 brd xx.xx.xx.xx scope global eth0 58 59 ${cmd_output}= Execute Command On BMC /sbin/ip addr | grep eth0 60 61 # Get line having IP address details. 62 ${lines}= Get Lines Containing String ${cmd_output} inet 63 64 # List IP address details. 65 @{ip_components}= Split To Lines ${lines} 66 67 @{ip_data}= Create List 68 69 # Get all IP addresses and prefix lengths on system. 70 :FOR ${ip_component} IN @{ip_components} 71 \ @{if_info}= Split String ${ip_component} 72 \ ${ip_n_prefix}= Get From List ${if_info} 1 73 \ Append To List ${ip_data} ${ip_n_prefix} 74 75 [Return] ${ip_data} 76 77Get BMC Route Info 78 [Documentation] Get system route info. 79 80 Open Connection And Login 81 82 # Sample output of "ip route": 83 # default via xx.xx.xx.x dev eth0 84 # xx.xx.xx.0/23 dev eth0 src xx.xx.xx.xx 85 # xx.xx.xx.0/24 dev eth0 src xx.xx.xx.xx 86 87 ${cmd_output}= Execute Command On BMC /sbin/ip route 88 89 [Return] ${cmd_output} 90 91Get BMC MAC Address 92 [Documentation] Get system MAC address. 93 94 Open Connection And Login 95 96 # Sample output of "ip addr | grep ether": 97 # link/ether xx.xx.xx.xx.xx.xx brd ff:ff:ff:ff:ff:ff 98 99 ${cmd_output}= Execute Command On BMC /sbin/ip addr | grep ether 100 101 [Return] ${cmd_output} 102