blob: 3d8225949f76cf8a59560f49ee4292e500298710 [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
Prashanth Kattib478d902020-05-08 10:05:32 -050013Suite Setup Suite Setup Execution
Prashanth Kattif58cce02019-02-06 03:05:14 -060014
Prashanth Kattif34fafa2019-06-20 05:04:40 -050015Force Tags Network_Conf_Test
16
Prashanth Katti23efc6e2019-03-13 06:07:15 -050017*** Variables ***
Vijayde3bf7b2019-04-16 04:56:09 -050018${test_hostname} openbmc
19${test_ipv4_addr} 10.7.7.7
20${test_ipv4_invalid_addr} 0.0.1.a
21${test_subnet_mask} 255.255.0.0
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 Katti568df5f2020-05-15 06:00:37 -050026${test_ipv4_addr2} 10.7.7.8
Prashanth Katti23efc6e2019-03-13 06:07:15 -050027
Prashanth Katti040c8c12019-05-31 04:42:05 -050028# Valid netmask is 4 bytes long and has continuos block of 1s.
29# Maximum valid value in each octet is 255 and least value is 0.
30# 253 is not valid, as binary value is 11111101.
31${invalid_netmask} 255.255.253.0
32${alpha_netmask} ff.ff.ff.ff
33# Maximum value of octet in netmask is 255.
34${out_of_range_netmask} 255.256.255.0
35${more_byte_netmask} 255.255.255.0.0
36${less_byte_netmask} 255.255.255
Prashanth Kattic6ad6472019-06-14 03:33:39 -050037${threshold_netmask} 255.255.255.255
38${lowest_netmask} 128.0.0.0
39
40# There will be 4 octets in IP address (e.g. xx.xx.xx.xx)
41# but trying to configure xx.xx.xx
42${less_octet_ip} 10.3.36
43
44# For the address 10.6.6.6, the 10.6.6.0 portion describes the
45# network ID and the 6 describe the host.
46
47${network_id} 10.7.7.0
48${hex_ip} 0xa.0xb.0xc.0xd
49${negative_ip} 10.-7.-7.7
50${hex_ip} 0xa.0xb.0xc.0xd
Prashanth Katti7098c972019-07-03 06:56:42 -050051@{static_name_servers} 10.5.5.5
Prashanth Katti3c7b6432019-07-26 06:53:37 -050052@{null_value} null
Prashanth Kattiafe16b72019-08-02 00:29:45 -050053@{empty_dictionary} {}
54@{string_value} aa.bb.cc.dd
55
Prashanth Kattif58cce02019-02-06 03:05:14 -060056*** Test Cases ***
57
58Get IP Address And Verify
59 [Documentation] Get IP Address And Verify.
George Keishing5d467552019-02-08 23:30:48 -060060 [Tags] Get_IP_Address_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060061
62 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060063 \ Verify IP On BMC ${network_configuration['Address']}
64
Prashanth Kattif58cce02019-02-06 03:05:14 -060065Get Netmask And Verify
66 [Documentation] Get Netmask And Verify.
George Keishing5d467552019-02-08 23:30:48 -060067 [Tags] Get_Netmask_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060068
69 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060070 \ Verify Netmask On BMC ${network_configuration['SubnetMask']}
71
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060072Get Gateway And Verify
73 [Documentation] Get gateway and verify it's existence on the BMC.
74 [Tags] Get_Gateway_And_Verify
75
76 : FOR ${network_configuration} IN @{network_configurations}
77 \ Verify Gateway On BMC ${network_configuration['Gateway']}
78
79Get MAC Address And Verify
80 [Documentation] Get MAC address and verify it's existence on the BMC.
81 [Tags] Get_MAC_Address_And_Verify
82
Tony Lee412c6682020-04-01 17:34:30 +080083 ${active_channel_config}= Get Active Channel Config
84 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
85
86 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060087 ${macaddr}= Get From Dictionary ${resp.dict} MACAddress
88 Validate MAC On BMC ${macaddr}
Prashanth Kattif58cce02019-02-06 03:05:14 -060089
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -060090Verify All Configured IP And Netmask
91 [Documentation] Verify all configured IP and netmask on BMC.
92 [Tags] Verify_All_Configured_IP_And_Netmask
93
94 : FOR ${network_configuration} IN @{network_configurations}
95 \ Verify IP And Netmask On BMC ${network_configuration['Address']}
96 ... ${network_configuration['SubnetMask']}
97
Prashanth Katti23efc6e2019-03-13 06:07:15 -050098Get Hostname And Verify
99 [Documentation] Get hostname via Redfish and verify.
100 [Tags] Get_Hostname_And_Verify
101
102 ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
103
104 Validate Hostname On BMC ${hostname}
105
106Configure Hostname And Verify
107 [Documentation] Configure hostname via Redfish and verify.
108 [Tags] Configure_Hostname_And_Verify
109
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500110 ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500111
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500112 Configure Hostname ${test_hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500113 Validate Hostname On BMC ${test_hostname}
114
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500115 # Revert back to initial hostname.
116 Configure Hostname ${hostname}
117 Validate Hostname On BMC ${hostname}
118
Vijayde3bf7b2019-04-16 04:56:09 -0500119Add Valid IPv4 Address And Verify
120 [Documentation] Add IPv4 Address via Redfish and verify.
121 [Tags] Add_Valid_IPv4_Addres_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500122 [Teardown] Run Keywords
123 ... Delete IP Address ${test_ipv4_addr} AND Test Teardown Execution
Vijayde3bf7b2019-04-16 04:56:09 -0500124
125 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
Vijayde3bf7b2019-04-16 04:56:09 -0500126
127Add Invalid IPv4 Address And Verify
128 [Documentation] Add Invalid IPv4 Address via Redfish and verify.
129 [Tags] Add_Invalid_IPv4_Addres_And_Verify
130
131 Add IP Address ${test_ipv4_invalid_addr} ${test_subnet_mask}
132 ... ${test_gateway} valid_status_codes=${HTTP_BAD_REQUEST}
133
Prashanth Kattib36a7522019-05-22 05:32:39 -0500134Configure Out Of Range IP
135 [Documentation] Configure out-of-range IP address.
136 [Tags] Configure_Out_Of_Range_IP
137 [Template] Add IP Address
138
139 # ip subnet_mask gateway valid_status_codes
140 ${out_of_range_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
141
142Configure Broadcast IP
143 [Documentation] Configure broadcast IP address.
144 [Tags] Configure_Broadcast_IP
145 [Template] Add IP Address
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500146 [Teardown] Clear IP Settings On Fail ${broadcast_ip}
Prashanth Kattib36a7522019-05-22 05:32:39 -0500147
148 # ip subnet_mask gateway valid_status_codes
149 ${broadcast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
150
151Configure Multicast IP
152 [Documentation] Configure multicast IP address.
153 [Tags] Configure_Multicast_IP
154 [Template] Add IP Address
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500155 [Teardown] Clear IP Settings On Fail ${multicast_ip}
Prashanth Kattib36a7522019-05-22 05:32:39 -0500156
157 # ip subnet_mask gateway valid_status_codes
158 ${multicast_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
159
160Configure Loopback IP
161 [Documentation] Configure loopback IP address.
162 [Tags] Configure_Loopback_IP
163 [Template] Add IP Address
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500164 [Teardown] Clear IP Settings On Fail ${loopback_ip}
Prashanth Kattib36a7522019-05-22 05:32:39 -0500165
166 # ip subnet_mask gateway valid_status_codes
167 ${loopback_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
168
169Add Valid IPv4 Address And Check Persistency
170 [Documentation] Add IPv4 address and check peristency.
171 [Tags] Add_Valid_IPv4_Addres_And_Check_Persistency
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500172 [Teardown] Run Keywords
173 ... Delete IP Address ${test_ipv4_addr} AND Test Teardown Execution
Prashanth Kattib36a7522019-05-22 05:32:39 -0500174
175 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
176
177 # Reboot BMC and verify persistency.
178 OBMC Reboot (off)
George Keishing5c498742019-08-09 02:14:44 -0500179 Redfish.Login
Prashanth Kattib36a7522019-05-22 05:32:39 -0500180 Verify IP On BMC ${test_ipv4_addr}
Vijayde3bf7b2019-04-16 04:56:09 -0500181
Prashanth Katti6cedca22019-05-30 02:31:11 -0500182Add Fourth Octet Threshold IP And Verify
183 [Documentation] Add fourth octet threshold IP and verify.
184 [Tags] Add_Fourth_Octet_Threshold_IP_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500185 [Teardown] Run Keywords
186 ... Delete IP Address 10.7.7.254 AND Test Teardown Execution
Prashanth Katti6cedca22019-05-30 02:31:11 -0500187
188 Add IP Address 10.7.7.254 ${test_subnet_mask} ${test_gateway}
Prashanth Katti6cedca22019-05-30 02:31:11 -0500189
190Add Fourth Octet Lowest IP And Verify
191 [Documentation] Add fourth octet lowest IP and verify.
192 [Tags] Add_Fourth_Octet_Lowest_IP_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500193 [Teardown] Run Keywords
194 ... Delete IP Address 10.7.7.1 AND Test Teardown Execution
Prashanth Katti6cedca22019-05-30 02:31:11 -0500195
196 Add IP Address 10.7.7.1 ${test_subnet_mask} ${test_gateway}
Prashanth Katti6cedca22019-05-30 02:31:11 -0500197
198Add Third Octet Threshold IP And Verify
199 [Documentation] Add third octet threshold IP and verify.
200 [Tags] Add_Third_Octet_Threshold_IP_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500201 [Teardown] Run Keywords
202 ... Delete IP Address 10.7.255.7 AND Test Teardown Execution
Prashanth Katti6cedca22019-05-30 02:31:11 -0500203
204 Add IP Address 10.7.255.7 ${test_subnet_mask} ${test_gateway}
Prashanth Katti6cedca22019-05-30 02:31:11 -0500205
206Add Third Octet Lowest IP And Verify
207 [Documentation] Add third octet lowest IP and verify.
208 [Tags] Add_Third_Octet_Lowest_IP_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500209 [Teardown] Run Keywords
210 ... Delete IP Address 10.7.0.7 AND Test Teardown Execution
Prashanth Katti6cedca22019-05-30 02:31:11 -0500211
212 Add IP Address 10.7.0.7 ${test_subnet_mask} ${test_gateway}
Prashanth Katti6cedca22019-05-30 02:31:11 -0500213
214Add Second Octet Threshold IP And Verify
215 [Documentation] Add second octet threshold IP and verify.
216 [Tags] Add_Second_Octet_Threshold_IP_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500217 [Teardown] Run Keywords
218 ... Delete IP Address 10.255.7.7 AND Test Teardown Execution
Prashanth Katti6cedca22019-05-30 02:31:11 -0500219
220 Add IP Address 10.255.7.7 ${test_subnet_mask} ${test_gateway}
Prashanth Katti6cedca22019-05-30 02:31:11 -0500221
222Add Second Octet Lowest IP And Verify
223 [Documentation] Add second octet lowest IP and verify.
224 [Tags] Add_Second_Octet_Lowest_IP_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500225 [Teardown] Run Keywords
226 ... Delete IP Address 10.0.7.7 AND Test Teardown Execution
Prashanth Katti6cedca22019-05-30 02:31:11 -0500227
228 Add IP Address 10.0.7.7 ${test_subnet_mask} ${test_gateway}
Prashanth Katti6cedca22019-05-30 02:31:11 -0500229
230Add First Octet Threshold IP And Verify
231 [Documentation] Add first octet threshold IP and verify.
232 [Tags] Add_First_Octet_Threshold_IP_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500233 [Teardown] Run Keywords
234 ... Delete IP Address 233.7.7.7 AND Test Teardown Execution
Prashanth Katti6cedca22019-05-30 02:31:11 -0500235
236 Add IP Address 223.7.7.7 ${test_subnet_mask} ${test_gateway}
Prashanth Katti6cedca22019-05-30 02:31:11 -0500237
238Add First Octet Lowest IP And Verify
239 [Documentation] Add first octet lowest IP and verify.
240 [Tags] Add_First_Octet_Lowest_IP_And_Verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500241 [Teardown] Run Keywords
242 ... Delete IP Address 1.7.7.7 AND Test Teardown Execution
Prashanth Katti6cedca22019-05-30 02:31:11 -0500243
244 Add IP Address 1.7.7.7 ${test_subnet_mask} ${test_gateway}
Prashanth Katti6cedca22019-05-30 02:31:11 -0500245
Prashanth Katti040c8c12019-05-31 04:42:05 -0500246Configure Invalid Netmask
247 [Documentation] Verify error while setting invalid netmask.
248 [Tags] Configure_Invalid_Netmask
249 [Template] Add IP Address
250
251 # ip subnet_mask gateway valid_status_codes
252 ${test_ipv4_addr} ${invalid_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
253
254Configure Out Of Range Netmask
255 [Documentation] Verify error while setting out of range netmask.
256 [Tags] Configure_Out_Of_Range_Netmask
257 [Template] Add IP Address
258
259 # ip subnet_mask gateway valid_status_codes
260 ${test_ipv4_addr} ${out_of_range_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
261
262Configure Alpha Netmask
263 [Documentation] Verify error while setting alpha netmask.
264 [Tags] Configure_Alpha_Netmask
265 [Template] Add IP Address
266
267 # ip subnet_mask gateway valid_status_codes
268 ${test_ipv4_addr} ${alpha_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
269
270Configure More Byte Netmask
271 [Documentation] Verify error while setting more byte netmask.
272 [Tags] Configure_More_Byte_Netmask
273 [Template] Add IP Address
274
275 # ip subnet_mask gateway valid_status_codes
276 ${test_ipv4_addr} ${more_byte_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
277
278Configure Less Byte Netmask
279 [Documentation] Verify error while setting less byte netmask.
280 [Tags] Configure_Less_Byte_Netmask
281 [Template] Add IP Address
282
283 # ip subnet_mask gateway valid_status_codes
284 ${test_ipv4_addr} ${less_byte_netmask} ${test_gateway} ${HTTP_BAD_REQUEST}
285
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500286Configure Threshold Netmask And Verify
287 [Documentation] Configure threshold netmask and verify.
288 [Tags] Configure_Threshold_Netmask_And_verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500289 [Teardown] Run Keywords
290 ... Delete IP Address ${test_ipv4_addr} AND Test Teardown Execution
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500291
292 Add IP Address ${test_ipv4_addr} ${threshold_netmask} ${test_gateway}
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500293
294Configure Lowest Netmask And Verify
295 [Documentation] Configure lowest netmask and verify.
296 [Tags] Configure_Lowest_Netmask_And_verify
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500297 [Teardown] Run Keywords
298 ... Delete IP Address ${test_ipv4_addr} AND Test Teardown Execution
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500299
300 Add IP Address ${test_ipv4_addr} ${lowest_netmask} ${test_gateway}
Prashanth Kattic6ad6472019-06-14 03:33:39 -0500301
302Configure Network ID
303 [Documentation] Verify error while configuring network ID.
304 [Tags] Configure_Network_ID
305 [Template] Add IP Address
306 [Teardown] Clear IP Settings On Fail ${network_id}
307
308 # ip subnet_mask gateway valid_status_codes
309 ${network_id} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
310
311Configure Less Octet IP
312 [Documentation] Verify error while Configuring less octet IP address.
313 [Tags] Configure_Less_Octet_IP
314 [Template] Add IP Address
315
316 # ip subnet_mask gateway valid_status_codes
317 ${less_octet_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
318
319Configure Empty IP
320 [Documentation] Verify error while Configuring empty IP address.
321 [Tags] Configure_Empty_IP
322 [Template] Add IP Address
323
324 # ip subnet_mask gateway valid_status_codes
325 ${EMPTY} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
326
327Configure Special Char IP
328 [Documentation] Configure invalid IP address containing special chars.
329 [Tags] Configure_Special_Char_IP
330 [Template] Add IP Address
331
332 # ip subnet_mask gateway valid_status_codes
333 @@@.%%.44.11 ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
334
335Configure Hexadecimal IP
336 [Documentation] Configure invalid IP address containing hex value.
337 [Tags] Configure_Hexadecimal_IP
338 [Template] Add IP Address
339
340 # ip subnet_mask gateway valid_status_codes
341 ${hex_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
342
343Configure Negative Octet IP
344 [Documentation] Configure invalid IP address containing negative octet.
345 [Tags] Configure_Negative_Octet_IP
346 [Template] Add IP Address
347
348 # ip subnet_mask gateway valid_status_codes
349 ${negative_ip} ${test_subnet_mask} ${test_gateway} ${HTTP_BAD_REQUEST}
350
Prashanth Katti5cad5a02019-06-20 07:27:10 -0500351Configure Incomplete IP For Gateway
352 [Documentation] Configure incomplete IP for gateway and expect an error.
353 [Tags] Configure_Incomplete_IP_For_Gateway
354 [Template] Add IP Address
355
356 # ip subnet_mask gateway valid_status_codes
357 ${test_ipv4_addr} ${test_subnet_mask} ${less_octet_ip} ${HTTP_BAD_REQUEST}
358
359Configure Special Char IP For Gateway
360 [Documentation] Configure special char IP for gateway and expect an error.
361 [Tags] Configure_Special_Char_IP_For_Gateway
362 [Template] Add IP Address
363
364 # ip subnet_mask gateway valid_status_codes
365 ${test_ipv4_addr} ${test_subnet_mask} @@@.%%.44.11 ${HTTP_BAD_REQUEST}
366
367Configure Hexadecimal IP For Gateway
368 [Documentation] Configure hexadecimal IP for gateway and expect an error.
369 [Tags] Configure_Hexadecimal_IP_For_Gateway
370 [Template] Add IP Address
371
372 # ip subnet_mask gateway valid_status_codes
373 ${test_ipv4_addr} ${test_subnet_mask} ${hex_ip} ${HTTP_BAD_REQUEST}
374
Prashanth Katti7098c972019-07-03 06:56:42 -0500375Get DNS Server And Verify
376 [Documentation] Get DNS server via Redfish and verify.
377 [Tags] Get_DNS_Server_And_Verify
378
379 Verify CLI and Redfish Nameservers
380
381Configure DNS Server And Verify
382 [Documentation] Configure DNS server and verify.
383 [Tags] Configure_DNS_Server_And_Verify
Prashanth Kattic85957c2019-07-09 02:01:20 -0500384 [Setup] DNS Test Setup Execution
Prashanth Katti7098c972019-07-03 06:56:42 -0500385 [Teardown] Run Keywords
386 ... Configure Static Name Servers AND Test Teardown Execution
387
Prashanth Katti7098c972019-07-03 06:56:42 -0500388 Configure Static Name Servers ${static_name_servers}
389 Verify CLI and Redfish Nameservers
390
Prashanth Kattic85957c2019-07-09 02:01:20 -0500391Delete DNS Server And Verify
392 [Documentation] Delete DNS server and verify.
393 [Tags] Delete_DNS_Server_And_Verify
394 [Setup] DNS Test Setup Execution
395 [Teardown] Run Keywords
396 ... Configure Static Name Servers AND Test Teardown Execution
397
398 Delete Static Name Servers
399 Verify CLI and Redfish Nameservers
400
401Configure DNS Server And Check Persistency
402 [Documentation] Configure DNS server and check persistency on reboot.
403 [Tags] Configure_DNS_Server_And_Check_Persistency
404 [Setup] DNS Test Setup Execution
405 [Teardown] Run Keywords
406 ... Configure Static Name Servers AND Test Teardown Execution
407
408 Configure Static Name Servers ${static_name_servers}
409 # Reboot BMC and verify persistency.
410 OBMC Reboot (off)
411 Verify CLI and Redfish Nameservers
412
Prashanth Katti3063ffe2019-07-25 04:35:25 -0500413Configure Loopback IP For Gateway
414 [Documentation] Configure loopback IP for gateway and expect an error.
415 [Tags] Configure_Loopback_IP_For_Gateway
416 [Template] Add IP Address
417 [Teardown] Clear IP Settings On Fail ${test_ipv4_addr}
418
419 # ip subnet_mask gateway valid_status_codes
420 ${test_ipv4_addr} ${test_subnet_mask} ${loopback_ip} ${HTTP_BAD_REQUEST}
421
422Configure Network ID For Gateway
423 [Documentation] Configure network ID for gateway and expect an error.
424 [Tags] Configure_Network_ID_For_Gateway
425 [Template] Add IP Address
426 [Teardown] Clear IP Settings On Fail ${test_ipv4_addr}
427
428 # ip subnet_mask gateway valid_status_codes
429 ${test_ipv4_addr} ${test_subnet_mask} ${network_id} ${HTTP_BAD_REQUEST}
430
431Configure Multicast IP For Gateway
432 [Documentation] Configure multicast IP for gateway and expect an error.
433 [Tags] Configure_Multicast_IP_For_Gateway
434 [Template] Add IP Address
435 [Teardown] Clear IP Settings On Fail ${test_ipv4_addr}
436
437 # ip subnet_mask gateway valid_status_codes
Tony Lee412c6682020-04-01 17:34:30 +0800438 ${test_ipv4_addr} ${test_subnet_mask} ${multicast_ip} ${HTTP_BAD_REQUEST}
Prashanth Katti3063ffe2019-07-25 04:35:25 -0500439
440Configure Broadcast IP For Gateway
441 [Documentation] Configure broadcast IP for gateway and expect an error.
442 [Tags] Configure_Broadcast_IP_For_Gateway
443 [Template] Add IP Address
444 [Teardown] Clear IP Settings On Fail ${test_ipv4_addr}
445
446 # ip subnet_mask gateway valid_status_codes
447 ${test_ipv4_addr} ${test_subnet_mask} ${broadcast_ip} ${HTTP_BAD_REQUEST}
Prashanth Kattic85957c2019-07-09 02:01:20 -0500448
Prashanth Katti3c7b6432019-07-26 06:53:37 -0500449Configure Null Value For DNS Server
450 [Documentation] Configure null value for DNS server and expect an error.
451 [Tags] Configure_Null_Value_For_DNS_Server
452 [Setup] DNS Test Setup Execution
453 [Teardown] Run Keywords
454 ... Configure Static Name Servers AND Test Teardown Execution
455
456 Configure Static Name Servers ${null_value} ${HTTP_BAD_REQUEST}
457
Prashanth Kattiafe16b72019-08-02 00:29:45 -0500458Configure Empty Value For DNS Server
459 [Documentation] Configure empty value for DNS server and expect an error.
460 [Tags] Configure_Empty_Value_For_DNS_Server
461 [Setup] DNS Test Setup Execution
462 [Teardown] Run Keywords
463 ... Configure Static Name Servers AND Test Teardown Execution
464
465 Configure Static Name Servers ${empty_dictionary} ${HTTP_BAD_REQUEST}
466
467Configure String Value For DNS Server
468 [Documentation] Configure string value for DNS server and expect an error.
469 [Tags] Configure_String_Value_For_DNS_Server
470 [Setup] DNS Test Setup Execution
471 [Teardown] Run Keywords
472 ... Configure Static Name Servers AND Test Teardown Execution
473
474 Configure Static Name Servers ${string_value} ${HTTP_BAD_REQUEST}
475
Prashanth Katti568df5f2020-05-15 06:00:37 -0500476Modify IPv4 Address And Verify
477 [Documentation] Modify IP address via Redfish and verify.
478 [Tags] Modify_IPv4_Addres_And_Verify
479 [Teardown] Run Keywords
480 ... Delete IP Address ${test_ipv4_addr2} AND Delete IP Address ${test_ipv4_addr}
481 ... AND Test Teardown Execution
482
483 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
484
485 Update IP Address ${test_ipv4_addr} ${test_ipv4_addr2} ${test_subnet_mask} ${test_gateway}
486
Anvesh Kumar9c7238d2020-04-21 03:56:21 -0500487
Prashanth Kattif58cce02019-02-06 03:05:14 -0600488*** Keywords ***
489
490Test Setup Execution
491 [Documentation] Test setup execution.
492
George Keishing97c93942019-03-04 12:45:07 -0600493 Redfish.Login
Prashanth Kattif58cce02019-02-06 03:05:14 -0600494
495 @{network_configurations}= Get Network Configuration
496 Set Test Variable @{network_configurations}
497
498 # Get BMC IP address and prefix length.
499 ${ip_data}= Get BMC IP Info
500 Set Test Variable ${ip_data}
501
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600502
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600503Verify Netmask On BMC
504 [Documentation] Verify netmask on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600505 [Arguments] ${netmask}
506
507 # Description of the argument(s):
508 # netmask netmask value to be verified.
509
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600510 ${prefix_length}= Netmask Prefix Length ${netmask}
511
512 Should Contain Match ${ip_data} */${prefix_length}
513 ... msg=Prefix length does not exist.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600514
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -0600515Verify IP And Netmask On BMC
516 [Documentation] Verify IP and netmask on BMC.
517 [Arguments] ${ip} ${netmask}
518
519 # Description of the argument(s):
520 # ip IP address to be verified.
521 # netmask netmask value to be verified.
522
523 ${prefix_length}= Netmask Prefix Length ${netmask}
524 @{ip_data}= Get BMC IP Info
525
526 ${ip_with_netmask}= Catenate ${ip}/${prefix_length}
527 Should Contain ${ip_data} ${ip_with_netmask}
528 ... msg=IP and netmask pair does not exist.
529
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500530Validate Hostname On BMC
531 [Documentation] Verify that the hostname read via Redfish is the same as the
532 ... hostname configured on system.
533 [Arguments] ${hostname}
534
535 # Description of argument(s):
536 # hostname A hostname value which is to be compared to the hostname
537 # configured on system.
538
539 ${sys_hostname}= Get BMC Hostname
Prashanth Katti466d8342019-03-21 08:58:50 -0500540 Should Be Equal ${sys_hostname} ${hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500541 ... ignore_case=True msg=Hostname does not exist.
542
Prashanth Kattif58cce02019-02-06 03:05:14 -0600543Test Teardown Execution
544 [Documentation] Test teardown execution.
545
546 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600547 Redfish.Logout
Prashanth Kattia8442512019-06-07 06:47:09 -0500548
549Clear IP Settings On Fail
550 [Documentation] Clear IP settings on fail.
551 [Arguments] ${ip}
552
553 # Description of argument(s):
554 # ip IP address to be deleted.
555
556 Run Keyword If '${TEST STATUS}' == 'FAIL'
557 ... Delete IP Address ${ip}
558
559 Test Teardown Execution
Prashanth Kattiadf0b4e2019-06-10 04:20:30 -0500560
Prashanth Katti7098c972019-07-03 06:56:42 -0500561Verify CLI and Redfish Nameservers
562 [Documentation] Verify that nameservers obtained via Redfish do not
563 ... match those found in /etc/resolv.conf.
564
Tony Lee412c6682020-04-01 17:34:30 +0800565 ${active_channel_config}= Get Active Channel Config
566 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
567
568 ${redfish_nameservers}= Redfish.Get Attribute ${REDFISH_NW_ETH_IFACE}${ethernet_interface} StaticNameServers
Prashanth Katti7098c972019-07-03 06:56:42 -0500569 ${resolve_conf_nameservers}= CLI Get Nameservers
Michael Walsh39c00512019-07-17 10:54:06 -0500570 Rqprint Vars redfish_nameservers resolve_conf_nameservers
Prashanth Katti7098c972019-07-03 06:56:42 -0500571
572 # Check that the 2 lists are equivalent.
573 ${match}= Evaluate set($redfish_nameservers) == set($resolve_conf_nameservers)
574 Should Be True ${match}
575 ... The nameservers obtained via Redfish do not match those found in /etc/resolv.conf.
576
Prashanth Katti7098c972019-07-03 06:56:42 -0500577
578Configure Static Name Servers
579 [Documentation] Configure DNS server on BMC.
Prashanth Kattic85957c2019-07-09 02:01:20 -0500580 [Arguments] ${static_name_servers}=${original_nameservers}
Prashanth Katti3c7b6432019-07-26 06:53:37 -0500581 ... ${valid_status_codes}=${HTTP_OK}
Prashanth Katti7098c972019-07-03 06:56:42 -0500582
George Keishing9cb2e592019-07-12 09:37:33 -0500583 # Description of the argument(s):
Prashanth Katti7098c972019-07-03 06:56:42 -0500584 # static_name_servers A list of static name server IPs to be
585 # configured on the BMC.
586
Tony Lee412c6682020-04-01 17:34:30 +0800587 ${active_channel_config}= Get Active Channel Config
588 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
589
Prashanth Katti9d995fc2019-09-24 01:29:06 -0500590 # Currently BMC is sending 500 response code instead of 400 for invalid scenarios.
Tony Lee412c6682020-04-01 17:34:30 +0800591 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body={'StaticNameServers': ${static_name_servers}}
Prashanth Katti9d995fc2019-09-24 01:29:06 -0500592 ... valid_status_codes=[${valid_status_codes}, ${HTTP_INTERNAL_SERVER_ERROR}]
Prashanth Kattic85957c2019-07-09 02:01:20 -0500593
Prashanth Kattif247be32019-10-07 04:40:43 -0500594 # Patch operation takes 1 to 3 seconds to set new value.
595 Sleep 3s
596
Prashanth Katti7f9e60f2019-07-26 01:18:41 -0500597 # Check if newly added DNS server is configured on BMC.
598 ${cli_nameservers}= CLI Get Nameservers
Prashanth Katti3c7b6432019-07-26 06:53:37 -0500599 ${cmd_status}= Run Keyword And Return Status
600 ... List Should Contain Sub List ${cli_nameservers} ${static_name_servers}
601
602 Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
603 ... Should Be True ${cmd_status} == ${True}
604 ... ELSE Should Be True ${cmd_status} == ${False}
Prashanth Katti7f9e60f2019-07-26 01:18:41 -0500605
Prashanth Kattic85957c2019-07-09 02:01:20 -0500606Delete Static Name Servers
607 [Documentation] Delete static name servers.
608
609 Configure Static Name Servers @{EMPTY}
610
611 # Check if all name servers deleted on BMC.
612 ${nameservers}= CLI Get Nameservers
613 Should Be Empty ${nameservers}
614
615DNS Test Setup Execution
616 [Documentation] Do DNS test setup execution.
617
618 Redfish.Login
619
Tony Lee412c6682020-04-01 17:34:30 +0800620 ${active_channel_config}= Get Active Channel Config
621 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
622
623 ${original_nameservers}= Redfish.Get Attribute ${REDFISH_NW_ETH_IFACE}${ethernet_interface} StaticNameServers
624
Prashanth Kattic85957c2019-07-09 02:01:20 -0500625 Rprint Vars original_nameservers
626 # Set suite variables to trigger restoration during teardown.
627 Set Suite Variable ${original_nameservers}
Prashanth Kattib478d902020-05-08 10:05:32 -0500628
629Suite Setup Execution
630 [Documentation] Do suite setup execution.
631
632 ${test_gateway}= Get BMC Default Gateway
633 Set Suite Variable ${test_gateway}
Prashanth Katti568df5f2020-05-15 06:00:37 -0500634
635Update IP Address
636 [Documentation] Update IP address of BMC.
637 [Arguments] ${ip} ${new_ip} ${netmask} ${gw_ip} ${valid_status_codes}=${HTTP_OK}
638
639 # Description of argument(s):
640 # ip IP address to be replaced (e.g. "10.7.7.7").
641 # new_ip New IP address to be configured.
642 # netmask Netmask value.
643 # gw_ip Gateway IP address.
644 # valid_status_codes Expected return code from patch operation
645 # (e.g. "200"). See prolog of rest_request
646 # method in redfish_plus.py for details.
647
648 ${empty_dict}= Create Dictionary
649 ${patch_list}= Create List
650 ${ip_data}= Create Dictionary Address=${new_ip} SubnetMask=${netmask} Gateway=${gw_ip}
651
652 # Find the position of IP address to be modified.
653 @{network_configurations}= Get Network Configuration
654 FOR ${network_configuration} IN @{network_configurations}
655 Run Keyword If '${network_configuration['Address']}' == '${ip}'
656 ... Append To List ${patch_list} ${ip_data}
657 ... ELSE Append To List ${patch_list} ${empty_dict}
658 END
659
660 ${ip_found}= Run Keyword And Return Status List Should Contain Value
661 ... ${patch_list} ${ip_data} msg=${ip} does not exist on BMC
662 Pass Execution If ${ip_found} == ${False} ${ip} does not exist on BMC
663
664 # Run patch command only if given IP is found on BMC
665 ${data}= Create Dictionary IPv4StaticAddresses=${patch_list}
666
667 Redfish.patch ${REDFISH_NW_ETH0_URI} body=&{data} valid_status_codes=[${valid_status_codes}]
668
669 # Note: Network restart takes around 15-18s after patch request processing.
670 Sleep ${NETWORK_TIMEOUT}s
671 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
672
673 Verify IP On BMC ${new_ip}
674 Validate Network Config On BMC