blob: 0aaa58b8802fd8ce2c43e10b69e743ddcb6b16c7 [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
Sweta Potthuri8ba74322025-03-19 12:29:06 -05008Resource ../../lib/external_intf/vmi_utils.robot
Prashanth Katti8abbb4d2021-01-29 02:17:45 -06009Library ../../lib/bmc_network_utils.py
10Library Collections
11
12Test Setup Test Setup Execution
13Test Teardown Test Teardown Execution
Prashanth Katti3270fd02021-06-11 08:02:22 -050014Suite Setup Suite Setup Execution
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060015
Matt Fischer6fb70d92023-10-24 19:06:33 -060016Test Tags BMC_IPv6
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060017
18*** Variables ***
Sweta Potthuri2edacd32025-07-02 01:04:43 -050019${test_ipv6_addr} 2001:db8:3333:4444:5555:6666:7777:8888
20${test_ipv6_invalid_addr} 2001:db8:3333:4444:5555:6666:7777:JJKK
21${test_ipv6_addr1} 2001:db8:3333:4444:5555:6666:7777:9999
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060022
George Keishinge16f1582022-12-15 07:32:21 -060023# Valid prefix length is a integer ranges from 1 to 128.
Sweta Potthuri2edacd32025-07-02 01:04:43 -050024${test_prefix_length} 64
25${ipv6_gw_addr} 2002:903:15F:32:9:3:32:1
26${prefix_length_def} None
27${invalid_staticv6_gateway} 9.41.164.1
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060028
29*** Test Cases ***
30
31Get IPv6 Address And Verify
32 [Documentation] Get IPv6 Address And Verify.
33 [Tags] Get_IPv6_Address_And_Verify
34
35 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
36 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
37 END
38
39
Prashanth Katti2c73abc2021-03-17 07:42:25 -050040Get PrefixLength And Verify
41 [Documentation] Get IPv6 prefix length and verify.
42 [Tags] Get_PrefixLength_And_Verify
43
44 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
45 Verify IPv6 On BMC ${ipv6_network_configuration['PrefixLength']}
46 END
47
48
49Get IPv6 Default Gateway And Verify
George Keishing96143832021-03-23 07:55:08 -050050 [Documentation] Get IPv6 default gateway and verify.
George Keishingade6ab42022-07-19 11:41:03 -050051 [Tags] Get_IPv6_Default_Gateway_And_Verify
Prashanth Katti2c73abc2021-03-17 07:42:25 -050052
53 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
54 ${ipv6_gateway}= Get From Dictionary ${resp.dict} IPv6DefaultGateway
55 Verify IPv6 Default Gateway On BMC ${ipv6_gateway}
56
57
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050058Verify All Configured IPv6 And PrefixLength On BMC
59 [Documentation] Verify IPv6 address and its prefix length on BMC.
60 [Tags] Verify_All_Configured_IPv6_And_PrefixLength_On_BMC
61
62 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
George Keishingf02ca2b2023-04-05 22:11:03 +053063 Verify IPv6 And PrefixLength ${ipv6_network_configuration['Address']}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050064 ... ${ipv6_network_configuration['PrefixLength']}
65 END
66
67
68Configure IPv6 Address And Verify
69 [Documentation] Configure IPv6 address and verify.
70 [Tags] Configure_IPv6_Address_And_Verify
Anvesh-Kumar_Rayankula3a26c662025-04-16 01:19:26 -050071 [Teardown] Run Keywords
72 ... Delete IPv6 Address ${test_ipv6_addr} AND Test Teardown Execution
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050073 [Template] Configure IPv6 Address On BMC
74
75
76 # IPv6 address Prefix length
77 ${test_ipv6_addr} ${test_prefix_length}
78
79
Prashanth Katti12ed4b72023-05-16 05:24:00 -050080Delete IPv6 Address And Verify
81 [Documentation] Delete IPv6 address and verify.
82 [Tags] Delete_IPv6_Address_And_Verify
83
84 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
85
86 Delete IPv6 Address ${test_ipv6_addr}
87
88
Prashanth Katti5f7d2e42023-05-22 03:17:25 -050089
George Keishingcc288312024-10-22 10:13:12 +053090Modify IPv6 Address And Verify
Prashanth Katti5f7d2e42023-05-22 03:17:25 -050091 [Documentation] Modify IPv6 address and verify.
92 [Tags] Modify_IPv6_Address_And_Verify
kvishal88de8c42025-03-04 01:45:10 -060093 [Teardown] Run Keywords
George Keishingcfdd0992025-03-17 11:59:20 +053094 ... Delete IPv6 Address ${test_ipv6_addr1} AND Test Teardown Execution
Prashanth Katti5f7d2e42023-05-22 03:17:25 -050095
96 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
97
98 Modify IPv6 Address ${test_ipv6_addr} ${test_ipv6_addr1} ${test_prefix_length}
99
100
Sweta Potthuriafe858e2025-02-25 23:52:51 -0600101Verify Persistency Of IPv6 After BMC Reboot
102 [Documentation] Verify persistency of IPv6 after BMC reboot.
103 [Tags] Verify_Persistency_Of_IPv6_After_BMC_Reboot
104 [Teardown] Run Keywords
105 ... Delete IPv6 Address ${test_ipv6_addr} AND Test Teardown Execution
106
107 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
108
109 Redfish OBMC Reboot (off) stack_mode=skip
110
111 # Verifying persistency of IPv6.
112 Verify IPv6 On BMC ${test_ipv6_addr}
113
114
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500115Enable SLAACv6 On BMC And Verify
116 [Documentation] Enable SLAACv6 on BMC and verify.
117 [Tags] Enable_SLAACv6_On_BMC_And_Verify
118
119 Set SLAACv6 Configuration State And Verify ${True}
120
121
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500122Enable DHCPv6 Property On BMC And Verify
123 [Documentation] Enable DHCPv6 property on BMC and verify.
124 [Tags] Enable_DHCPv6_Property_On_BMC_And_Verify
125
126 Set And Verify DHCPv6 Property Enabled
127
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500128
kvishal0d199a92025-05-29 02:35:18 -0500129Disable DHCPv6 Property On BMC And Verify
130 [Documentation] Disable DHCPv6 property on BMC and verify.
131 [Tags] Disable_DHCPv6_Property_On_BMC_And_Verify
132
133 Set And Verify DHCPv6 Property Disabled
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500134
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500135
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500136Configure Invalid Static IPv6 And Verify
137 [Documentation] Configure invalid static IPv6 and verify.
138 [Tags] Configure_Invalid_Static_IPv6_And_Verify
139 [Template] Configure IPv6 Address On BMC
140
141 #invalid_ipv6 prefix length valid_status_code
142 ${ipv4_hexword_addr} ${test_prefix_length} ${HTTP_BAD_REQUEST}
143
Sweta Potthuri565318d2025-06-09 06:13:46 -0500144
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500145Configure IPv6 Static Default Gateway And Verify
146 [Documentation] Configure IPv6 static default gateway and verify.
147 [Tags] Configure_IPv6_Static_Default_Gateway_And_Verify
148 [Template] Configure IPv6 Static Default Gateway On BMC
Sweta Potthuri565318d2025-06-09 06:13:46 -0500149
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500150 # static_def_gw prefix length valid_status_code
151 ${ipv6_gw_addr} ${prefix_length_def} ${HTTP_OK}
152 ${invalid_staticv6_gateway} ${test_prefix_length} ${HTTP_BAD_REQUEST}
Sweta Potthuri565318d2025-06-09 06:13:46 -0500153
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500154
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500155Modify Static Default Gateway And Verify
156 [Documentation] Modify static default gateway and verify.
157 [Tags] Modify_Static_Default_Gateway_And_Verify
158 [Setup] Configure IPv6 Static Default Gateway On BMC ${ipv6_gw_addr} ${prefix_length_def}
159
160 Modify IPv6 Static Default Gateway On BMC ${test_ipv6_addr1} ${prefix_length_def} ${HTTP_OK} ${ipv6_gw_addr}
161
162
Sweta Potthuri2d085732025-07-16 09:10:08 -0500163Delete IPv6 Static Default Gateway And Verify
164 [Documentation] Delete IPv6 static default gateway and verify.
165 [Tags] Delete_IPv6_Static_Default_Gateway_And_Verify
166 [Setup] Configure IPv6 Static Default Gateway On BMC ${ipv6_gw_addr} ${prefix_length_def}
167
168 Delete IPv6 Static Default Gateway ${ipv6_gw_addr}
169
170
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600171*** Keywords ***
172
Prashanth Katti3270fd02021-06-11 08:02:22 -0500173Suite Setup Execution
174 [Documentation] Do suite setup execution.
175
176 ${active_channel_config}= Get Active Channel Config
177 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
178
179 Set Suite variable ${ethernet_interface}
180
181
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600182Test Setup Execution
183 [Documentation] Test setup execution.
184
185 Redfish.Login
186
187 @{ipv6_network_configurations}= Get IPv6 Network Configuration
188 Set Test Variable @{ipv6_network_configurations}
189
190 # Get BMC IPv6 address and prefix length.
191 ${ipv6_data}= Get BMC IPv6 Info
192 Set Test Variable ${ipv6_data}
193
194
195Test Teardown Execution
196 [Documentation] Test teardown execution.
197
198 FFDC On Test Case Fail
199 Redfish.Logout
200
201
202Get IPv6 Network Configuration
203 [Documentation] Get Ipv6 network configuration.
204 # Sample output:
205 # {
ganesanb4d430282023-04-27 14:33:23 +0000206 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0",
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600207 # "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
208 # "DHCPv4": {
209 # "DHCPEnabled": false,
210 # "UseDNSServers": false,
211 # "UseDomainName": true,
212 # "UseNTPServers": false
213 # },
214 # "DHCPv6": {
215 # "OperatingMode": "Disabled",
216 # "UseDNSServers": false,
217 # "UseDomainName": true,
218 # "UseNTPServers": false
219 # },
220 # "Description": "Management Network Interface",
221 # "FQDN": "localhost",
222 # "HostName": "localhost",
223 # "IPv4Addresses": [
224 # {
225 # "Address": "xx.xx.xx.xx",
226 # "AddressOrigin": "Static",
227 # "Gateway": "xx.xx.xx.1",
228 # "SubnetMask": "xx.xx.xx.0"
229 # },
230 # {
231 # "Address": "169.254.xx.xx",
232 # "AddressOrigin": "IPv4LinkLocal",
233 # "Gateway": "0.0.0.0",
234 # "SubnetMask": "xx.xx.0.0"
235 # },
236 # ],
237 # "IPv4StaticAddresses": [
238 # {
239 # "Address": "xx.xx.xx.xx",
240 # "AddressOrigin": "Static",
241 # "Gateway": "xx.xx.xx.1",
242 # "SubnetMask": "xx.xx.0.0"
243 # }
244 # }
245 # ],
246 # "IPv6AddressPolicyTable": [],
247 # "IPv6Addresses": [
248 # {
249 # "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
250 # "AddressOrigin": "LinkLocal",
251 # "AddressState": null,
252 # "PrefixLength": xx
253 # }
254 # ],
255 # "IPv6DefaultGateway": "",
256 # "IPv6StaticAddresses": [
257 # { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
258 # "AddressOrigin": "Static",
259 # "AddressState": null,
260 # "PrefixLength": xxx
261 # }
262 # ],
263 # "Id": "eth0",
264 # "InterfaceEnabled": true,
265 # "LinkStatus": "LinkUp",
266 # "MACAddress": "xx:xx:xx:xx:xx:xx",
267 # "Name": "Manager Ethernet Interface",
268 # "NameServers": [],
269 # "SpeedMbps": 0,
270 # "StaticNameServers": [],
271 # "Status": {
272 # "Health": "OK",
273 # "HealthRollup": "OK",
274 # "State": "Enabled"
275 # },
276 # "VLANs": {
ganesanb4d430282023-04-27 14:33:23 +0000277 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs"
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600278
279
280 ${active_channel_config}= Get Active Channel Config
281 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
282
283 @{ipv6_network_configurations}= Get From Dictionary ${resp.dict} IPv6StaticAddresses
George Keishing409df052024-01-17 22:36:14 +0530284 RETURN @{ipv6_network_configurations}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500285
286
287Verify IPv6 And PrefixLength
288 [Documentation] Verify IPv6 address and prefix length on BMC.
289 [Arguments] ${ipv6_addr} ${prefix_len}
290
291 # Description of the argument(s):
292 # ipv6_addr IPv6 address to be verified.
293 # prefix_len PrefixLength value to be verified.
294
295 # Catenate IPv6 address and its prefix length.
296 ${ipv6_with_prefix}= Catenate ${ipv6_addr}/${prefix_len}
297
298 # Get IPv6 address details on BMC using IP command.
299 @{ip_data}= Get BMC IPv6 Info
300
301 # Verify if IPv6 and prefix length is configured on BMC.
302
303 Should Contain ${ip_data} ${ipv6_with_prefix}
304 ... msg=IPv6 and prefix length pair does not exist.
305
306
307Configure IPv6 Address On BMC
308 [Documentation] Add IPv6 Address on BMC.
309 [Arguments] ${ipv6_addr} ${prefix_len} ${valid_status_codes}=${HTTP_OK}
310
311 # Description of argument(s):
312 # ipv6_addr IPv6 address to be added (e.g. "2001:EEEE:2222::2022").
313 # prefix_len Prefix length for the IPv6 to be added
314 # (e.g. "64").
315 # valid_status_codes Expected return code from patch operation
316 # (e.g. "200").
317
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500318 ${prefix_length}= Convert To Integer ${prefix_len}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500319 ${empty_dict}= Create Dictionary
320 ${ipv6_data}= Create Dictionary Address=${ipv6_addr}
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500321 ... PrefixLength=${prefix_length}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500322
323 ${patch_list}= Create List
324
325 # Get existing static IPv6 configurations on BMC.
326 ${ipv6_network_configurations}= Get IPv6 Network Configuration
327 ${num_entries}= Get Length ${ipv6_network_configurations}
328
329 FOR ${INDEX} IN RANGE 0 ${num_entries}
330 Append To List ${patch_list} ${empty_dict}
331 END
332
George Keishinge6e161e2025-05-08 10:18:30 +0530333 ${valid_status_codes}= Set Variable If '${valid_status_codes}' == '${HTTP_OK}'
334 ... ${HTTP_OK},${HTTP_NO_CONTENT}
335 ... ${valid_status_codes}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500336
337 # We need not check for existence of IPv6 on BMC while adding.
338 Append To List ${patch_list} ${ipv6_data}
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 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
348
349 # Note: Network restart takes around 15-18s after patch request processing.
350 Sleep ${NETWORK_TIMEOUT}s
351 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
352
353 Verify IPv6 And PrefixLength ${ipv6_addr} ${prefix_len}
354
355 # Verify if existing static IPv6 addresses still exist.
356 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
357 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
358 END
359
360 Validate IPv6 Network Config On BMC
361
362
363Validate IPv6 Network Config On BMC
364 [Documentation] Check that IPv6 network info obtained via redfish matches info
365 ... obtained via CLI.
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500366 @{ipv6_network_configurations}= Get IPv6 Network Configuration
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500367 ${ipv6_data}= Get BMC IPv6 Info
368 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
369 Should Contain Match ${ipv6_data} ${ipv6_network_configuration['Address']}/*
370 ... msg=IPv6 address does not exist.
371 END
372
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500373
374Delete IPv6 Address
375 [Documentation] Delete IPv6 address of BMC.
Prashanth Kattibcb9dab2025-04-01 12:58:37 -0500376 [Arguments] ${ipv6_addr}
377 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500378
379 # Description of argument(s):
380 # ipv6_addr IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234").
381 # valid_status_codes Expected return code from patch operation
382 # (e.g. "200"). See prolog of rest_request
383 # method in redfish_plus.py for details.
384
385 ${empty_dict}= Create Dictionary
386 ${patch_list}= Create List
387
388 @{ipv6_network_configurations}= Get IPv6 Network Configuration
389 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
390 IF '${ipv6_network_configuration['Address']}' == '${ipv6_addr}'
391 Append To List ${patch_list} ${null}
392 ELSE
393 Append To List ${patch_list} ${empty_dict}
394 END
395 END
396
397 ${ip_found}= Run Keyword And Return Status List Should Contain Value
398 ... ${patch_list} ${null} msg=${ipv6_addr} does not exist on BMC
399 Pass Execution If ${ip_found} == ${False} ${ipv6_addr} does not exist on BMC
400
401 # Run patch command only if given IP is found on BMC
402 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
403
404 ${active_channel_config}= Get Active Channel Config
405 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
406
407 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
Sweta Potthuria1981612025-05-09 05:41:10 -0500408 ... valid_status_codes=${valid_status_codes}
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500409
410 # Note: Network restart takes around 15-18s after patch request processing
411 Sleep ${NETWORK_TIMEOUT}s
412 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
413
414 # IPv6 address that is deleted should not be there on BMC.
415 ${delete_status}= Run Keyword And Return Status Verify IPv6 On BMC ${ipv6_addr}
Anvesh-Kumar_Rayankula3a26c662025-04-16 01:19:26 -0500416 IF '${valid_status_codes}' == '[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]'
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500417 Should Be True '${delete_status}' == '${False}'
418 ELSE
419 Should Be True '${delete_status}' == '${True}'
420 END
421
422 Validate IPv6 Network Config On BMC
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500423
424
425Modify IPv6 Address
426 [Documentation] Modify and verify IPv6 address of BMC.
427 [Arguments] ${ipv6} ${new_ipv6} ${prefix_len}
428 ... ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
429
430 # Description of argument(s):
431 # ipv6 IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
432 # new_ipv6 New IPv6 address to be configured.
433 # prefix_len Prefix length value (Range 1 to 128).
434 # valid_status_codes Expected return code from patch operation
435 # (e.g. "200", "201").
436
437 ${empty_dict}= Create Dictionary
438 ${patch_list}= Create List
439 ${prefix_length}= Convert To Integer ${prefix_len}
440 ${ipv6_data}= Create Dictionary
441 ... Address=${new_ipv6} PrefixLength=${prefix_length}
442
443 # Sample IPv6 network configurations:
444 # "IPv6AddressPolicyTable": [],
445 # "IPv6Addresses": [
446 # {
447 # "Address": "X002:db8:0:2::XX0",
448 # "AddressOrigin": "DHCPv6",
449 # "PrefixLength": 128
450 # },
451 # {
452 # "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX",
453 # "AddressOrigin": "SLAAC",
454 # "PrefixLength": 64
455 # },
456 # {
457 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
458 # "AddressOrigin": "Static",
459 # "PrefixLength": 56
460 # },
461 # {
462 # "Address": “Z002:db8:0:2:a94:efff:fe82:5000",
463 # "AddressOrigin": "Static",
464 # "PrefixLength": 56
465 # },
466 # {
467 # "Address": “Xe80::a94:efff:YYYY:XXXX",
468 # "AddressOrigin": "LinkLocal",
469 # "PrefixLength": 64
470 # },
471 # {
472 # "Address": “X002:db8:1:2:eff:233:fee:546",
473 # "AddressOrigin": "Static",
474 # "PrefixLength": 56
475 # }
476 # ],
477 # "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”,
478 # "IPv6StaticAddresses": [
479 # {
480 # "Address": “X002:db8:0:2:a94:efff:fe82:5000",
481 # "PrefixLength": 56
482 # },
483 # {
484 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
485 # "PrefixLength": 56
486 # },
487 # {
488 # "Address": “Z002:db8:1:2:eff:233:fee:546",
489 # "PrefixLength": 56
490 # }
491 # ],
492 # "IPv6StaticDefaultGateways": [],
493
494 # Find the position of IPv6 address to be modified.
495 @{ipv6_network_configurations}= Get IPv6 Network Configuration
496 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
George Keishinge6e161e2025-05-08 10:18:30 +0530497 IF '${ipv6_network_configuration['Address']}' == '${ipv6}'
498 Append To List ${patch_list} ${ipv6_data}
499 ELSE
500 Append To List ${patch_list} ${empty_dict}
501 END
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500502 END
503
504 # Modify the IPv6 address only if given IPv6 is found
505 ${ip_found}= Run Keyword And Return Status List Should Contain Value
506 ... ${patch_list} ${ipv6_data} msg=${ipv6} does not exist on BMC
507 Pass Execution If ${ip_found} == ${False} ${ipv6} does not exist on BMC
508
509 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
510
511 ${active_channel_config}= Get Active Channel Config
512 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
513
514 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
515 ... body=&{data} valid_status_codes=${valid_status_codes}
516
517 # Note: Network restart takes around 15-18s after patch request processing.
518 Sleep ${NETWORK_TIMEOUT}s
519 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
520
521 # Verify if new IPv6 address is configured on BMC.
522 Verify IPv6 On BMC ${new_ipv6}
523
524 # Verify if old IPv6 address is erased.
525 ${cmd_status}= Run Keyword And Return Status
526 ... Verify IPv6 On BMC ${ipv6}
527 Should Be Equal ${cmd_status} ${False} msg=Old IPv6 address is not deleted.
528
529 Validate IPv6 Network Config On BMC
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500530
531
532Set SLAACv6 Configuration State And Verify
533 [Documentation] Set SLAACv6 configuration state and verify.
Sweta Potthuri610f86f2025-05-30 00:47:23 -0500534 [Arguments] ${slaac_state} ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500535
536 # Description of argument(s):
537 # slaac_state SLAACv6 state('True' or 'False').
538 # valid_status_code Expected valid status codes.
539
540 ${active_channel_config}= Get Active Channel Config
541 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
542
543 ${data}= Set Variable If ${slaac_state} == ${False} ${DISABLE_SLAAC} ${ENABLE_SLAAC}
544 ${resp}= Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Sweta Potthuri610f86f2025-05-30 00:47:23 -0500545 ... body=${data} valid_status_codes=${valid_status_codes}
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500546
547 # Verify SLAACv6 is set correctly.
548 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
549 ${slaac_verify}= Get From Dictionary ${resp.dict} StatelessAddressAutoConfig
550
George Keishinge6e161e2025-05-08 10:18:30 +0530551 IF '${slaac_verify['IPv6AutoConfigEnabled']}' != '${slaac_state}'
552 Fail msg=SLAACv6 not set properly.
553 END
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500554
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500555
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500556Set And Verify DHCPv6 Property
557 [Documentation] Set DHCPv6 attribute and verify.
558 [Arguments] ${dhcpv6_operating_mode}=${Disabled}
559
560 # Description of argument(s):
561 # dhcpv6_operating_mode Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled').
562
563 ${data}= Set Variable If '${dhcpv6_operating_mode}' == 'Disabled' ${DISABLE_DHCPv6} ${ENABLE_DHCPv6}
564 ${active_channel_config}= Get Active Channel Config
565 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
566
567 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
568 ... body=${data} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
569
570 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
571 ${dhcpv6_verify}= Get From Dictionary ${resp.dict} DHCPv6
572
573 Should Be Equal '${dhcpv6_verify['OperatingMode']}' '${dhcpv6_operating_mode}'
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500574
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500575
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500576Get IPv6 Static Default Gateway
577 [Documentation] Get IPv6 static default gateway.
578
579 ${active_channel_config}= Get Active Channel Config
580 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
581
582 @{ipv6_static_defgw_configurations}= Get From Dictionary ${resp.dict} IPv6StaticDefaultGateways
583 RETURN @{ipv6_static_defgw_configurations}
584
Sweta Potthuri2d085732025-07-16 09:10:08 -0500585
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500586Configure IPv6 Static Default Gateway On BMC
587 [Documentation] Configure IPv6 static default gateway on BMC.
588 [Arguments] ${ipv6_gw_addr} ${prefix_length_def}
589 ... ${valid_status_codes}=${HTTP_OK}
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500590 # Description of argument(s):
591 # ipv6_gw_addr IPv6 Static Default Gateway address to be configured.
592 # prefix_len_def Prefix length value (Range 1 to 128).
593 # valid_status_codes Expected return code from patch operation
594 # (e.g. "200", "204".)
595
596 # Prefix Length is passed as None.
597 IF '${prefix_length_def}' == '${None}'
598 ${ipv6_gw}= Create Dictionary Address=${ipv6_gw_addr}
599 ELSE
600 ${ipv6_gw}= Create Dictionary Address=${ipv6_gw_addr} Prefix Length=${prefix_length_def}
601 END
602
603 ${ipv6_static_def_gw}= Get IPv6 Static Default Gateway
604
605 ${num_entries}= Get Length ${ipv6_static_def_gw}
606
607 ${patch_list}= Create List
608 ${empty_dict}= Create Dictionary
609
610 FOR ${INDEX} IN RANGE 0 ${num_entries}
611 Append To List ${patch_list} ${empty_dict}
612 END
613
614 ${valid_status_codes}= Set Variable If '${valid_status_codes}' == '${HTTP_OK}'
615 ... ${HTTP_OK},${HTTP_NO_CONTENT}
616 ... ${valid_status_codes}
617
618 Append To List ${patch_list} ${ipv6_gw}
619 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
620
621 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
622 ... body=${data} valid_status_codes=[${valid_status_codes}]
623
624 # Verify the added static default gateway is present in Redfish Get Output.
625 ${ipv6_staticdef_gateway}= Get IPv6 Static Default Gateway
626
627 ${ipv6_static_def_gw_list}= Create List
628 FOR ${ipv6_staticdef_gateway} IN @{ipv6_staticdef_gateway}
629 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
630 Append To List ${ipv6_static_def_gw_list} ${value}
631 END
632
633 IF '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
634 Should Not Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
635 ELSE
636 Should Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
637 END
638
Sweta Potthuri2d085732025-07-16 09:10:08 -0500639
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500640Modify Static Default Gateway
641 [Documentation] Modify and verify IPv6 address of BMC.
642 [Arguments] ${ipv6_gw_addr} ${new_static_def_gw} ${prefix_length}
643 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED}]
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500644
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500645 # Description of argument(s):
646 # ipv6_gw_addr IPv6 static default gateway address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
647 # new_static_def_gw New static default gateway address to be configured.
648 # prefix length Prefix length value (Range 1 to 128).
649 # valid_status_codes Expected return code from patch operation
650 # (e.g. "200", "204").
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500651
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500652 ${empty_dict}= Create Dictionary
653 ${patch_list}= Create List
654 # Prefix Length is passed as None.
655 IF '${prefix_length_def}' == '${None}'
656 ${modified_ipv6_gw_addripv6_data}= Create Dictionary Address=${new_static_def_gw}
657 ELSE
658 ${modified_ipv6_gw_addripv6_data}= Create Dictionary Address=${new_static_def_gw} Prefix Length=${prefix_length_def}
659 END
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500660
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500661 @{ipv6_static_def_gw_list}= Get IPv6 Static Default Gateway
662
663 FOR ${ipv6_static_def_gw} IN @{ipv6_static_def_gw_list}
664 IF '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
665 Append To List ${patch_list} ${modified_ipv6_gw_addripv6_data}
666 ELSE
667 Append To List ${patch_list} ${empty_dict}
668 END
669 END
670
671 # Modify the IPv6 address only if given IPv6 static default gateway is found.
672 ${ip_static_def_gw_found}= Run Keyword And Return Status List Should Contain Value
673 ... ${patch_list} ${modified_ipv6_gw_addripv6_data} msg=${ipv6_gw_addr} does not exist on BMC
674 Pass Execution If ${ip_static_def_gw_found} == ${False} ${ipv6_gw_addr} does not exist on BMC
675
676 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
677
678 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
679 ... body=&{data} valid_status_codes=${valid_status_codes}
680
681 ${ipv6_staticdef_gateway}= Get IPv6 Static Default Gateway
682
683 ${ipv6_static_def_gw_list}= Create List
684 FOR ${ipv6_staticdef_gateway} IN @{ipv6_staticdef_gateway}
Sweta Potthuri2d085732025-07-16 09:10:08 -0500685 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500686 Append To List ${ipv6_static_def_gw_list} ${value}
687 END
688
689 Should Contain ${ipv6_static_def_gw_list} ${new_static_def_gw}
690 # Verify if old static default gateway address is erased.
691 Should Not Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
692
Sweta Potthuri2d085732025-07-16 09:10:08 -0500693
694Delete IPv6 Static Default Gateway
695 [Documentation] Delete IPv6 static default gateway on BMC.
696 [Arguments] ${ipv6_gw_addr}
697 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
698
699 # Description of argument(s):
700 # ipv6_gw_addr IPv6 Static Default Gateway address to be deleted.
701 # valid_status_codes Expected return code from patch operation
702 # (e.g. "200").
703
704 ${patch_list}= Create List
705 ${empty_dict}= Create Dictionary
706
707 ${ipv6_static_def_gw_list}= Create List
708 @{ipv6_static_defgw_configurations}= Get IPv6 Static Default Gateway
709
710 FOR ${ipv6_staticdef_gateway} IN @{ipv6_static_defgw_configurations}
711 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
712 Append To List ${ipv6_static_def_gw_list} ${value}
713 END
714
715 ${defgw_found}= Run Keyword And Return Status List Should Contain Value
716 ... ${ipv6_static_def_gw_list} ${ipv6_gw_addr} msg=${ipv6_gw_addr} does not exist on BMC
717 Skip If ${defgw_found} == ${False} ${ipv6_gw_addr} does not exist on BMC
718
719 FOR ${ipv6_static_def_gw} IN @{ipv6_static_defgw_configurations}
720 IF '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
721 Append To List ${patch_list} ${null}
722 ELSE
723 Append To List ${patch_list} ${empty_dict}
724 END
725 END
726
727 # Run patch command only if given IP is found on BMC.
728 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
729
730 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
731 ... valid_status_codes=${valid_status_codes}
732
733 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
734
735 @{ipv6_static_defgw_configurations}= Get IPv6 Static Default Gateway
736 Should Not Contain Match ${ipv6_static_defgw_configurations} ${ipv6_gw_addr}
737 ... msg=IPv6 Static default gateway does not exist.