blob: 0c14ae96baf6d7428e7d783659439dc041424319 [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 Kattif34fafa2019-06-20 05:04:40 -050014Force Tags Network_Conf_Test
15
Prashanth Katti23efc6e2019-03-13 06:07:15 -050016*** Variables ***
Vijayde3bf7b2019-04-16 04:56:09 -050017${test_hostname} openbmc
18${test_ipv4_addr} 10.7.7.7
19${test_ipv4_invalid_addr} 0.0.1.a
20${test_subnet_mask} 255.255.0.0
21${test_gateway} 10.7.7.1
Prashanth Kattib36a7522019-05-22 05:32:39 -050022${broadcast_ip} 10.7.7.255
23${loopback_ip} 127.0.0.2
24${multicast_ip} 224.6.6.6
25${out_of_range_ip} 10.7.7.256
Prashanth Katti23efc6e2019-03-13 06:07:15 -050026
Prashanth Katti040c8c12019-05-31 04:42:05 -050027# Valid netmask is 4 bytes long and has continuos block of 1s.
28# Maximum valid value in each octet is 255 and least value is 0.
29# 253 is not valid, as binary value is 11111101.
30${invalid_netmask} 255.255.253.0
31${alpha_netmask} ff.ff.ff.ff
32# Maximum value of octet in netmask is 255.
33${out_of_range_netmask} 255.256.255.0
34${more_byte_netmask} 255.255.255.0.0
35${less_byte_netmask} 255.255.255
Prashanth Kattic6ad6472019-06-14 03:33:39 -050036${threshold_netmask} 255.255.255.255
37${lowest_netmask} 128.0.0.0
38
39# There will be 4 octets in IP address (e.g. xx.xx.xx.xx)
40# but trying to configure xx.xx.xx
41${less_octet_ip} 10.3.36
42
43# For the address 10.6.6.6, the 10.6.6.0 portion describes the
44# network ID and the 6 describe the host.
45
46${network_id} 10.7.7.0
47${hex_ip} 0xa.0xb.0xc.0xd
48${negative_ip} 10.-7.-7.7
49${hex_ip} 0xa.0xb.0xc.0xd
Prashanth Katti7098c972019-07-03 06:56:42 -050050@{static_name_servers} 10.5.5.5
Prashanth Katti3c7b6432019-07-26 06:53:37 -050051@{null_value} null
Prashanth Kattiafe16b72019-08-02 00:29:45 -050052@{empty_dictionary} {}
53@{string_value} aa.bb.cc.dd
54
Prashanth Kattif58cce02019-02-06 03:05:14 -060055*** Test Cases ***
56
57Get IP Address And Verify
58 [Documentation] Get IP Address And Verify.
George Keishing5d467552019-02-08 23:30:48 -060059 [Tags] Get_IP_Address_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060060
61 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060062 \ Verify IP On BMC ${network_configuration['Address']}
63
Prashanth Kattif58cce02019-02-06 03:05:14 -060064Get Netmask And Verify
65 [Documentation] Get Netmask And Verify.
George Keishing5d467552019-02-08 23:30:48 -060066 [Tags] Get_Netmask_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060067
68 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060069 \ Verify Netmask On BMC ${network_configuration['SubnetMask']}
70
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060071Get Gateway And Verify
72 [Documentation] Get gateway and verify it's existence on the BMC.
73 [Tags] Get_Gateway_And_Verify
74
75 : FOR ${network_configuration} IN @{network_configurations}
76 \ Verify Gateway On BMC ${network_configuration['Gateway']}
77
78Get MAC Address And Verify
79 [Documentation] Get MAC address and verify it's existence on the BMC.
80 [Tags] Get_MAC_Address_And_Verify
81
George Keishing97c93942019-03-04 12:45:07 -060082 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060083 ${macaddr}= Get From Dictionary ${resp.dict} MACAddress
84 Validate MAC On BMC ${macaddr}
Prashanth Kattif58cce02019-02-06 03:05:14 -060085
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -060086Verify All Configured IP And Netmask
87 [Documentation] Verify all configured IP and netmask on BMC.
88 [Tags] Verify_All_Configured_IP_And_Netmask
89
90 : FOR ${network_configuration} IN @{network_configurations}
91 \ Verify IP And Netmask On BMC ${network_configuration['Address']}
92 ... ${network_configuration['SubnetMask']}
93
Prashanth Katti23efc6e2019-03-13 06:07:15 -050094Get Hostname And Verify
95 [Documentation] Get hostname via Redfish and verify.
96 [Tags] Get_Hostname_And_Verify
97
98 ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
99
100 Validate Hostname On BMC ${hostname}
101
102Configure Hostname And Verify
103 [Documentation] Configure hostname via Redfish and verify.
104 [Tags] Configure_Hostname_And_Verify
105
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500106 ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500107
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500108 Configure Hostname ${test_hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500109 Validate Hostname On BMC ${test_hostname}
110
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500111 # Revert back to initial hostname.
112 Configure Hostname ${hostname}
113 Validate Hostname On BMC ${hostname}
114
Vijayde3bf7b2019-04-16 04:56:09 -0500115Add Valid IPv4 Address And Verify
116 [Documentation] Add IPv4 Address via Redfish and verify.
117 [Tags] Add_Valid_IPv4_Addres_And_Verify
118
119 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
120 Delete IP Address ${test_ipv4_addr}
121
122Add Invalid IPv4 Address And Verify
123 [Documentation] Add Invalid IPv4 Address via Redfish and verify.
124 [Tags] Add_Invalid_IPv4_Addres_And_Verify
125
126 Add IP Address ${test_ipv4_invalid_addr} ${test_subnet_mask}
127 ... ${test_gateway} valid_status_codes=${HTTP_BAD_REQUEST}
128
Prashanth Kattib36a7522019-05-22 05:32:39 -0500129Configure Out Of Range IP
130 [Documentation] Configure out-of-range IP address.
131 [Tags] Configure_Out_Of_Range_IP
132 [Template] Add IP Address
133
134 # ip subnet_mask gateway valid_status_codes
135 ${out_of_range_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
136
137Configure Broadcast IP
138 [Documentation] Configure broadcast IP address.
139 [Tags] Configure_Broadcast_IP
140 [Template] Add IP Address
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500141 [Teardown] Clear IP Settings On Fail ${broadcast_ip}
Prashanth Kattib36a7522019-05-22 05:32:39 -0500142
143 # ip subnet_mask gateway valid_status_codes
144 ${broadcast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
145
146Configure Multicast IP
147 [Documentation] Configure multicast IP address.
148 [Tags] Configure_Multicast_IP
149 [Template] Add IP Address
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500150 [Teardown] Clear IP Settings On Fail ${multicast_ip}
Prashanth Kattib36a7522019-05-22 05:32:39 -0500151
152 # ip subnet_mask gateway valid_status_codes
153 ${multicast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
154
155Configure Loopback IP
156 [Documentation] Configure loopback IP address.
157 [Tags] Configure_Loopback_IP
158 [Template] Add IP Address
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500159 [Teardown] Clear IP Settings On Fail ${loopback_ip}
Prashanth Kattib36a7522019-05-22 05:32:39 -0500160
161 # ip subnet_mask gateway valid_status_codes
162 ${loopback_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
163
164Add Valid IPv4 Address And Check Persistency
165 [Documentation] Add IPv4 address and check peristency.
166 [Tags] Add_Valid_IPv4_Addres_And_Check_Persistency
167
168 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
169
170 # Reboot BMC and verify persistency.
171 OBMC Reboot (off)
172 Verify IP On BMC ${test_ipv4_addr}
173 Delete IP Address ${test_ipv4_addr}
Vijayde3bf7b2019-04-16 04:56:09 -0500174
Prashanth Katti6cedca22019-05-30 02:31:11 -0500175Add Fourth Octet Threshold IP And Verify
176 [Documentation] Add fourth octet threshold IP and verify.
177 [Tags] Add_Fourth_Octet_Threshold_IP_And_Verify
178
179 Add IP Address 10.7.7.254 ${test_subnet_mask} ${test_gateway}
180 Delete IP Address 10.7.7.254
181
182Add Fourth Octet Lowest IP And Verify
183 [Documentation] Add fourth octet lowest IP and verify.
184 [Tags] Add_Fourth_Octet_Lowest_IP_And_Verify
185
186 Add IP Address 10.7.7.1 ${test_subnet_mask} ${test_gateway}
187 Delete IP Address 10.7.7.1
188
189Add Third Octet Threshold IP And Verify
190 [Documentation] Add third octet threshold IP and verify.
191 [Tags] Add_Third_Octet_Threshold_IP_And_Verify
192
193 Add IP Address 10.7.255.7 ${test_subnet_mask} ${test_gateway}
194 Delete IP Address 10.7.255.7
195
196Add Third Octet Lowest IP And Verify
197 [Documentation] Add third octet lowest IP and verify.
198 [Tags] Add_Third_Octet_Lowest_IP_And_Verify
199
200 Add IP Address 10.7.0.7 ${test_subnet_mask} ${test_gateway}
201 Delete IP Address 10.7.0.7
202
203Add Second Octet Threshold IP And Verify
204 [Documentation] Add second octet threshold IP and verify.
205 [Tags] Add_Second_Octet_Threshold_IP_And_Verify
206
207 Add IP Address 10.255.7.7 ${test_subnet_mask} ${test_gateway}
208 Delete IP Address 10.255.7.7
209
210Add Second Octet Lowest IP And Verify
211 [Documentation] Add second octet lowest IP and verify.
212 [Tags] Add_Second_Octet_Lowest_IP_And_Verify
213
214 Add IP Address 10.0.7.7 ${test_subnet_mask} ${test_gateway}
215 Delete IP Address 10.0.7.7
216
217Add First Octet Threshold IP And Verify
218 [Documentation] Add first octet threshold IP and verify.
219 [Tags] Add_First_Octet_Threshold_IP_And_Verify
220
221 Add IP Address 223.7.7.7 ${test_subnet_mask} ${test_gateway}
222 Delete IP Address 223.7.7.7
223
224Add First Octet Lowest IP And Verify
225 [Documentation] Add first octet lowest IP and verify.
226 [Tags] Add_First_Octet_Lowest_IP_And_Verify
227
228 Add IP Address 1.7.7.7 ${test_subnet_mask} ${test_gateway}
229 Delete IP Address 1.7.7.7
230
Prashanth Katti040c8c12019-05-31 04:42:05 -0500231Configure Invalid Netmask
232 [Documentation] Verify error while setting invalid netmask.
233 [Tags] Configure_Invalid_Netmask
234 [Template] Add IP Address
235
236 # ip subnet_mask gateway valid_status_codes
237 ${test_ipv4_addr} ${invalid_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
238
239Configure Out Of Range Netmask
240 [Documentation] Verify error while setting out of range netmask.
241 [Tags] Configure_Out_Of_Range_Netmask
242 [Template] Add IP Address
243
244 # ip subnet_mask gateway valid_status_codes
245 ${test_ipv4_addr} ${out_of_range_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
246
247Configure Alpha Netmask
248 [Documentation] Verify error while setting alpha netmask.
249 [Tags] Configure_Alpha_Netmask
250 [Template] Add IP Address
251
252 # ip subnet_mask gateway valid_status_codes
253 ${test_ipv4_addr} ${alpha_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
254
255Configure More Byte Netmask
256 [Documentation] Verify error while setting more byte netmask.
257 [Tags] Configure_More_Byte_Netmask
258 [Template] Add IP Address
259
260 # ip subnet_mask gateway valid_status_codes
261 ${test_ipv4_addr} ${more_byte_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
262
263Configure Less Byte Netmask
264 [Documentation] Verify error while setting less byte netmask.
265 [Tags] Configure_Less_Byte_Netmask
266 [Template] Add IP Address
267
268 # ip subnet_mask gateway valid_status_codes
269 ${test_ipv4_addr} ${less_byte_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
270
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500271Configure Threshold Netmask And Verify
272 [Documentation] Configure threshold netmask and verify.
273 [Tags] Configure_Threshold_Netmask_And_verify
274
275 Add IP Address ${test_ipv4_addr} ${threshold_netmask} ${test_gateway}
276 Delete IP Address ${test_ipv4_addr}
277
278Configure Lowest Netmask And Verify
279 [Documentation] Configure lowest netmask and verify.
280 [Tags] Configure_Lowest_Netmask_And_verify
281
282 Add IP Address ${test_ipv4_addr} ${lowest_netmask} ${test_gateway}
283 Delete IP Address ${test_ipv4_addr}
284
285Configure Network ID
286 [Documentation] Verify error while configuring network ID.
287 [Tags] Configure_Network_ID
288 [Template] Add IP Address
289 [Teardown] Clear IP Settings On Fail ${network_id}
290
291 # ip subnet_mask gateway valid_status_codes
292 ${network_id} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
293
294Configure Less Octet IP
295 [Documentation] Verify error while Configuring less octet IP address.
296 [Tags] Configure_Less_Octet_IP
297 [Template] Add IP Address
298
299 # ip subnet_mask gateway valid_status_codes
300 ${less_octet_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
301
302Configure Empty IP
303 [Documentation] Verify error while Configuring empty IP address.
304 [Tags] Configure_Empty_IP
305 [Template] Add IP Address
306
307 # ip subnet_mask gateway valid_status_codes
308 ${EMPTY} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
309
310Configure Special Char IP
311 [Documentation] Configure invalid IP address containing special chars.
312 [Tags] Configure_Special_Char_IP
313 [Template] Add IP Address
314
315 # ip subnet_mask gateway valid_status_codes
316 @@@.%%.44.11 ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
317
318Configure Hexadecimal IP
319 [Documentation] Configure invalid IP address containing hex value.
320 [Tags] Configure_Hexadecimal_IP
321 [Template] Add IP Address
322
323 # ip subnet_mask gateway valid_status_codes
324 ${hex_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
325
326Configure Negative Octet IP
327 [Documentation] Configure invalid IP address containing negative octet.
328 [Tags] Configure_Negative_Octet_IP
329 [Template] Add IP Address
330
331 # ip subnet_mask gateway valid_status_codes
332 ${negative_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
333
Prashanth Katti5cad5a02019-06-20 07:27:10 -0500334Configure Incomplete IP For Gateway
335 [Documentation] Configure incomplete IP for gateway and expect an error.
336 [Tags] Configure_Incomplete_IP_For_Gateway
337 [Template] Add IP Address
338
339 # ip subnet_mask gateway valid_status_codes
340 ${test_ipv4_addr} ${test_subnet_mask} ${less_octet_ip} ${HTTP_BAD_REQUEST}
341
342Configure Special Char IP For Gateway
343 [Documentation] Configure special char IP for gateway and expect an error.
344 [Tags] Configure_Special_Char_IP_For_Gateway
345 [Template] Add IP Address
346
347 # ip subnet_mask gateway valid_status_codes
348 ${test_ipv4_addr} ${test_subnet_mask} @@@.%%.44.11 ${HTTP_BAD_REQUEST}
349
350Configure Hexadecimal IP For Gateway
351 [Documentation] Configure hexadecimal IP for gateway and expect an error.
352 [Tags] Configure_Hexadecimal_IP_For_Gateway
353 [Template] Add IP Address
354
355 # ip subnet_mask gateway valid_status_codes
356 ${test_ipv4_addr} ${test_subnet_mask} ${hex_ip} ${HTTP_BAD_REQUEST}
357
Prashanth Katti7098c972019-07-03 06:56:42 -0500358Get DNS Server And Verify
359 [Documentation] Get DNS server via Redfish and verify.
360 [Tags] Get_DNS_Server_And_Verify
361
362 Verify CLI and Redfish Nameservers
363
364Configure DNS Server And Verify
365 [Documentation] Configure DNS server and verify.
366 [Tags] Configure_DNS_Server_And_Verify
Prashanth Kattic85957c2019-07-09 02:01:20 -0500367 [Setup] DNS Test Setup Execution
Prashanth Katti7098c972019-07-03 06:56:42 -0500368 [Teardown] Run Keywords
369 ... Configure Static Name Servers AND Test Teardown Execution
370
Prashanth Katti7098c972019-07-03 06:56:42 -0500371 Configure Static Name Servers ${static_name_servers}
372 Verify CLI and Redfish Nameservers
373
Prashanth Kattic85957c2019-07-09 02:01:20 -0500374Delete DNS Server And Verify
375 [Documentation] Delete DNS server and verify.
376 [Tags] Delete_DNS_Server_And_Verify
377 [Setup] DNS Test Setup Execution
378 [Teardown] Run Keywords
379 ... Configure Static Name Servers AND Test Teardown Execution
380
381 Delete Static Name Servers
382 Verify CLI and Redfish Nameservers
383
384Configure DNS Server And Check Persistency
385 [Documentation] Configure DNS server and check persistency on reboot.
386 [Tags] Configure_DNS_Server_And_Check_Persistency
387 [Setup] DNS Test Setup Execution
388 [Teardown] Run Keywords
389 ... Configure Static Name Servers AND Test Teardown Execution
390
391 Configure Static Name Servers ${static_name_servers}
392 # Reboot BMC and verify persistency.
393 OBMC Reboot (off)
394 Verify CLI and Redfish Nameservers
395
Prashanth Katti3063ffe2019-07-25 04:35:25 -0500396Configure Loopback IP For Gateway
397 [Documentation] Configure loopback IP for gateway and expect an error.
398 [Tags] Configure_Loopback_IP_For_Gateway
399 [Template] Add IP Address
400 [Teardown] Clear IP Settings On Fail ${test_ipv4_addr}
401
402 # ip subnet_mask gateway valid_status_codes
403 ${test_ipv4_addr} ${test_subnet_mask} ${loopback_ip} ${HTTP_BAD_REQUEST}
404
405Configure Network ID For Gateway
406 [Documentation] Configure network ID for gateway and expect an error.
407 [Tags] Configure_Network_ID_For_Gateway
408 [Template] Add IP Address
409 [Teardown] Clear IP Settings On Fail ${test_ipv4_addr}
410
411 # ip subnet_mask gateway valid_status_codes
412 ${test_ipv4_addr} ${test_subnet_mask} ${network_id} ${HTTP_BAD_REQUEST}
413
414Configure Multicast IP For Gateway
415 [Documentation] Configure multicast IP for gateway and expect an error.
416 [Tags] Configure_Multicast_IP_For_Gateway
417 [Template] Add IP Address
418 [Teardown] Clear IP Settings On Fail ${test_ipv4_addr}
419
420 # ip subnet_mask gateway valid_status_codes
421 ${test_ipv4_addr} ${test_subnet_mask} ${multicaste_ip} ${HTTP_BAD_REQUEST}
422
423Configure Broadcast IP For Gateway
424 [Documentation] Configure broadcast IP for gateway and expect an error.
425 [Tags] Configure_Broadcast_IP_For_Gateway
426 [Template] Add IP Address
427 [Teardown] Clear IP Settings On Fail ${test_ipv4_addr}
428
429 # ip subnet_mask gateway valid_status_codes
430 ${test_ipv4_addr} ${test_subnet_mask} ${broadcast_ip} ${HTTP_BAD_REQUEST}
Prashanth Kattic85957c2019-07-09 02:01:20 -0500431
Prashanth Katti3c7b6432019-07-26 06:53:37 -0500432Configure Null Value For DNS Server
433 [Documentation] Configure null value for DNS server and expect an error.
434 [Tags] Configure_Null_Value_For_DNS_Server
435 [Setup] DNS Test Setup Execution
436 [Teardown] Run Keywords
437 ... Configure Static Name Servers AND Test Teardown Execution
438
439 Configure Static Name Servers ${null_value} ${HTTP_BAD_REQUEST}
440
Prashanth Kattiafe16b72019-08-02 00:29:45 -0500441Configure Empty Value For DNS Server
442 [Documentation] Configure empty value for DNS server and expect an error.
443 [Tags] Configure_Empty_Value_For_DNS_Server
444 [Setup] DNS Test Setup Execution
445 [Teardown] Run Keywords
446 ... Configure Static Name Servers AND Test Teardown Execution
447
448 Configure Static Name Servers ${empty_dictionary} ${HTTP_BAD_REQUEST}
449
450Configure String Value For DNS Server
451 [Documentation] Configure string value for DNS server and expect an error.
452 [Tags] Configure_String_Value_For_DNS_Server
453 [Setup] DNS Test Setup Execution
454 [Teardown] Run Keywords
455 ... Configure Static Name Servers AND Test Teardown Execution
456
457 Configure Static Name Servers ${string_value} ${HTTP_BAD_REQUEST}
458
Prashanth Kattif58cce02019-02-06 03:05:14 -0600459*** Keywords ***
460
461Test Setup Execution
462 [Documentation] Test setup execution.
463
George Keishing97c93942019-03-04 12:45:07 -0600464 Redfish.Login
Prashanth Kattif58cce02019-02-06 03:05:14 -0600465
466 @{network_configurations}= Get Network Configuration
467 Set Test Variable @{network_configurations}
468
469 # Get BMC IP address and prefix length.
470 ${ip_data}= Get BMC IP Info
471 Set Test Variable ${ip_data}
472
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600473
Prashanth Kattif58cce02019-02-06 03:05:14 -0600474Get Network Configuration
475 [Documentation] Get network configuration.
476
477 # Sample output:
478 #{
479 # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
480 # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
481 # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
482 # "Description": "Management Network Interface",
483 # "IPv4Addresses": [
484 # {
485 # "Address": "169.254.xx.xx",
486 # "AddressOrigin": "IPv4LinkLocal",
487 # "Gateway": "0.0.0.0",
488 # "SubnetMask": "255.255.0.0"
489 # },
490 # {
491 # "Address": "xx.xx.xx.xx",
492 # "AddressOrigin": "Static",
493 # "Gateway": "xx.xx.xx.1",
494 # "SubnetMask": "xx.xx.xx.xx"
495 # }
496 # ],
497 # "Id": "eth0",
498 # "MACAddress": "xx:xx:xx:xx:xx:xx",
499 # "Name": "Manager Ethernet Interface",
500 # "SpeedMbps": 0,
501 # "VLAN": {
502 # "VLANEnable": false,
503 # "VLANId": 0
504 # }
505
George Keishing97c93942019-03-04 12:45:07 -0600506 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Kattiff54bff2019-07-09 05:50:17 -0500507 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
Prashanth Kattif58cce02019-02-06 03:05:14 -0600508 [Return] @{network_configurations}
509
George Keishing5d467552019-02-08 23:30:48 -0600510
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600511Verify IP On BMC
512 [Documentation] Verify IP on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600513 [Arguments] ${ip}
514
Vijayde3bf7b2019-04-16 04:56:09 -0500515 # Description of argument(s):
516 # ip IP address to be verified (e.g. "10.7.7.7").
Prashanth Kattif58cce02019-02-06 03:05:14 -0600517
518 # Get IP address details on BMC using IP command.
519 @{ip_data}= Get BMC IP Info
520 Should Contain Match ${ip_data} ${ip}/*
521 ... msg=IP address does not exist.
522
Vijayde3bf7b2019-04-16 04:56:09 -0500523Add IP Address
524 [Documentation] Add IP Address To BMC.
525 [Arguments] ${ip} ${subnet_mask} ${gateway}
526 ... ${valid_status_codes}=${HTTP_OK}
527
528 # Description of argument(s):
529 # ip IP address to be added (e.g. "10.7.7.7").
530 # subnet_mask Subnet mask for the IP to be added
531 # (e.g. "255.255.0.0").
532 # gateway Gateway for the IP to be added (e.g. "10.7.7.1").
533 # valid_status_codes Expected return code from patch operation
534 # (e.g. "200"). See prolog of rest_request
535 # method in redfish_plut.py for details.
536
537 ${empty_dict}= Create Dictionary
538 ${ip_data}= Create Dictionary Address=${ip}
Prashanth Kattiff54bff2019-07-09 05:50:17 -0500539 ... SubnetMask=${subnet_mask} Gateway=${gateway}
Vijayde3bf7b2019-04-16 04:56:09 -0500540
541 ${patch_list}= Create List
542 ${network_configurations}= Get Network Configuration
543 ${num_entries}= Get Length ${network_configurations}
544
545 : FOR ${INDEX} IN RANGE 0 ${num_entries}
546 \ Append To List ${patch_list} ${empty_dict}
547
George Keishing98ffa862019-05-23 10:07:45 -0500548 # We need not check for existence of IP on BMC while adding.
Vijayde3bf7b2019-04-16 04:56:09 -0500549 Append To List ${patch_list} ${ip_data}
Prashanth Kattiff54bff2019-07-09 05:50:17 -0500550 ${data}= Create Dictionary IPv4StaticAddresses=${patch_list}
Vijayde3bf7b2019-04-16 04:56:09 -0500551
552 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
553 ... valid_status_codes=[${valid_status_codes}]
554
555 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK}'
556
557 # Note: Network restart takes around 15-18s after patch request processing.
558 Sleep ${NETWORK_TIMEOUT}s
559 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
560
561 Verify IP On BMC ${ip}
562 Validate Network Config On BMC
563
564
565Delete IP Address
566 [Documentation] Delete IP Address Of BMC.
567 [Arguments] ${ip} ${valid_status_codes}=${HTTP_OK}
568
569 # Description of argument(s):
570 # ip IP address to be deleted (e.g. "10.7.7.7").
571 # valid_status_codes Expected return code from patch operation
572 # (e.g. "200"). See prolog of rest_request
573 # method in redfish_plut.py for details.
574
575 ${empty_dict}= Create Dictionary
576 ${patch_list}= Create List
577
578 @{network_configurations}= Get Network Configuration
579 : FOR ${network_configuration} IN @{network_configurations}
580 \ Run Keyword If '${network_configuration['Address']}' == '${ip}'
581 ... Append To List ${patch_list} ${null}
582 ... ELSE Append To List ${patch_list} ${empty_dict}
583
584 ${ip_found}= Run Keyword And Return Status List Should Contain Value
585 ... ${patch_list} ${null} msg=${ip} does not exist on BMC
586 Pass Execution If ${ip_found} == ${False} ${ip} does not exist on BMC
587
588 # Run patch command only if given IP is found on BMC
Prashanth Kattiff54bff2019-07-09 05:50:17 -0500589 ${data}= Create Dictionary IPv4StaticAddresses=${patch_list}
Vijayde3bf7b2019-04-16 04:56:09 -0500590
591 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data}
592 ... valid_status_codes=[${valid_status_codes}]
593
594 # Note: Network restart takes around 15-18s after patch request processing
595 Sleep ${NETWORK_TIMEOUT}s
596 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
597
598 ${delete_status}= Run Keyword And Return Status Verify IP On BMC ${ip}
599 Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
600 ... Should Be True ${delete_status} == ${False}
601 ... ELSE Should Be True ${delete_status} == ${True}
602
603 Validate Network Config On BMC
604
605
606Validate Network Config On BMC
607 [Documentation] Check that network info obtained via redfish matches info
608 ... obtained via CLI.
609
610 @{network_configurations}= Get Network Configuration
611 ${ip_data}= Get BMC IP Info
612 : FOR ${network_configuration} IN @{network_configurations}
613 \ Should Contain Match ${ip_data} ${network_configuration['Address']}/*
614 ... msg=IP address does not exist.
615
George Keishing5d467552019-02-08 23:30:48 -0600616
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600617Verify Netmask On BMC
618 [Documentation] Verify netmask on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600619 [Arguments] ${netmask}
620
621 # Description of the argument(s):
622 # netmask netmask value to be verified.
623
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600624 ${prefix_length}= Netmask Prefix Length ${netmask}
625
626 Should Contain Match ${ip_data} */${prefix_length}
627 ... msg=Prefix length does not exist.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600628
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -0600629Verify Gateway On BMC
630 [Documentation] Verify gateway on BMC.
631 [Arguments] ${gateway_ip}=0.0.0.0
632
633 # Description of argument(s):
634 # gateway_ip Gateway IP address.
635
636 ${route_info}= Get BMC Route Info
637
638 # If gateway IP is empty or 0.0.0.0 it will not have route entry.
639
640 Run Keyword If '${gateway_ip}' == '0.0.0.0'
641 ... Pass Execution Gateway IP is "0.0.0.0".
642 ... ELSE
643 ... Should Contain ${route_info} ${gateway_ip}
644 ... msg=Gateway IP address not matching.
George Keishing5d467552019-02-08 23:30:48 -0600645
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -0600646Verify IP And Netmask On BMC
647 [Documentation] Verify IP and netmask on BMC.
648 [Arguments] ${ip} ${netmask}
649
650 # Description of the argument(s):
651 # ip IP address to be verified.
652 # netmask netmask value to be verified.
653
654 ${prefix_length}= Netmask Prefix Length ${netmask}
655 @{ip_data}= Get BMC IP Info
656
657 ${ip_with_netmask}= Catenate ${ip}/${prefix_length}
658 Should Contain ${ip_data} ${ip_with_netmask}
659 ... msg=IP and netmask pair does not exist.
660
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500661Validate Hostname On BMC
662 [Documentation] Verify that the hostname read via Redfish is the same as the
663 ... hostname configured on system.
664 [Arguments] ${hostname}
665
666 # Description of argument(s):
667 # hostname A hostname value which is to be compared to the hostname
668 # configured on system.
669
670 ${sys_hostname}= Get BMC Hostname
Prashanth Katti466d8342019-03-21 08:58:50 -0500671 Should Be Equal ${sys_hostname} ${hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500672 ... ignore_case=True msg=Hostname does not exist.
673
Prashanth Kattif58cce02019-02-06 03:05:14 -0600674Test Teardown Execution
675 [Documentation] Test teardown execution.
676
677 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600678 Redfish.Logout
Prashanth Kattia8442512019-06-07 06:47:09 -0500679
680Clear IP Settings On Fail
681 [Documentation] Clear IP settings on fail.
682 [Arguments] ${ip}
683
684 # Description of argument(s):
685 # ip IP address to be deleted.
686
687 Run Keyword If '${TEST STATUS}' == 'FAIL'
688 ... Delete IP Address ${ip}
689
690 Test Teardown Execution
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500691
Prashanth Katti7098c972019-07-03 06:56:42 -0500692Verify CLI and Redfish Nameservers
693 [Documentation] Verify that nameservers obtained via Redfish do not
694 ... match those found in /etc/resolv.conf.
695
696 ${redfish_nameservers}= Redfish.Get Attribute ${REDFISH_NW_ETH0_URI} StaticNameServers
697 ${resolve_conf_nameservers}= CLI Get Nameservers
Michael Walsh39c00512019-07-17 10:54:06 -0500698 Rqprint Vars redfish_nameservers resolve_conf_nameservers
Prashanth Katti7098c972019-07-03 06:56:42 -0500699
700 # Check that the 2 lists are equivalent.
701 ${match}= Evaluate set($redfish_nameservers) == set($resolve_conf_nameservers)
702 Should Be True ${match}
703 ... The nameservers obtained via Redfish do not match those found in /etc/resolv.conf.
704
705CLI Get Nameservers
706 [Documentation] Get the nameserver IPs from /etc/resolv.conf and return as a list.
707
708 # Example of /etc/resolv.conf data:
709 # nameserver x.x.x.x
710 # nameserver y.y.y.y
711
712 ${stdout} ${stderr} ${rc}= BMC Execute Command egrep nameserver /etc/resolv.conf | cut -f2- -d ' '
713 ${nameservers}= Split String ${stdout}
714
715 [Return] ${nameservers}
716
717
718Configure Static Name Servers
719 [Documentation] Configure DNS server on BMC.
Prashanth Kattic85957c2019-07-09 02:01:20 -0500720 [Arguments] ${static_name_servers}=${original_nameservers}
Prashanth Katti3c7b6432019-07-26 06:53:37 -0500721 ... ${valid_status_codes}=${HTTP_OK}
Prashanth Katti7098c972019-07-03 06:56:42 -0500722
George Keishing9cb2e592019-07-12 09:37:33 -0500723 # Description of the argument(s):
Prashanth Katti7098c972019-07-03 06:56:42 -0500724 # static_name_servers A list of static name server IPs to be
725 # configured on the BMC.
726
727 Redfish.Patch ${REDFISH_NW_ETH0_URI} body={'StaticNameServers': ${static_name_servers}}
Prashanth Katti3c7b6432019-07-26 06:53:37 -0500728 ... valid_status_codes=[${valid_status_codes}]
Prashanth Kattic85957c2019-07-09 02:01:20 -0500729
Prashanth Katti7f9e60f2019-07-26 01:18:41 -0500730 # Check if newly added DNS server is configured on BMC.
731 ${cli_nameservers}= CLI Get Nameservers
Prashanth Katti3c7b6432019-07-26 06:53:37 -0500732 ${cmd_status}= Run Keyword And Return Status
733 ... List Should Contain Sub List ${cli_nameservers} ${static_name_servers}
734
735 Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
736 ... Should Be True ${cmd_status} == ${True}
737 ... ELSE Should Be True ${cmd_status} == ${False}
Prashanth Katti7f9e60f2019-07-26 01:18:41 -0500738
Prashanth Kattic85957c2019-07-09 02:01:20 -0500739Delete Static Name Servers
740 [Documentation] Delete static name servers.
741
742 Configure Static Name Servers @{EMPTY}
743
744 # Check if all name servers deleted on BMC.
745 ${nameservers}= CLI Get Nameservers
746 Should Be Empty ${nameservers}
747
748DNS Test Setup Execution
749 [Documentation] Do DNS test setup execution.
750
751 Redfish.Login
752
753 ${original_nameservers}= Redfish.Get Attribute ${REDFISH_NW_ETH0_URI} StaticNameServers
754 Rprint Vars original_nameservers
755 # Set suite variables to trigger restoration during teardown.
756 Set Suite Variable ${original_nameservers}