blob: a610e2827a1c5ee757bc799ccdc9196850a87b40 [file] [log] [blame]
Prashanth Katti8abbb4d2021-01-29 02:17:45 -06001*** Settings ***
2Documentation Network interface IPv6 configuration and verification
3 ... tests.
4
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/bmc_ipv6_utils.robot
8Library ../../lib/bmc_network_utils.py
9Library Collections
10
11Test Setup Test Setup Execution
12Test Teardown Test Teardown Execution
Prashanth Katti3270fd02021-06-11 08:02:22 -050013Suite Setup Suite Setup Execution
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060014
Matt Fischer6fb70d92023-10-24 19:06:33 -060015Test Tags BMC_IPv6
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060016
17*** Variables ***
Sweta Potthuriafe858e2025-02-25 23:52:51 -060018${test_ipv6_addr} 2001:db8:3333:4444:5555:6666:7777:8888
19${test_ipv6_invalid_addr} 2001:db8:3333:4444:5555:6666:7777:JJKK
20${test_ipv6_addr1} 2001:db8:3333:4444:5555:6666:7777:9999
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060021
George Keishinge16f1582022-12-15 07:32:21 -060022# Valid prefix length is a integer ranges from 1 to 128.
Sweta Potthuriafe858e2025-02-25 23:52:51 -060023${test_prefix_length} 64
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060024
25*** Test Cases ***
26
27Get IPv6 Address And Verify
28 [Documentation] Get IPv6 Address And Verify.
29 [Tags] Get_IPv6_Address_And_Verify
30
31 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
32 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
33 END
34
35
Prashanth Katti2c73abc2021-03-17 07:42:25 -050036Get PrefixLength And Verify
37 [Documentation] Get IPv6 prefix length and verify.
38 [Tags] Get_PrefixLength_And_Verify
39
40 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
41 Verify IPv6 On BMC ${ipv6_network_configuration['PrefixLength']}
42 END
43
44
45Get IPv6 Default Gateway And Verify
George Keishing96143832021-03-23 07:55:08 -050046 [Documentation] Get IPv6 default gateway and verify.
George Keishingade6ab42022-07-19 11:41:03 -050047 [Tags] Get_IPv6_Default_Gateway_And_Verify
Prashanth Katti2c73abc2021-03-17 07:42:25 -050048
49 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
50 ${ipv6_gateway}= Get From Dictionary ${resp.dict} IPv6DefaultGateway
51 Verify IPv6 Default Gateway On BMC ${ipv6_gateway}
52
53
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050054Verify All Configured IPv6 And PrefixLength On BMC
55 [Documentation] Verify IPv6 address and its prefix length on BMC.
56 [Tags] Verify_All_Configured_IPv6_And_PrefixLength_On_BMC
57
58 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
George Keishingf02ca2b2023-04-05 22:11:03 +053059 Verify IPv6 And PrefixLength ${ipv6_network_configuration['Address']}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050060 ... ${ipv6_network_configuration['PrefixLength']}
61 END
62
63
64Configure IPv6 Address And Verify
65 [Documentation] Configure IPv6 address and verify.
66 [Tags] Configure_IPv6_Address_And_Verify
67 [Template] Configure IPv6 Address On BMC
68
69
70 # IPv6 address Prefix length
71 ${test_ipv6_addr} ${test_prefix_length}
72
73
Prashanth Katti12ed4b72023-05-16 05:24:00 -050074Delete IPv6 Address And Verify
75 [Documentation] Delete IPv6 address and verify.
76 [Tags] Delete_IPv6_Address_And_Verify
77
78 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
79
80 Delete IPv6 Address ${test_ipv6_addr}
81
82
Prashanth Katti5f7d2e42023-05-22 03:17:25 -050083
George Keishingcc288312024-10-22 10:13:12 +053084Modify IPv6 Address And Verify
Prashanth Katti5f7d2e42023-05-22 03:17:25 -050085 [Documentation] Modify IPv6 address and verify.
86 [Tags] Modify_IPv6_Address_And_Verify
kvishal88de8c42025-03-04 01:45:10 -060087 [Teardown] Run Keywords
George Keishingcfdd0992025-03-17 11:59:20 +053088 ... Delete IPv6 Address ${test_ipv6_addr1} AND Test Teardown Execution
Prashanth Katti5f7d2e42023-05-22 03:17:25 -050089
90 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
91
92 Modify IPv6 Address ${test_ipv6_addr} ${test_ipv6_addr1} ${test_prefix_length}
93
94
Sweta Potthuriafe858e2025-02-25 23:52:51 -060095Verify Persistency Of IPv6 After BMC Reboot
96 [Documentation] Verify persistency of IPv6 after BMC reboot.
97 [Tags] Verify_Persistency_Of_IPv6_After_BMC_Reboot
98 [Teardown] Run Keywords
99 ... Delete IPv6 Address ${test_ipv6_addr} AND Test Teardown Execution
100
101 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
102
103 Redfish OBMC Reboot (off) stack_mode=skip
104
105 # Verifying persistency of IPv6.
106 Verify IPv6 On BMC ${test_ipv6_addr}
107
108
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600109*** Keywords ***
110
Prashanth Katti3270fd02021-06-11 08:02:22 -0500111Suite Setup Execution
112 [Documentation] Do suite setup execution.
113
114 ${active_channel_config}= Get Active Channel Config
115 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
116
117 Set Suite variable ${ethernet_interface}
118
119
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600120Test Setup Execution
121 [Documentation] Test setup execution.
122
123 Redfish.Login
124
125 @{ipv6_network_configurations}= Get IPv6 Network Configuration
126 Set Test Variable @{ipv6_network_configurations}
127
128 # Get BMC IPv6 address and prefix length.
129 ${ipv6_data}= Get BMC IPv6 Info
130 Set Test Variable ${ipv6_data}
131
132
133Test Teardown Execution
134 [Documentation] Test teardown execution.
135
136 FFDC On Test Case Fail
137 Redfish.Logout
138
139
140Get IPv6 Network Configuration
141 [Documentation] Get Ipv6 network configuration.
142 # Sample output:
143 # {
ganesanb4d430282023-04-27 14:33:23 +0000144 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0",
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600145 # "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
146 # "DHCPv4": {
147 # "DHCPEnabled": false,
148 # "UseDNSServers": false,
149 # "UseDomainName": true,
150 # "UseNTPServers": false
151 # },
152 # "DHCPv6": {
153 # "OperatingMode": "Disabled",
154 # "UseDNSServers": false,
155 # "UseDomainName": true,
156 # "UseNTPServers": false
157 # },
158 # "Description": "Management Network Interface",
159 # "FQDN": "localhost",
160 # "HostName": "localhost",
161 # "IPv4Addresses": [
162 # {
163 # "Address": "xx.xx.xx.xx",
164 # "AddressOrigin": "Static",
165 # "Gateway": "xx.xx.xx.1",
166 # "SubnetMask": "xx.xx.xx.0"
167 # },
168 # {
169 # "Address": "169.254.xx.xx",
170 # "AddressOrigin": "IPv4LinkLocal",
171 # "Gateway": "0.0.0.0",
172 # "SubnetMask": "xx.xx.0.0"
173 # },
174 # ],
175 # "IPv4StaticAddresses": [
176 # {
177 # "Address": "xx.xx.xx.xx",
178 # "AddressOrigin": "Static",
179 # "Gateway": "xx.xx.xx.1",
180 # "SubnetMask": "xx.xx.0.0"
181 # }
182 # }
183 # ],
184 # "IPv6AddressPolicyTable": [],
185 # "IPv6Addresses": [
186 # {
187 # "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
188 # "AddressOrigin": "LinkLocal",
189 # "AddressState": null,
190 # "PrefixLength": xx
191 # }
192 # ],
193 # "IPv6DefaultGateway": "",
194 # "IPv6StaticAddresses": [
195 # { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
196 # "AddressOrigin": "Static",
197 # "AddressState": null,
198 # "PrefixLength": xxx
199 # }
200 # ],
201 # "Id": "eth0",
202 # "InterfaceEnabled": true,
203 # "LinkStatus": "LinkUp",
204 # "MACAddress": "xx:xx:xx:xx:xx:xx",
205 # "Name": "Manager Ethernet Interface",
206 # "NameServers": [],
207 # "SpeedMbps": 0,
208 # "StaticNameServers": [],
209 # "Status": {
210 # "Health": "OK",
211 # "HealthRollup": "OK",
212 # "State": "Enabled"
213 # },
214 # "VLANs": {
ganesanb4d430282023-04-27 14:33:23 +0000215 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs"
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600216
217
218 ${active_channel_config}= Get Active Channel Config
219 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
220
221 @{ipv6_network_configurations}= Get From Dictionary ${resp.dict} IPv6StaticAddresses
George Keishing409df052024-01-17 22:36:14 +0530222 RETURN @{ipv6_network_configurations}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500223
224
225Verify IPv6 And PrefixLength
226 [Documentation] Verify IPv6 address and prefix length on BMC.
227 [Arguments] ${ipv6_addr} ${prefix_len}
228
229 # Description of the argument(s):
230 # ipv6_addr IPv6 address to be verified.
231 # prefix_len PrefixLength value to be verified.
232
233 # Catenate IPv6 address and its prefix length.
234 ${ipv6_with_prefix}= Catenate ${ipv6_addr}/${prefix_len}
235
236 # Get IPv6 address details on BMC using IP command.
237 @{ip_data}= Get BMC IPv6 Info
238
239 # Verify if IPv6 and prefix length is configured on BMC.
240
241 Should Contain ${ip_data} ${ipv6_with_prefix}
242 ... msg=IPv6 and prefix length pair does not exist.
243
244
245Configure IPv6 Address On BMC
246 [Documentation] Add IPv6 Address on BMC.
247 [Arguments] ${ipv6_addr} ${prefix_len} ${valid_status_codes}=${HTTP_OK}
248
249 # Description of argument(s):
250 # ipv6_addr IPv6 address to be added (e.g. "2001:EEEE:2222::2022").
251 # prefix_len Prefix length for the IPv6 to be added
252 # (e.g. "64").
253 # valid_status_codes Expected return code from patch operation
254 # (e.g. "200").
255
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500256 ${prefix_length}= Convert To Integer ${prefix_len}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500257 ${empty_dict}= Create Dictionary
258 ${ipv6_data}= Create Dictionary Address=${ipv6_addr}
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500259 ... PrefixLength=${prefix_length}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500260
261 ${patch_list}= Create List
262
263 # Get existing static IPv6 configurations on BMC.
264 ${ipv6_network_configurations}= Get IPv6 Network Configuration
265 ${num_entries}= Get Length ${ipv6_network_configurations}
266
267 FOR ${INDEX} IN RANGE 0 ${num_entries}
268 Append To List ${patch_list} ${empty_dict}
269 END
270
271 ${valid_status_codes}= Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
272 ... Set Variable ${HTTP_OK},${HTTP_NO_CONTENT}
273 ... ELSE Set Variable ${valid_status_codes}
274
275 # We need not check for existence of IPv6 on BMC while adding.
276 Append To List ${patch_list} ${ipv6_data}
277 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
278
279 ${active_channel_config}= Get Active Channel Config
280 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
281
282 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
283 ... valid_status_codes=[${valid_status_codes}]
284
285 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
286
287 # Note: Network restart takes around 15-18s after patch request processing.
288 Sleep ${NETWORK_TIMEOUT}s
289 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
290
291 Verify IPv6 And PrefixLength ${ipv6_addr} ${prefix_len}
292
293 # Verify if existing static IPv6 addresses still exist.
294 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
295 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
296 END
297
298 Validate IPv6 Network Config On BMC
299
300
301Validate IPv6 Network Config On BMC
302 [Documentation] Check that IPv6 network info obtained via redfish matches info
303 ... obtained via CLI.
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500304 @{ipv6_network_configurations}= Get IPv6 Network Configuration
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500305 ${ipv6_data}= Get BMC IPv6 Info
306 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
307 Should Contain Match ${ipv6_data} ${ipv6_network_configuration['Address']}/*
308 ... msg=IPv6 address does not exist.
309 END
310
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500311
312Delete IPv6 Address
313 [Documentation] Delete IPv6 address of BMC.
314 [Arguments] ${ipv6_addr} ${valid_status_codes}=${HTTP_OK}
315
316 # Description of argument(s):
317 # ipv6_addr IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234").
318 # valid_status_codes Expected return code from patch operation
319 # (e.g. "200"). See prolog of rest_request
320 # method in redfish_plus.py for details.
321
322 ${empty_dict}= Create Dictionary
323 ${patch_list}= Create List
324
325 @{ipv6_network_configurations}= Get IPv6 Network Configuration
326 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
327 IF '${ipv6_network_configuration['Address']}' == '${ipv6_addr}'
328 Append To List ${patch_list} ${null}
329 ELSE
330 Append To List ${patch_list} ${empty_dict}
331 END
332 END
333
334 ${ip_found}= Run Keyword And Return Status List Should Contain Value
335 ... ${patch_list} ${null} msg=${ipv6_addr} does not exist on BMC
336 Pass Execution If ${ip_found} == ${False} ${ipv6_addr} does not exist on BMC
337
338 # Run patch command only if given IP is found on BMC
339 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
340
341 ${active_channel_config}= Get Active Channel Config
342 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
343
344 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
345 ... valid_status_codes=[${valid_status_codes}]
346
347 # Note: Network restart takes around 15-18s after patch request processing
348 Sleep ${NETWORK_TIMEOUT}s
349 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
350
351 # IPv6 address that is deleted should not be there on BMC.
352 ${delete_status}= Run Keyword And Return Status Verify IPv6 On BMC ${ipv6_addr}
353 IF '${valid_status_codes}' == '${HTTP_OK}'
354 Should Be True '${delete_status}' == '${False}'
355 ELSE
356 Should Be True '${delete_status}' == '${True}'
357 END
358
359 Validate IPv6 Network Config On BMC
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500360
361
362Modify IPv6 Address
363 [Documentation] Modify and verify IPv6 address of BMC.
364 [Arguments] ${ipv6} ${new_ipv6} ${prefix_len}
365 ... ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
366
367 # Description of argument(s):
368 # ipv6 IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
369 # new_ipv6 New IPv6 address to be configured.
370 # prefix_len Prefix length value (Range 1 to 128).
371 # valid_status_codes Expected return code from patch operation
372 # (e.g. "200", "201").
373
374 ${empty_dict}= Create Dictionary
375 ${patch_list}= Create List
376 ${prefix_length}= Convert To Integer ${prefix_len}
377 ${ipv6_data}= Create Dictionary
378 ... Address=${new_ipv6} PrefixLength=${prefix_length}
379
380 # Sample IPv6 network configurations:
381 # "IPv6AddressPolicyTable": [],
382 # "IPv6Addresses": [
383 # {
384 # "Address": "X002:db8:0:2::XX0",
385 # "AddressOrigin": "DHCPv6",
386 # "PrefixLength": 128
387 # },
388 # {
389 # "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX",
390 # "AddressOrigin": "SLAAC",
391 # "PrefixLength": 64
392 # },
393 # {
394 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
395 # "AddressOrigin": "Static",
396 # "PrefixLength": 56
397 # },
398 # {
399 # "Address": “Z002:db8:0:2:a94:efff:fe82:5000",
400 # "AddressOrigin": "Static",
401 # "PrefixLength": 56
402 # },
403 # {
404 # "Address": “Xe80::a94:efff:YYYY:XXXX",
405 # "AddressOrigin": "LinkLocal",
406 # "PrefixLength": 64
407 # },
408 # {
409 # "Address": “X002:db8:1:2:eff:233:fee:546",
410 # "AddressOrigin": "Static",
411 # "PrefixLength": 56
412 # }
413 # ],
414 # "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”,
415 # "IPv6StaticAddresses": [
416 # {
417 # "Address": “X002:db8:0:2:a94:efff:fe82:5000",
418 # "PrefixLength": 56
419 # },
420 # {
421 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
422 # "PrefixLength": 56
423 # },
424 # {
425 # "Address": “Z002:db8:1:2:eff:233:fee:546",
426 # "PrefixLength": 56
427 # }
428 # ],
429 # "IPv6StaticDefaultGateways": [],
430
431 # Find the position of IPv6 address to be modified.
432 @{ipv6_network_configurations}= Get IPv6 Network Configuration
433 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
434 Run Keyword If '${ipv6_network_configuration['Address']}' == '${ipv6}'
435 ... Append To List ${patch_list} ${ipv6_data}
436 ... ELSE Append To List ${patch_list} ${empty_dict}
437 END
438
439 # Modify the IPv6 address only if given IPv6 is found
440 ${ip_found}= Run Keyword And Return Status List Should Contain Value
441 ... ${patch_list} ${ipv6_data} msg=${ipv6} does not exist on BMC
442 Pass Execution If ${ip_found} == ${False} ${ipv6} does not exist on BMC
443
444 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
445
446 ${active_channel_config}= Get Active Channel Config
447 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
448
449 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
450 ... body=&{data} valid_status_codes=${valid_status_codes}
451
452 # Note: Network restart takes around 15-18s after patch request processing.
453 Sleep ${NETWORK_TIMEOUT}s
454 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
455
456 # Verify if new IPv6 address is configured on BMC.
457 Verify IPv6 On BMC ${new_ipv6}
458
459 # Verify if old IPv6 address is erased.
460 ${cmd_status}= Run Keyword And Return Status
461 ... Verify IPv6 On BMC ${ipv6}
462 Should Be Equal ${cmd_status} ${False} msg=Old IPv6 address is not deleted.
463
464 Validate IPv6 Network Config On BMC