blob: 6480f3b8df869b85251bd92ca28c3813e4a1060d [file] [log] [blame]
Prashanth Kattif58cce02019-02-06 03:05:14 -06001*** Settings ***
2Documentation Network interface configuration and verification
3 ... tests.
4
George Keishing5d467552019-02-08 23:30:48 -06005Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/bmc_network_utils.robot
7Resource ../../lib/openbmc_ffdc.robot
Prashanth Katti747ce9d2019-02-07 07:23:48 -06008Library ../../lib/bmc_network_utils.py
Vijayde3bf7b2019-04-16 04:56:09 -05009Library Collections
Prashanth Kattif58cce02019-02-06 03:05:14 -060010
11Test Setup Test Setup Execution
12Test Teardown Test Teardown Execution
13
Prashanth Katti23efc6e2019-03-13 06:07:15 -050014*** Variables ***
Vijayde3bf7b2019-04-16 04:56:09 -050015${test_hostname} openbmc
16${test_ipv4_addr} 10.7.7.7
17${test_ipv4_invalid_addr} 0.0.1.a
18${test_subnet_mask} 255.255.0.0
19${test_gateway} 10.7.7.1
Prashanth Kattib36a7522019-05-22 05:32:39 -050020${broadcast_ip} 10.7.7.255
21${loopback_ip} 127.0.0.2
22${multicast_ip} 224.6.6.6
23${out_of_range_ip} 10.7.7.256
Prashanth Katti23efc6e2019-03-13 06:07:15 -050024
Prashanth Kattif58cce02019-02-06 03:05:14 -060025*** Test Cases ***
26
27Get IP Address And Verify
28 [Documentation] Get IP Address And Verify.
George Keishing5d467552019-02-08 23:30:48 -060029 [Tags] Get_IP_Address_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060030
31 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060032 \ Verify IP On BMC ${network_configuration['Address']}
33
Prashanth Kattif58cce02019-02-06 03:05:14 -060034Get Netmask And Verify
35 [Documentation] Get Netmask And Verify.
George Keishing5d467552019-02-08 23:30:48 -060036 [Tags] Get_Netmask_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060037
38 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060039 \ Verify Netmask On BMC ${network_configuration['SubnetMask']}
40
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060041Get Gateway And Verify
42 [Documentation] Get gateway and verify it's existence on the BMC.
43 [Tags] Get_Gateway_And_Verify
44
45 : FOR ${network_configuration} IN @{network_configurations}
46 \ Verify Gateway On BMC ${network_configuration['Gateway']}
47
48Get MAC Address And Verify
49 [Documentation] Get MAC address and verify it's existence on the BMC.
50 [Tags] Get_MAC_Address_And_Verify
51
George Keishing97c93942019-03-04 12:45:07 -060052 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060053 ${macaddr}= Get From Dictionary ${resp.dict} MACAddress
54 Validate MAC On BMC ${macaddr}
Prashanth Kattif58cce02019-02-06 03:05:14 -060055
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -060056Verify All Configured IP And Netmask
57 [Documentation] Verify all configured IP and netmask on BMC.
58 [Tags] Verify_All_Configured_IP_And_Netmask
59
60 : FOR ${network_configuration} IN @{network_configurations}
61 \ Verify IP And Netmask On BMC ${network_configuration['Address']}
62 ... ${network_configuration['SubnetMask']}
63
Prashanth Katti23efc6e2019-03-13 06:07:15 -050064Get Hostname And Verify
65 [Documentation] Get hostname via Redfish and verify.
66 [Tags] Get_Hostname_And_Verify
67
68 ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
69
70 Validate Hostname On BMC ${hostname}
71
72Configure Hostname And Verify
73 [Documentation] Configure hostname via Redfish and verify.
74 [Tags] Configure_Hostname_And_Verify
75
76 Configure Hostname ${test_hostname}
77
78 Validate Hostname On BMC ${test_hostname}
79
Vijayde3bf7b2019-04-16 04:56:09 -050080Add Valid IPv4 Address And Verify
81 [Documentation] Add IPv4 Address via Redfish and verify.
82 [Tags] Add_Valid_IPv4_Addres_And_Verify
83
84 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
85 Delete IP Address ${test_ipv4_addr}
86
87Add Invalid IPv4 Address And Verify
88 [Documentation] Add Invalid IPv4 Address via Redfish and verify.
89 [Tags] Add_Invalid_IPv4_Addres_And_Verify
90
91 Add IP Address ${test_ipv4_invalid_addr} ${test_subnet_mask}
92 ... ${test_gateway} valid_status_codes=${HTTP_BAD_REQUEST}
93
Prashanth Kattib36a7522019-05-22 05:32:39 -050094Configure Out Of Range IP
95 [Documentation] Configure out-of-range IP address.
96 [Tags] Configure_Out_Of_Range_IP
97 [Template] Add IP Address
98
99 # ip subnet_mask gateway valid_status_codes
100 ${out_of_range_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
101
102Configure Broadcast IP
103 [Documentation] Configure broadcast IP address.
104 [Tags] Configure_Broadcast_IP
105 [Template] Add IP Address
106
107 # ip subnet_mask gateway valid_status_codes
108 ${broadcast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
109
110Configure Multicast IP
111 [Documentation] Configure multicast IP address.
112 [Tags] Configure_Multicast_IP
113 [Template] Add IP Address
114
115 # ip subnet_mask gateway valid_status_codes
116 ${multicast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
117
118Configure Loopback IP
119 [Documentation] Configure loopback IP address.
120 [Tags] Configure_Loopback_IP
121 [Template] Add IP Address
122
123 # ip subnet_mask gateway valid_status_codes
124 ${loopback_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
125
126Add Valid IPv4 Address And Check Persistency
127 [Documentation] Add IPv4 address and check peristency.
128 [Tags] Add_Valid_IPv4_Addres_And_Check_Persistency
129
130 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
131
132 # Reboot BMC and verify persistency.
133 OBMC Reboot (off)
134 Verify IP On BMC ${test_ipv4_addr}
135 Delete IP Address ${test_ipv4_addr}
Vijayde3bf7b2019-04-16 04:56:09 -0500136
Prashanth Kattif58cce02019-02-06 03:05:14 -0600137*** Keywords ***
138
139Test Setup Execution
140 [Documentation] Test setup execution.
141
George Keishing97c93942019-03-04 12:45:07 -0600142 Redfish.Login
Prashanth Kattif58cce02019-02-06 03:05:14 -0600143
144 @{network_configurations}= Get Network Configuration
145 Set Test Variable @{network_configurations}
146
147 # Get BMC IP address and prefix length.
148 ${ip_data}= Get BMC IP Info
149 Set Test Variable ${ip_data}
150
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600151
Prashanth Kattif58cce02019-02-06 03:05:14 -0600152Get Network Configuration
153 [Documentation] Get network configuration.
154
155 # Sample output:
156 #{
157 # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
158 # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
159 # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
160 # "Description": "Management Network Interface",
161 # "IPv4Addresses": [
162 # {
163 # "Address": "169.254.xx.xx",
164 # "AddressOrigin": "IPv4LinkLocal",
165 # "Gateway": "0.0.0.0",
166 # "SubnetMask": "255.255.0.0"
167 # },
168 # {
169 # "Address": "xx.xx.xx.xx",
170 # "AddressOrigin": "Static",
171 # "Gateway": "xx.xx.xx.1",
172 # "SubnetMask": "xx.xx.xx.xx"
173 # }
174 # ],
175 # "Id": "eth0",
176 # "MACAddress": "xx:xx:xx:xx:xx:xx",
177 # "Name": "Manager Ethernet Interface",
178 # "SpeedMbps": 0,
179 # "VLAN": {
180 # "VLANEnable": false,
181 # "VLANId": 0
182 # }
183
George Keishing97c93942019-03-04 12:45:07 -0600184 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Kattif58cce02019-02-06 03:05:14 -0600185 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses
186 [Return] @{network_configurations}
187
George Keishing5d467552019-02-08 23:30:48 -0600188
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600189Verify IP On BMC
190 [Documentation] Verify IP on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600191 [Arguments] ${ip}
192
Vijayde3bf7b2019-04-16 04:56:09 -0500193 # Description of argument(s):
194 # ip IP address to be verified (e.g. "10.7.7.7").
Prashanth Kattif58cce02019-02-06 03:05:14 -0600195
196 # Get IP address details on BMC using IP command.
197 @{ip_data}= Get BMC IP Info
198 Should Contain Match ${ip_data} ${ip}/*
199 ... msg=IP address does not exist.
200
Vijayde3bf7b2019-04-16 04:56:09 -0500201Add IP Address
202 [Documentation] Add IP Address To BMC.
203 [Arguments] ${ip} ${subnet_mask} ${gateway}
204 ... ${valid_status_codes}=${HTTP_OK}
205
206 # Description of argument(s):
207 # ip IP address to be added (e.g. "10.7.7.7").
208 # subnet_mask Subnet mask for the IP to be added
209 # (e.g. "255.255.0.0").
210 # gateway Gateway for the IP to be added (e.g. "10.7.7.1").
211 # valid_status_codes Expected return code from patch operation
212 # (e.g. "200"). See prolog of rest_request
213 # method in redfish_plut.py for details.
214
215 ${empty_dict}= Create Dictionary
216 ${ip_data}= Create Dictionary Address=${ip}
217 ... AddressOrigin=Static SubnetMask=${subnet_mask}
218 ... Gateway=${gateway}
219
220 ${patch_list}= Create List
221 ${network_configurations}= Get Network Configuration
222 ${num_entries}= Get Length ${network_configurations}
223
224 : FOR ${INDEX} IN RANGE 0 ${num_entries}
225 \ Append To List ${patch_list} ${empty_dict}
226
George Keishing98ffa862019-05-23 10:07:45 -0500227 # We need not check for existence of IP on BMC while adding.
Vijayde3bf7b2019-04-16 04:56:09 -0500228 Append To List ${patch_list} ${ip_data}
229 ${data}= Create Dictionary IPv4Addresses=${patch_list}
230
231 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
232 ... valid_status_codes=[${valid_status_codes}]
233
234 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK}'
235
236 # Note: Network restart takes around 15-18s after patch request processing.
237 Sleep ${NETWORK_TIMEOUT}s
238 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
239
240 Verify IP On BMC ${ip}
241 Validate Network Config On BMC
242
243
244Delete IP Address
245 [Documentation] Delete IP Address Of BMC.
246 [Arguments] ${ip} ${valid_status_codes}=${HTTP_OK}
247
248 # Description of argument(s):
249 # ip IP address to be deleted (e.g. "10.7.7.7").
250 # valid_status_codes Expected return code from patch operation
251 # (e.g. "200"). See prolog of rest_request
252 # method in redfish_plut.py for details.
253
254 ${empty_dict}= Create Dictionary
255 ${patch_list}= Create List
256
257 @{network_configurations}= Get Network Configuration
258 : FOR ${network_configuration} IN @{network_configurations}
259 \ Run Keyword If '${network_configuration['Address']}' == '${ip}'
260 ... Append To List ${patch_list} ${null}
261 ... ELSE Append To List ${patch_list} ${empty_dict}
262
263 ${ip_found}= Run Keyword And Return Status List Should Contain Value
264 ... ${patch_list} ${null} msg=${ip} does not exist on BMC
265 Pass Execution If ${ip_found} == ${False} ${ip} does not exist on BMC
266
267 # Run patch command only if given IP is found on BMC
268 ${data}= Create Dictionary IPv4Addresses=${patch_list}
269
270 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
271 ... valid_status_codes=[${valid_status_codes}]
272
273 # Note: Network restart takes around 15-18s after patch request processing
274 Sleep ${NETWORK_TIMEOUT}s
275 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
276
277 ${delete_status}= Run Keyword And Return Status Verify IP On BMC ${ip}
278 Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
279 ... Should Be True ${delete_status} == ${False}
280 ... ELSE Should Be True ${delete_status} == ${True}
281
282 Validate Network Config On BMC
283
284
285Validate Network Config On BMC
286 [Documentation] Check that network info obtained via redfish matches info
287 ... obtained via CLI.
288
289 @{network_configurations}= Get Network Configuration
290 ${ip_data}= Get BMC IP Info
291 : FOR ${network_configuration} IN @{network_configurations}
292 \ Should Contain Match ${ip_data} ${network_configuration['Address']}/*
293 ... msg=IP address does not exist.
294
George Keishing5d467552019-02-08 23:30:48 -0600295
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600296Verify Netmask On BMC
297 [Documentation] Verify netmask on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600298 [Arguments] ${netmask}
299
300 # Description of the argument(s):
301 # netmask netmask value to be verified.
302
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600303 ${prefix_length}= Netmask Prefix Length ${netmask}
304
305 Should Contain Match ${ip_data} */${prefix_length}
306 ... msg=Prefix length does not exist.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600307
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -0600308Verify Gateway On BMC
309 [Documentation] Verify gateway on BMC.
310 [Arguments] ${gateway_ip}=0.0.0.0
311
312 # Description of argument(s):
313 # gateway_ip Gateway IP address.
314
315 ${route_info}= Get BMC Route Info
316
317 # If gateway IP is empty or 0.0.0.0 it will not have route entry.
318
319 Run Keyword If '${gateway_ip}' == '0.0.0.0'
320 ... Pass Execution Gateway IP is "0.0.0.0".
321 ... ELSE
322 ... Should Contain ${route_info} ${gateway_ip}
323 ... msg=Gateway IP address not matching.
George Keishing5d467552019-02-08 23:30:48 -0600324
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -0600325Verify IP And Netmask On BMC
326 [Documentation] Verify IP and netmask on BMC.
327 [Arguments] ${ip} ${netmask}
328
329 # Description of the argument(s):
330 # ip IP address to be verified.
331 # netmask netmask value to be verified.
332
333 ${prefix_length}= Netmask Prefix Length ${netmask}
334 @{ip_data}= Get BMC IP Info
335
336 ${ip_with_netmask}= Catenate ${ip}/${prefix_length}
337 Should Contain ${ip_data} ${ip_with_netmask}
338 ... msg=IP and netmask pair does not exist.
339
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500340Configure Hostname
341 [Documentation] Configure hostname on BMC via Redfish.
342 [Arguments] ${hostname}
343
344 # Description of argument(s):
345 # hostname A hostname value which is to be configured on BMC.
346
347 ${data}= Create Dictionary HostName=${hostname}
348 Redfish.patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
349
350Validate Hostname On BMC
351 [Documentation] Verify that the hostname read via Redfish is the same as the
352 ... hostname configured on system.
353 [Arguments] ${hostname}
354
355 # Description of argument(s):
356 # hostname A hostname value which is to be compared to the hostname
357 # configured on system.
358
359 ${sys_hostname}= Get BMC Hostname
Prashanth Katti466d8342019-03-21 08:58:50 -0500360 Should Be Equal ${sys_hostname} ${hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500361 ... ignore_case=True msg=Hostname does not exist.
362
Prashanth Kattif58cce02019-02-06 03:05:14 -0600363Test Teardown Execution
364 [Documentation] Test teardown execution.
365
366 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600367 Redfish.Logout