blob: fbc5c6f3ad5d87032c778c1398ac1314afd44158 [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
Michael Walsh1b0ceb22017-05-31 16:03:01 -050013Check And Reset MAC
14 [Documentation] Update BMC with user input MAC address.
15 [Arguments] ${mac_address}=${MAC_ADDRESS}
16
17 # Description of argument(s):
18 # mac_address The mac address (e.g. 00:01:6c:80:02:28).
19
20 Should Not Be Empty ${mac_address}
21 Open Connection And Log In
22 ${bmc_mac_addr}= Execute Command On BMC cat /sys/class/net/eth0/address
23 Run Keyword If '${mac_address.lower()}' != '${bmc_mac_addr.lower()}'
24 ... Set MAC Address
25
Michael Walsh1b0ceb22017-05-31 16:03:01 -050026
Michael Walsh1b0ceb22017-05-31 16:03:01 -050027Set MAC Address
28 [Documentation] Update eth0 with input MAC address.
29 [Arguments] ${mac_address}=${MAC_ADDRESS}
30
31 # Description of argument(s):
32 # mac_address The mac address (e.g. 00:01:6c:80:02:28).
33
34 Write fw_setenv ethaddr ${mac_address}
35 OBMC Reboot (off)
Sunil Md1c4f272017-07-07 09:03:24 -050036
37 # Take SSH session post BMC reboot.
38 Open Connection And Log In
Michael Walsh1b0ceb22017-05-31 16:03:01 -050039 ${bmc_mac_addr}= Execute Command On BMC cat /sys/class/net/eth0/address
40 Should Be Equal ${bmc_mac_addr} ${mac_address} ignore_case=True
41
Prashanth Kattie79c5402017-06-08 07:40:49 -050042
43Get BMC IP Info
44 [Documentation] Get system IP address and prefix length.
45
46 Open Connection And Login
47
48 # Get system IP address and prefix length details using "ip addr"
49 # Sample Output of "ip addr":
50 # 1: eth0: <BROADCAST,MULTIAST> mtu 1500 qdisc mq state UP qlen 1000
51 # link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
52 # inet xx.xx.xx.xx/24 brd xx.xx.xx.xx scope global eth0
53
54 ${cmd_output}= Execute Command On BMC /sbin/ip addr | grep eth0
55
56 # Get line having IP address details.
57 ${lines}= Get Lines Containing String ${cmd_output} inet
58
59 # List IP address details.
60 @{ip_components}= Split To Lines ${lines}
61
62 @{ip_data}= Create List
63
64 # Get all IP addresses and prefix lengths on system.
65 :FOR ${ip_component} IN @{ip_components}
66 \ @{if_info}= Split String ${ip_component}
67 \ ${ip_n_prefix}= Get From List ${if_info} 1
68 \ Append To List ${ip_data} ${ip_n_prefix}
69
70 [Return] ${ip_data}
71
72Get BMC Route Info
73 [Documentation] Get system route info.
74
75 Open Connection And Login
76
77 # Sample output of "ip route":
78 # default via xx.xx.xx.x dev eth0
79 # xx.xx.xx.0/23 dev eth0 src xx.xx.xx.xx
80 # xx.xx.xx.0/24 dev eth0 src xx.xx.xx.xx
81
82 ${cmd_output}= Execute Command On BMC /sbin/ip route
83
84 [Return] ${cmd_output}
85
86Get BMC MAC Address
87 [Documentation] Get system MAC address.
88
89 Open Connection And Login
90
91 # Sample output of "ip addr | grep ether":
92 # link/ether xx.xx.xx.xx.xx.xx brd ff:ff:ff:ff:ff:ff
93
94 ${cmd_output}= Execute Command On BMC /sbin/ip addr | grep ether
95
96 [Return] ${cmd_output}
Prashanth Katti40fb8ca2017-07-25 06:47:23 -050097
98Get BMC Hostname
99 [Documentation] Get BMC hostname.
100
101 # Sample output of "hostnamectl":
102 # Static hostname: xxyyxxyyxx
103 # Icon name: computer
104 # Machine ID: 6939927dc0db409ea09289d5b56eef08
105 # Boot ID: bb806955fd904d47b6aa4bc7c34df482
106 # Operating System: Phosphor OpenBMC (xxx xx xx) v1.xx.x-xx
107 # Kernel: Linux 4.10.17-d6ae40dc4c4dff3265cc254d404ed6b03fcc2206
108 # Architecture: arm
109
110 ${output}= Execute Command on BMC hostnamectl | grep hostname
111
112 [Return] ${output}
Prashanth Katti90f9ff22017-08-11 06:17:12 -0500113
114Get List Of IP Address Via REST
115 [Documentation] Get list of IP address via REST.
116 [Arguments] @{ip_uri_list}
117
118 # Description of argument(s):
119 # ip_uri_list List of IP objects.
120 # Example:
121 # "data": [
122 # "/xyz/openbmc_project/network/eth0/ipv4/e9767624",
123 # "/xyz/openbmc_project/network/eth0/ipv4/31f4ce8b"
124 # ],
125
126 ${ip_list}= Create List
127
128 : FOR ${ip_uri} IN @{ip_uri_list}
129 \ ${ip_addr}= Read Attribute ${ip_uri} Address
130 \ Append To List ${ip_list} ${ip_addr}
131
132 [Return] @{ip_list}
133
134Delete IP And Object
135 [Documentation] Delete IP and object.
136 [Arguments] ${ip_addr} @{ip_uri_list}
137
138 # Description of argument(s):
139 # ip_addr IP address to be deleted.
140 # ip_uri_list List of IP object URIs.
141
142 # Find IP object having this IP address.
143
144 : FOR ${ip_uri} IN @{ip_uri_list}
145 \ ${ip_addr1}= Read Attribute ${ip_uri} Address
146 \ Run Keyword If '${ip_addr}' == '${ip_addr1}' Exit For Loop
147
148 # If the given IP address is not configured, return.
149 # Otherwise, delete the IP and object.
150
151 Run Keyword And Return If '${ip_addr}' != '${ip_addr1}'
152 ... Pass Execution IP address to be deleted is not configured.
153
154 Run Keyword And Ignore Error OpenBMC Delete Request ${ip_uri}
155
156 # After any modification on network interface, BMC restarts network
157 # module, wait until it is reachable.
158
Prashanth Katti3690dc02017-11-22 07:21:24 -0600159 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_RETRY_TIME}
160 ... ${NETWORK_TIMEOUT}
Prashanth Katti90f9ff22017-08-11 06:17:12 -0500161
162 # Verify whether deleted IP address is removed from BMC system.
163
164 ${ip_data}= Get BMC IP Info
Prashanth Katti160faf62017-09-07 01:05:56 -0500165 Should Not Contain Match ${ip_data} ${ip_addr}*
Prashanth Katti90f9ff22017-08-11 06:17:12 -0500166 ... msg=IP address not deleted.