blob: c6606117ee742c0251b407ac28553b0edce991cc [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 Katti6cedca22019-05-30 02:31:11 -0500137Add Fourth Octet Threshold IP And Verify
138 [Documentation] Add fourth octet threshold IP and verify.
139 [Tags] Add_Fourth_Octet_Threshold_IP_And_Verify
140
141 Add IP Address 10.7.7.254 ${test_subnet_mask} ${test_gateway}
142 Delete IP Address 10.7.7.254
143
144Add Fourth Octet Lowest IP And Verify
145 [Documentation] Add fourth octet lowest IP and verify.
146 [Tags] Add_Fourth_Octet_Lowest_IP_And_Verify
147
148 Add IP Address 10.7.7.1 ${test_subnet_mask} ${test_gateway}
149 Delete IP Address 10.7.7.1
150
151Add Third Octet Threshold IP And Verify
152 [Documentation] Add third octet threshold IP and verify.
153 [Tags] Add_Third_Octet_Threshold_IP_And_Verify
154
155 Add IP Address 10.7.255.7 ${test_subnet_mask} ${test_gateway}
156 Delete IP Address 10.7.255.7
157
158Add Third Octet Lowest IP And Verify
159 [Documentation] Add third octet lowest IP and verify.
160 [Tags] Add_Third_Octet_Lowest_IP_And_Verify
161
162 Add IP Address 10.7.0.7 ${test_subnet_mask} ${test_gateway}
163 Delete IP Address 10.7.0.7
164
165Add Second Octet Threshold IP And Verify
166 [Documentation] Add second octet threshold IP and verify.
167 [Tags] Add_Second_Octet_Threshold_IP_And_Verify
168
169 Add IP Address 10.255.7.7 ${test_subnet_mask} ${test_gateway}
170 Delete IP Address 10.255.7.7
171
172Add Second Octet Lowest IP And Verify
173 [Documentation] Add second octet lowest IP and verify.
174 [Tags] Add_Second_Octet_Lowest_IP_And_Verify
175
176 Add IP Address 10.0.7.7 ${test_subnet_mask} ${test_gateway}
177 Delete IP Address 10.0.7.7
178
179Add First Octet Threshold IP And Verify
180 [Documentation] Add first octet threshold IP and verify.
181 [Tags] Add_First_Octet_Threshold_IP_And_Verify
182
183 Add IP Address 223.7.7.7 ${test_subnet_mask} ${test_gateway}
184 Delete IP Address 223.7.7.7
185
186Add First Octet Lowest IP And Verify
187 [Documentation] Add first octet lowest IP and verify.
188 [Tags] Add_First_Octet_Lowest_IP_And_Verify
189
190 Add IP Address 1.7.7.7 ${test_subnet_mask} ${test_gateway}
191 Delete IP Address 1.7.7.7
192
Prashanth Kattif58cce02019-02-06 03:05:14 -0600193*** Keywords ***
194
195Test Setup Execution
196 [Documentation] Test setup execution.
197
George Keishing97c93942019-03-04 12:45:07 -0600198 Redfish.Login
Prashanth Kattif58cce02019-02-06 03:05:14 -0600199
200 @{network_configurations}= Get Network Configuration
201 Set Test Variable @{network_configurations}
202
203 # Get BMC IP address and prefix length.
204 ${ip_data}= Get BMC IP Info
205 Set Test Variable ${ip_data}
206
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600207
Prashanth Kattif58cce02019-02-06 03:05:14 -0600208Get Network Configuration
209 [Documentation] Get network configuration.
210
211 # Sample output:
212 #{
213 # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
214 # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
215 # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
216 # "Description": "Management Network Interface",
217 # "IPv4Addresses": [
218 # {
219 # "Address": "169.254.xx.xx",
220 # "AddressOrigin": "IPv4LinkLocal",
221 # "Gateway": "0.0.0.0",
222 # "SubnetMask": "255.255.0.0"
223 # },
224 # {
225 # "Address": "xx.xx.xx.xx",
226 # "AddressOrigin": "Static",
227 # "Gateway": "xx.xx.xx.1",
228 # "SubnetMask": "xx.xx.xx.xx"
229 # }
230 # ],
231 # "Id": "eth0",
232 # "MACAddress": "xx:xx:xx:xx:xx:xx",
233 # "Name": "Manager Ethernet Interface",
234 # "SpeedMbps": 0,
235 # "VLAN": {
236 # "VLANEnable": false,
237 # "VLANId": 0
238 # }
239
George Keishing97c93942019-03-04 12:45:07 -0600240 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Kattif58cce02019-02-06 03:05:14 -0600241 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses
242 [Return] @{network_configurations}
243
George Keishing5d467552019-02-08 23:30:48 -0600244
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600245Verify IP On BMC
246 [Documentation] Verify IP on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600247 [Arguments] ${ip}
248
Vijayde3bf7b2019-04-16 04:56:09 -0500249 # Description of argument(s):
250 # ip IP address to be verified (e.g. "10.7.7.7").
Prashanth Kattif58cce02019-02-06 03:05:14 -0600251
252 # Get IP address details on BMC using IP command.
253 @{ip_data}= Get BMC IP Info
254 Should Contain Match ${ip_data} ${ip}/*
255 ... msg=IP address does not exist.
256
Vijayde3bf7b2019-04-16 04:56:09 -0500257Add IP Address
258 [Documentation] Add IP Address To BMC.
259 [Arguments] ${ip} ${subnet_mask} ${gateway}
260 ... ${valid_status_codes}=${HTTP_OK}
261
262 # Description of argument(s):
263 # ip IP address to be added (e.g. "10.7.7.7").
264 # subnet_mask Subnet mask for the IP to be added
265 # (e.g. "255.255.0.0").
266 # gateway Gateway for the IP to be added (e.g. "10.7.7.1").
267 # valid_status_codes Expected return code from patch operation
268 # (e.g. "200"). See prolog of rest_request
269 # method in redfish_plut.py for details.
270
271 ${empty_dict}= Create Dictionary
272 ${ip_data}= Create Dictionary Address=${ip}
273 ... AddressOrigin=Static SubnetMask=${subnet_mask}
274 ... Gateway=${gateway}
275
276 ${patch_list}= Create List
277 ${network_configurations}= Get Network Configuration
278 ${num_entries}= Get Length ${network_configurations}
279
280 : FOR ${INDEX} IN RANGE 0 ${num_entries}
281 \ Append To List ${patch_list} ${empty_dict}
282
George Keishing98ffa862019-05-23 10:07:45 -0500283 # We need not check for existence of IP on BMC while adding.
Vijayde3bf7b2019-04-16 04:56:09 -0500284 Append To List ${patch_list} ${ip_data}
285 ${data}= Create Dictionary IPv4Addresses=${patch_list}
286
287 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
288 ... valid_status_codes=[${valid_status_codes}]
289
290 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK}'
291
292 # Note: Network restart takes around 15-18s after patch request processing.
293 Sleep ${NETWORK_TIMEOUT}s
294 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
295
296 Verify IP On BMC ${ip}
297 Validate Network Config On BMC
298
299
300Delete IP Address
301 [Documentation] Delete IP Address Of BMC.
302 [Arguments] ${ip} ${valid_status_codes}=${HTTP_OK}
303
304 # Description of argument(s):
305 # ip IP address to be deleted (e.g. "10.7.7.7").
306 # valid_status_codes Expected return code from patch operation
307 # (e.g. "200"). See prolog of rest_request
308 # method in redfish_plut.py for details.
309
310 ${empty_dict}= Create Dictionary
311 ${patch_list}= Create List
312
313 @{network_configurations}= Get Network Configuration
314 : FOR ${network_configuration} IN @{network_configurations}
315 \ Run Keyword If '${network_configuration['Address']}' == '${ip}'
316 ... Append To List ${patch_list} ${null}
317 ... ELSE Append To List ${patch_list} ${empty_dict}
318
319 ${ip_found}= Run Keyword And Return Status List Should Contain Value
320 ... ${patch_list} ${null} msg=${ip} does not exist on BMC
321 Pass Execution If ${ip_found} == ${False} ${ip} does not exist on BMC
322
323 # Run patch command only if given IP is found on BMC
324 ${data}= Create Dictionary IPv4Addresses=${patch_list}
325
326 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
327 ... valid_status_codes=[${valid_status_codes}]
328
329 # Note: Network restart takes around 15-18s after patch request processing
330 Sleep ${NETWORK_TIMEOUT}s
331 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
332
333 ${delete_status}= Run Keyword And Return Status Verify IP On BMC ${ip}
334 Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
335 ... Should Be True ${delete_status} == ${False}
336 ... ELSE Should Be True ${delete_status} == ${True}
337
338 Validate Network Config On BMC
339
340
341Validate Network Config On BMC
342 [Documentation] Check that network info obtained via redfish matches info
343 ... obtained via CLI.
344
345 @{network_configurations}= Get Network Configuration
346 ${ip_data}= Get BMC IP Info
347 : FOR ${network_configuration} IN @{network_configurations}
348 \ Should Contain Match ${ip_data} ${network_configuration['Address']}/*
349 ... msg=IP address does not exist.
350
George Keishing5d467552019-02-08 23:30:48 -0600351
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600352Verify Netmask On BMC
353 [Documentation] Verify netmask on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600354 [Arguments] ${netmask}
355
356 # Description of the argument(s):
357 # netmask netmask value to be verified.
358
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600359 ${prefix_length}= Netmask Prefix Length ${netmask}
360
361 Should Contain Match ${ip_data} */${prefix_length}
362 ... msg=Prefix length does not exist.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600363
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -0600364Verify Gateway On BMC
365 [Documentation] Verify gateway on BMC.
366 [Arguments] ${gateway_ip}=0.0.0.0
367
368 # Description of argument(s):
369 # gateway_ip Gateway IP address.
370
371 ${route_info}= Get BMC Route Info
372
373 # If gateway IP is empty or 0.0.0.0 it will not have route entry.
374
375 Run Keyword If '${gateway_ip}' == '0.0.0.0'
376 ... Pass Execution Gateway IP is "0.0.0.0".
377 ... ELSE
378 ... Should Contain ${route_info} ${gateway_ip}
379 ... msg=Gateway IP address not matching.
George Keishing5d467552019-02-08 23:30:48 -0600380
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -0600381Verify IP And Netmask On BMC
382 [Documentation] Verify IP and netmask on BMC.
383 [Arguments] ${ip} ${netmask}
384
385 # Description of the argument(s):
386 # ip IP address to be verified.
387 # netmask netmask value to be verified.
388
389 ${prefix_length}= Netmask Prefix Length ${netmask}
390 @{ip_data}= Get BMC IP Info
391
392 ${ip_with_netmask}= Catenate ${ip}/${prefix_length}
393 Should Contain ${ip_data} ${ip_with_netmask}
394 ... msg=IP and netmask pair does not exist.
395
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500396Configure Hostname
397 [Documentation] Configure hostname on BMC via Redfish.
398 [Arguments] ${hostname}
399
400 # Description of argument(s):
401 # hostname A hostname value which is to be configured on BMC.
402
403 ${data}= Create Dictionary HostName=${hostname}
404 Redfish.patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
405
406Validate Hostname On BMC
407 [Documentation] Verify that the hostname read via Redfish is the same as the
408 ... hostname configured on system.
409 [Arguments] ${hostname}
410
411 # Description of argument(s):
412 # hostname A hostname value which is to be compared to the hostname
413 # configured on system.
414
415 ${sys_hostname}= Get BMC Hostname
Prashanth Katti466d8342019-03-21 08:58:50 -0500416 Should Be Equal ${sys_hostname} ${hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500417 ... ignore_case=True msg=Hostname does not exist.
418
Prashanth Kattif58cce02019-02-06 03:05:14 -0600419Test Teardown Execution
420 [Documentation] Test teardown execution.
421
422 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600423 Redfish.Logout