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 ${bmc_mac_addr}= Execute Command On BMC cat /sys/class/net/eth0/address 41 Should Be Equal ${bmc_mac_addr} ${mac_address} ignore_case=True 42 43############################################################################### 44 45Get BMC IP Info 46 [Documentation] Get system IP address and prefix length. 47 48 Open Connection And Login 49 50 # Get system IP address and prefix length details using "ip addr" 51 # Sample Output of "ip addr": 52 # 1: eth0: <BROADCAST,MULTIAST> mtu 1500 qdisc mq state UP qlen 1000 53 # link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff 54 # inet xx.xx.xx.xx/24 brd xx.xx.xx.xx scope global eth0 55 56 ${cmd_output}= Execute Command On BMC /sbin/ip addr | grep eth0 57 58 # Get line having IP address details. 59 ${lines}= Get Lines Containing String ${cmd_output} inet 60 61 # List IP address details. 62 @{ip_components}= Split To Lines ${lines} 63 64 @{ip_data}= Create List 65 66 # Get all IP addresses and prefix lengths on system. 67 :FOR ${ip_component} IN @{ip_components} 68 \ @{if_info}= Split String ${ip_component} 69 \ ${ip_n_prefix}= Get From List ${if_info} 1 70 \ Append To List ${ip_data} ${ip_n_prefix} 71 72 [Return] ${ip_data} 73 74Get BMC Route Info 75 [Documentation] Get system route info. 76 77 Open Connection And Login 78 79 # Sample output of "ip route": 80 # default via xx.xx.xx.x dev eth0 81 # xx.xx.xx.0/23 dev eth0 src xx.xx.xx.xx 82 # xx.xx.xx.0/24 dev eth0 src xx.xx.xx.xx 83 84 ${cmd_output}= Execute Command On BMC /sbin/ip route 85 86 [Return] ${cmd_output} 87 88Get BMC MAC Address 89 [Documentation] Get system MAC address. 90 91 Open Connection And Login 92 93 # Sample output of "ip addr | grep ether": 94 # link/ether xx.xx.xx.xx.xx.xx brd ff:ff:ff:ff:ff:ff 95 96 ${cmd_output}= Execute Command On BMC /sbin/ip addr | grep ether 97 98 [Return] ${cmd_output} 99