blob: ffb066eeaa6f140bd0b95e11c184ef3526ee78ea [file] [log] [blame]
Michael Walsh1b0ceb22017-05-31 16:03:01 -05001*** 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)
Sunil Md1c4f272017-07-07 09:03:24 -050040
41 # Take SSH session post BMC reboot.
42 Open Connection And Log In
Michael Walsh1b0ceb22017-05-31 16:03:01 -050043 ${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###############################################################################
Prashanth Kattie79c5402017-06-08 07:40:49 -050047
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}
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500102
103Get BMC Hostname
104 [Documentation] Get BMC hostname.
105
106 # Sample output of "hostnamectl":
107 # Static hostname: xxyyxxyyxx
108 # Icon name: computer
109 # Machine ID: 6939927dc0db409ea09289d5b56eef08
110 # Boot ID: bb806955fd904d47b6aa4bc7c34df482
111 # Operating System: Phosphor OpenBMC (xxx xx xx) v1.xx.x-xx
112 # Kernel: Linux 4.10.17-d6ae40dc4c4dff3265cc254d404ed6b03fcc2206
113 # Architecture: arm
114
115 ${output}= Execute Command on BMC hostnamectl | grep hostname
116
117 [Return] ${output}