blob: 60cd440ea858c249fa27f6227ca75a685508e9fa [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
Sweta Potthuri35c503b2025-07-27 23:36:20 -050011Library Process
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060012
13Test Setup Test Setup Execution
14Test Teardown Test Teardown Execution
Prashanth Katti3270fd02021-06-11 08:02:22 -050015Suite Setup Suite Setup Execution
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060016
Matt Fischer6fb70d92023-10-24 19:06:33 -060017Test Tags BMC_IPv6
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060018
19*** Variables ***
Sweta Potthuri2edacd32025-07-02 01:04:43 -050020${test_ipv6_addr} 2001:db8:3333:4444:5555:6666:7777:8888
21${test_ipv6_invalid_addr} 2001:db8:3333:4444:5555:6666:7777:JJKK
22${test_ipv6_addr1} 2001:db8:3333:4444:5555:6666:7777:9999
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060023
George Keishinge16f1582022-12-15 07:32:21 -060024# Valid prefix length is a integer ranges from 1 to 128.
Sweta Potthuri2edacd32025-07-02 01:04:43 -050025${test_prefix_length} 64
26${ipv6_gw_addr} 2002:903:15F:32:9:3:32:1
27${prefix_length_def} None
28${invalid_staticv6_gateway} 9.41.164.1
Sweta Potthuri35c503b2025-07-27 23:36:20 -050029${linklocal_addr_format} fe80::[0-9a-f:]+$
Prashanth Katti8abbb4d2021-01-29 02:17:45 -060030
31*** Test Cases ***
32
33Get IPv6 Address And Verify
34 [Documentation] Get IPv6 Address And Verify.
35 [Tags] Get_IPv6_Address_And_Verify
36
37 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
38 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
39 END
40
41
Prashanth Katti2c73abc2021-03-17 07:42:25 -050042Get PrefixLength And Verify
43 [Documentation] Get IPv6 prefix length and verify.
44 [Tags] Get_PrefixLength_And_Verify
45
46 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
47 Verify IPv6 On BMC ${ipv6_network_configuration['PrefixLength']}
48 END
49
50
51Get IPv6 Default Gateway And Verify
George Keishing96143832021-03-23 07:55:08 -050052 [Documentation] Get IPv6 default gateway and verify.
George Keishingade6ab42022-07-19 11:41:03 -050053 [Tags] Get_IPv6_Default_Gateway_And_Verify
Prashanth Katti2c73abc2021-03-17 07:42:25 -050054
55 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
56 ${ipv6_gateway}= Get From Dictionary ${resp.dict} IPv6DefaultGateway
57 Verify IPv6 Default Gateway On BMC ${ipv6_gateway}
58
59
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050060Verify All Configured IPv6 And PrefixLength On BMC
61 [Documentation] Verify IPv6 address and its prefix length on BMC.
62 [Tags] Verify_All_Configured_IPv6_And_PrefixLength_On_BMC
63
64 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
George Keishingf02ca2b2023-04-05 22:11:03 +053065 Verify IPv6 And PrefixLength ${ipv6_network_configuration['Address']}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050066 ... ${ipv6_network_configuration['PrefixLength']}
67 END
68
69
70Configure IPv6 Address And Verify
71 [Documentation] Configure IPv6 address and verify.
72 [Tags] Configure_IPv6_Address_And_Verify
Anvesh-Kumar_Rayankula3a26c662025-04-16 01:19:26 -050073 [Teardown] Run Keywords
74 ... Delete IPv6 Address ${test_ipv6_addr} AND Test Teardown Execution
Prashanth Kattic1d2daa2022-07-26 03:53:06 -050075 [Template] Configure IPv6 Address On BMC
76
77
78 # IPv6 address Prefix length
79 ${test_ipv6_addr} ${test_prefix_length}
80
81
Prashanth Katti12ed4b72023-05-16 05:24:00 -050082Delete IPv6 Address And Verify
83 [Documentation] Delete IPv6 address and verify.
84 [Tags] Delete_IPv6_Address_And_Verify
85
86 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
87
88 Delete IPv6 Address ${test_ipv6_addr}
89
90
George Keishingcc288312024-10-22 10:13:12 +053091Modify IPv6 Address And Verify
Prashanth Katti5f7d2e42023-05-22 03:17:25 -050092 [Documentation] Modify IPv6 address and verify.
93 [Tags] Modify_IPv6_Address_And_Verify
kvishal88de8c42025-03-04 01:45:10 -060094 [Teardown] Run Keywords
George Keishingcfdd0992025-03-17 11:59:20 +053095 ... Delete IPv6 Address ${test_ipv6_addr1} AND Test Teardown Execution
Prashanth Katti5f7d2e42023-05-22 03:17:25 -050096
97 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
98
99 Modify IPv6 Address ${test_ipv6_addr} ${test_ipv6_addr1} ${test_prefix_length}
100
101
Sweta Potthuriafe858e2025-02-25 23:52:51 -0600102Verify Persistency Of IPv6 After BMC Reboot
103 [Documentation] Verify persistency of IPv6 after BMC reboot.
104 [Tags] Verify_Persistency_Of_IPv6_After_BMC_Reboot
105 [Teardown] Run Keywords
106 ... Delete IPv6 Address ${test_ipv6_addr} AND Test Teardown Execution
107
108 Configure IPv6 Address On BMC ${test_ipv6_addr} ${test_prefix_length}
109
110 Redfish OBMC Reboot (off) stack_mode=skip
111
112 # Verifying persistency of IPv6.
113 Verify IPv6 On BMC ${test_ipv6_addr}
114
115
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500116Enable SLAACv6 On BMC And Verify
117 [Documentation] Enable SLAACv6 on BMC and verify.
118 [Tags] Enable_SLAACv6_On_BMC_And_Verify
119
120 Set SLAACv6 Configuration State And Verify ${True}
121
122
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500123Enable DHCPv6 Property On BMC And Verify
124 [Documentation] Enable DHCPv6 property on BMC and verify.
125 [Tags] Enable_DHCPv6_Property_On_BMC_And_Verify
126
127 Set And Verify DHCPv6 Property Enabled
128
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500129
kvishal0d199a92025-05-29 02:35:18 -0500130Disable DHCPv6 Property On BMC And Verify
131 [Documentation] Disable DHCPv6 property on BMC and verify.
132 [Tags] Disable_DHCPv6_Property_On_BMC_And_Verify
133
134 Set And Verify DHCPv6 Property Disabled
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500135
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500136
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500137Configure Invalid Static IPv6 And Verify
138 [Documentation] Configure invalid static IPv6 and verify.
139 [Tags] Configure_Invalid_Static_IPv6_And_Verify
140 [Template] Configure IPv6 Address On BMC
141
142 #invalid_ipv6 prefix length valid_status_code
143 ${ipv4_hexword_addr} ${test_prefix_length} ${HTTP_BAD_REQUEST}
144
Sweta Potthuri565318d2025-06-09 06:13:46 -0500145
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500146Configure IPv6 Static Default Gateway And Verify
147 [Documentation] Configure IPv6 static default gateway and verify.
148 [Tags] Configure_IPv6_Static_Default_Gateway_And_Verify
149 [Template] Configure IPv6 Static Default Gateway On BMC
Sweta Potthuri565318d2025-06-09 06:13:46 -0500150
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500151 # static_def_gw prefix length valid_status_code
152 ${ipv6_gw_addr} ${prefix_length_def} ${HTTP_OK}
153 ${invalid_staticv6_gateway} ${test_prefix_length} ${HTTP_BAD_REQUEST}
Sweta Potthuri565318d2025-06-09 06:13:46 -0500154
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500155
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500156Modify Static Default Gateway And Verify
157 [Documentation] Modify static default gateway and verify.
158 [Tags] Modify_Static_Default_Gateway_And_Verify
159 [Setup] Configure IPv6 Static Default Gateway On BMC ${ipv6_gw_addr} ${prefix_length_def}
160
161 Modify IPv6 Static Default Gateway On BMC ${test_ipv6_addr1} ${prefix_length_def} ${HTTP_OK} ${ipv6_gw_addr}
162
163
Sweta Potthuri2d085732025-07-16 09:10:08 -0500164Delete IPv6 Static Default Gateway And Verify
165 [Documentation] Delete IPv6 static default gateway and verify.
166 [Tags] Delete_IPv6_Static_Default_Gateway_And_Verify
167 [Setup] Configure IPv6 Static Default Gateway On BMC ${ipv6_gw_addr} ${prefix_length_def}
168
169 Delete IPv6 Static Default Gateway ${ipv6_gw_addr}
170
171
Sweta Potthuri35c503b2025-07-27 23:36:20 -0500172Verify Coexistence Of Linklocalv6 And Static IPv6 On BMC
173 [Documentation] Verify linklocalv6 And static IPv6 both exist.
174 [Tags] Verify_Coexistence_Of_Linklocalv6_And_Static_IPv6_On_BMC
175 [Setup] Configure IPv6 Address On BMC ${IP_ADDR_TEST} ${test_prefix_length}
176 [Teardown] Delete IPv6 Address ${IP_ADDR_TEST}
177
178 Check Coexistence Of Linklocalv6 And Static IPv6
179
180
Sweta Potthuri3c6f97d2025-08-06 00:30:19 -0500181Verify IPv6 Linklocal Address Is In Corrrect Format
182 [Documentation] Verify linklocal address has network part as fe80 and host part as EUI64.
183 [Tags] Verify_IPv6_Linklocal_Address_Is_In_Correct_Format
184
185 Check If Linklocal Address Is In Correct Format
186
187
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600188*** Keywords ***
189
Prashanth Katti3270fd02021-06-11 08:02:22 -0500190Suite Setup Execution
191 [Documentation] Do suite setup execution.
192
193 ${active_channel_config}= Get Active Channel Config
Sweta Potthuri3c6f97d2025-08-06 00:30:19 -0500194 Set Suite Variable ${active_channel_config}
195
Prashanth Katti3270fd02021-06-11 08:02:22 -0500196 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
197
198 Set Suite variable ${ethernet_interface}
199
200
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600201Test Setup Execution
202 [Documentation] Test setup execution.
203
204 Redfish.Login
205
206 @{ipv6_network_configurations}= Get IPv6 Network Configuration
207 Set Test Variable @{ipv6_network_configurations}
208
209 # Get BMC IPv6 address and prefix length.
210 ${ipv6_data}= Get BMC IPv6 Info
211 Set Test Variable ${ipv6_data}
212
213
214Test Teardown Execution
215 [Documentation] Test teardown execution.
216
217 FFDC On Test Case Fail
218 Redfish.Logout
219
220
221Get IPv6 Network Configuration
222 [Documentation] Get Ipv6 network configuration.
223 # Sample output:
224 # {
ganesanb4d430282023-04-27 14:33:23 +0000225 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0",
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600226 # "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
227 # "DHCPv4": {
228 # "DHCPEnabled": false,
229 # "UseDNSServers": false,
230 # "UseDomainName": true,
231 # "UseNTPServers": false
232 # },
233 # "DHCPv6": {
234 # "OperatingMode": "Disabled",
235 # "UseDNSServers": false,
236 # "UseDomainName": true,
237 # "UseNTPServers": false
238 # },
239 # "Description": "Management Network Interface",
240 # "FQDN": "localhost",
241 # "HostName": "localhost",
242 # "IPv4Addresses": [
243 # {
244 # "Address": "xx.xx.xx.xx",
245 # "AddressOrigin": "Static",
246 # "Gateway": "xx.xx.xx.1",
247 # "SubnetMask": "xx.xx.xx.0"
248 # },
249 # {
250 # "Address": "169.254.xx.xx",
251 # "AddressOrigin": "IPv4LinkLocal",
252 # "Gateway": "0.0.0.0",
253 # "SubnetMask": "xx.xx.0.0"
254 # },
255 # ],
256 # "IPv4StaticAddresses": [
257 # {
258 # "Address": "xx.xx.xx.xx",
259 # "AddressOrigin": "Static",
260 # "Gateway": "xx.xx.xx.1",
261 # "SubnetMask": "xx.xx.0.0"
262 # }
263 # }
264 # ],
265 # "IPv6AddressPolicyTable": [],
266 # "IPv6Addresses": [
267 # {
268 # "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
269 # "AddressOrigin": "LinkLocal",
270 # "AddressState": null,
271 # "PrefixLength": xx
272 # }
273 # ],
274 # "IPv6DefaultGateway": "",
275 # "IPv6StaticAddresses": [
276 # { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
277 # "AddressOrigin": "Static",
278 # "AddressState": null,
279 # "PrefixLength": xxx
280 # }
281 # ],
282 # "Id": "eth0",
283 # "InterfaceEnabled": true,
284 # "LinkStatus": "LinkUp",
285 # "MACAddress": "xx:xx:xx:xx:xx:xx",
286 # "Name": "Manager Ethernet Interface",
287 # "NameServers": [],
288 # "SpeedMbps": 0,
289 # "StaticNameServers": [],
290 # "Status": {
291 # "Health": "OK",
292 # "HealthRollup": "OK",
293 # "State": "Enabled"
294 # },
295 # "VLANs": {
ganesanb4d430282023-04-27 14:33:23 +0000296 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs"
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600297
298
299 ${active_channel_config}= Get Active Channel Config
300 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
301
302 @{ipv6_network_configurations}= Get From Dictionary ${resp.dict} IPv6StaticAddresses
George Keishing409df052024-01-17 22:36:14 +0530303 RETURN @{ipv6_network_configurations}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500304
305
306Verify IPv6 And PrefixLength
307 [Documentation] Verify IPv6 address and prefix length on BMC.
308 [Arguments] ${ipv6_addr} ${prefix_len}
309
310 # Description of the argument(s):
311 # ipv6_addr IPv6 address to be verified.
312 # prefix_len PrefixLength value to be verified.
313
314 # Catenate IPv6 address and its prefix length.
315 ${ipv6_with_prefix}= Catenate ${ipv6_addr}/${prefix_len}
316
317 # Get IPv6 address details on BMC using IP command.
318 @{ip_data}= Get BMC IPv6 Info
319
320 # Verify if IPv6 and prefix length is configured on BMC.
321
322 Should Contain ${ip_data} ${ipv6_with_prefix}
323 ... msg=IPv6 and prefix length pair does not exist.
324
325
326Configure IPv6 Address On BMC
327 [Documentation] Add IPv6 Address on BMC.
328 [Arguments] ${ipv6_addr} ${prefix_len} ${valid_status_codes}=${HTTP_OK}
329
330 # Description of argument(s):
331 # ipv6_addr IPv6 address to be added (e.g. "2001:EEEE:2222::2022").
332 # prefix_len Prefix length for the IPv6 to be added
333 # (e.g. "64").
334 # valid_status_codes Expected return code from patch operation
335 # (e.g. "200").
336
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500337 ${prefix_length}= Convert To Integer ${prefix_len}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500338 ${empty_dict}= Create Dictionary
339 ${ipv6_data}= Create Dictionary Address=${ipv6_addr}
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500340 ... PrefixLength=${prefix_length}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500341
342 ${patch_list}= Create List
343
344 # Get existing static IPv6 configurations on BMC.
345 ${ipv6_network_configurations}= Get IPv6 Network Configuration
346 ${num_entries}= Get Length ${ipv6_network_configurations}
347
348 FOR ${INDEX} IN RANGE 0 ${num_entries}
349 Append To List ${patch_list} ${empty_dict}
350 END
351
George Keishinge6e161e2025-05-08 10:18:30 +0530352 ${valid_status_codes}= Set Variable If '${valid_status_codes}' == '${HTTP_OK}'
353 ... ${HTTP_OK},${HTTP_NO_CONTENT}
354 ... ${valid_status_codes}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500355
356 # We need not check for existence of IPv6 on BMC while adding.
357 Append To List ${patch_list} ${ipv6_data}
358 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
359
360 ${active_channel_config}= Get Active Channel Config
361 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
362
363 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
364 ... valid_status_codes=[${valid_status_codes}]
365
366 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
367
368 # Note: Network restart takes around 15-18s after patch request processing.
369 Sleep ${NETWORK_TIMEOUT}s
370 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
371
372 Verify IPv6 And PrefixLength ${ipv6_addr} ${prefix_len}
373
374 # Verify if existing static IPv6 addresses still exist.
375 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
376 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
377 END
378
379 Validate IPv6 Network Config On BMC
380
381
382Validate IPv6 Network Config On BMC
383 [Documentation] Check that IPv6 network info obtained via redfish matches info
384 ... obtained via CLI.
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500385 @{ipv6_network_configurations}= Get IPv6 Network Configuration
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500386 ${ipv6_data}= Get BMC IPv6 Info
387 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
388 Should Contain Match ${ipv6_data} ${ipv6_network_configuration['Address']}/*
389 ... msg=IPv6 address does not exist.
390 END
391
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500392
393Delete IPv6 Address
394 [Documentation] Delete IPv6 address of BMC.
Prashanth Kattibcb9dab2025-04-01 12:58:37 -0500395 [Arguments] ${ipv6_addr}
396 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500397
398 # Description of argument(s):
399 # ipv6_addr IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234").
400 # valid_status_codes Expected return code from patch operation
401 # (e.g. "200"). See prolog of rest_request
402 # method in redfish_plus.py for details.
403
404 ${empty_dict}= Create Dictionary
405 ${patch_list}= Create List
406
407 @{ipv6_network_configurations}= Get IPv6 Network Configuration
408 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
409 IF '${ipv6_network_configuration['Address']}' == '${ipv6_addr}'
410 Append To List ${patch_list} ${null}
411 ELSE
412 Append To List ${patch_list} ${empty_dict}
413 END
414 END
415
416 ${ip_found}= Run Keyword And Return Status List Should Contain Value
417 ... ${patch_list} ${null} msg=${ipv6_addr} does not exist on BMC
418 Pass Execution If ${ip_found} == ${False} ${ipv6_addr} does not exist on BMC
419
420 # Run patch command only if given IP is found on BMC
421 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
422
423 ${active_channel_config}= Get Active Channel Config
424 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
425
426 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
Sweta Potthuria1981612025-05-09 05:41:10 -0500427 ... valid_status_codes=${valid_status_codes}
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500428
429 # Note: Network restart takes around 15-18s after patch request processing
430 Sleep ${NETWORK_TIMEOUT}s
431 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
432
433 # IPv6 address that is deleted should not be there on BMC.
434 ${delete_status}= Run Keyword And Return Status Verify IPv6 On BMC ${ipv6_addr}
Anvesh-Kumar_Rayankula3a26c662025-04-16 01:19:26 -0500435 IF '${valid_status_codes}' == '[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]'
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500436 Should Be True '${delete_status}' == '${False}'
437 ELSE
438 Should Be True '${delete_status}' == '${True}'
439 END
440
441 Validate IPv6 Network Config On BMC
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500442
443
444Modify IPv6 Address
445 [Documentation] Modify and verify IPv6 address of BMC.
446 [Arguments] ${ipv6} ${new_ipv6} ${prefix_len}
447 ... ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
448
449 # Description of argument(s):
450 # ipv6 IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
451 # new_ipv6 New IPv6 address to be configured.
452 # prefix_len Prefix length value (Range 1 to 128).
453 # valid_status_codes Expected return code from patch operation
454 # (e.g. "200", "201").
455
456 ${empty_dict}= Create Dictionary
457 ${patch_list}= Create List
458 ${prefix_length}= Convert To Integer ${prefix_len}
459 ${ipv6_data}= Create Dictionary
460 ... Address=${new_ipv6} PrefixLength=${prefix_length}
461
462 # Sample IPv6 network configurations:
463 # "IPv6AddressPolicyTable": [],
464 # "IPv6Addresses": [
465 # {
466 # "Address": "X002:db8:0:2::XX0",
467 # "AddressOrigin": "DHCPv6",
468 # "PrefixLength": 128
469 # },
470 # {
471 # "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX",
472 # "AddressOrigin": "SLAAC",
473 # "PrefixLength": 64
474 # },
475 # {
476 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
477 # "AddressOrigin": "Static",
478 # "PrefixLength": 56
479 # },
480 # {
481 # "Address": “Z002:db8:0:2:a94:efff:fe82:5000",
482 # "AddressOrigin": "Static",
483 # "PrefixLength": 56
484 # },
485 # {
486 # "Address": “Xe80::a94:efff:YYYY:XXXX",
487 # "AddressOrigin": "LinkLocal",
488 # "PrefixLength": 64
489 # },
490 # {
491 # "Address": “X002:db8:1:2:eff:233:fee:546",
492 # "AddressOrigin": "Static",
493 # "PrefixLength": 56
494 # }
495 # ],
496 # "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”,
497 # "IPv6StaticAddresses": [
498 # {
499 # "Address": “X002:db8:0:2:a94:efff:fe82:5000",
500 # "PrefixLength": 56
501 # },
502 # {
503 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
504 # "PrefixLength": 56
505 # },
506 # {
507 # "Address": “Z002:db8:1:2:eff:233:fee:546",
508 # "PrefixLength": 56
509 # }
510 # ],
511 # "IPv6StaticDefaultGateways": [],
512
513 # Find the position of IPv6 address to be modified.
514 @{ipv6_network_configurations}= Get IPv6 Network Configuration
515 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
George Keishinge6e161e2025-05-08 10:18:30 +0530516 IF '${ipv6_network_configuration['Address']}' == '${ipv6}'
517 Append To List ${patch_list} ${ipv6_data}
518 ELSE
519 Append To List ${patch_list} ${empty_dict}
520 END
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500521 END
522
523 # Modify the IPv6 address only if given IPv6 is found
524 ${ip_found}= Run Keyword And Return Status List Should Contain Value
525 ... ${patch_list} ${ipv6_data} msg=${ipv6} does not exist on BMC
526 Pass Execution If ${ip_found} == ${False} ${ipv6} does not exist on BMC
527
528 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
529
530 ${active_channel_config}= Get Active Channel Config
531 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
532
533 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
534 ... body=&{data} valid_status_codes=${valid_status_codes}
535
536 # Note: Network restart takes around 15-18s after patch request processing.
537 Sleep ${NETWORK_TIMEOUT}s
538 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
539
540 # Verify if new IPv6 address is configured on BMC.
541 Verify IPv6 On BMC ${new_ipv6}
542
543 # Verify if old IPv6 address is erased.
544 ${cmd_status}= Run Keyword And Return Status
545 ... Verify IPv6 On BMC ${ipv6}
546 Should Be Equal ${cmd_status} ${False} msg=Old IPv6 address is not deleted.
547
548 Validate IPv6 Network Config On BMC
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500549
550
551Set SLAACv6 Configuration State And Verify
552 [Documentation] Set SLAACv6 configuration state and verify.
Sweta Potthuri610f86f2025-05-30 00:47:23 -0500553 [Arguments] ${slaac_state} ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500554
555 # Description of argument(s):
556 # slaac_state SLAACv6 state('True' or 'False').
557 # valid_status_code Expected valid status codes.
558
559 ${active_channel_config}= Get Active Channel Config
560 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
561
562 ${data}= Set Variable If ${slaac_state} == ${False} ${DISABLE_SLAAC} ${ENABLE_SLAAC}
563 ${resp}= Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Sweta Potthuri610f86f2025-05-30 00:47:23 -0500564 ... body=${data} valid_status_codes=${valid_status_codes}
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500565
566 # Verify SLAACv6 is set correctly.
567 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
568 ${slaac_verify}= Get From Dictionary ${resp.dict} StatelessAddressAutoConfig
569
George Keishinge6e161e2025-05-08 10:18:30 +0530570 IF '${slaac_verify['IPv6AutoConfigEnabled']}' != '${slaac_state}'
571 Fail msg=SLAACv6 not set properly.
572 END
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500573
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500574
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500575Set And Verify DHCPv6 Property
576 [Documentation] Set DHCPv6 attribute and verify.
577 [Arguments] ${dhcpv6_operating_mode}=${Disabled}
578
579 # Description of argument(s):
580 # dhcpv6_operating_mode Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled').
581
582 ${data}= Set Variable If '${dhcpv6_operating_mode}' == 'Disabled' ${DISABLE_DHCPv6} ${ENABLE_DHCPv6}
583 ${active_channel_config}= Get Active Channel Config
584 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
585
586 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
587 ... body=${data} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
588
589 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
590 ${dhcpv6_verify}= Get From Dictionary ${resp.dict} DHCPv6
591
592 Should Be Equal '${dhcpv6_verify['OperatingMode']}' '${dhcpv6_operating_mode}'
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500593
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500594
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500595Get IPv6 Static Default Gateway
596 [Documentation] Get IPv6 static default gateway.
597
598 ${active_channel_config}= Get Active Channel Config
599 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
600
601 @{ipv6_static_defgw_configurations}= Get From Dictionary ${resp.dict} IPv6StaticDefaultGateways
602 RETURN @{ipv6_static_defgw_configurations}
603
Sweta Potthuri2d085732025-07-16 09:10:08 -0500604
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500605Configure IPv6 Static Default Gateway On BMC
606 [Documentation] Configure IPv6 static default gateway on BMC.
607 [Arguments] ${ipv6_gw_addr} ${prefix_length_def}
608 ... ${valid_status_codes}=${HTTP_OK}
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500609 # Description of argument(s):
610 # ipv6_gw_addr IPv6 Static Default Gateway address to be configured.
611 # prefix_len_def Prefix length value (Range 1 to 128).
612 # valid_status_codes Expected return code from patch operation
613 # (e.g. "200", "204".)
614
615 # Prefix Length is passed as None.
616 IF '${prefix_length_def}' == '${None}'
617 ${ipv6_gw}= Create Dictionary Address=${ipv6_gw_addr}
618 ELSE
619 ${ipv6_gw}= Create Dictionary Address=${ipv6_gw_addr} Prefix Length=${prefix_length_def}
620 END
621
622 ${ipv6_static_def_gw}= Get IPv6 Static Default Gateway
623
624 ${num_entries}= Get Length ${ipv6_static_def_gw}
625
626 ${patch_list}= Create List
627 ${empty_dict}= Create Dictionary
628
629 FOR ${INDEX} IN RANGE 0 ${num_entries}
630 Append To List ${patch_list} ${empty_dict}
631 END
632
633 ${valid_status_codes}= Set Variable If '${valid_status_codes}' == '${HTTP_OK}'
634 ... ${HTTP_OK},${HTTP_NO_CONTENT}
635 ... ${valid_status_codes}
636
637 Append To List ${patch_list} ${ipv6_gw}
638 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
639
640 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
641 ... body=${data} valid_status_codes=[${valid_status_codes}]
642
643 # Verify the added static default gateway is present in Redfish Get Output.
644 ${ipv6_staticdef_gateway}= Get IPv6 Static Default Gateway
645
646 ${ipv6_static_def_gw_list}= Create List
647 FOR ${ipv6_staticdef_gateway} IN @{ipv6_staticdef_gateway}
648 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
649 Append To List ${ipv6_static_def_gw_list} ${value}
650 END
651
652 IF '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
653 Should Not Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
654 ELSE
655 Should Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
656 END
657
Sweta Potthuri2d085732025-07-16 09:10:08 -0500658
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500659Modify Static Default Gateway
660 [Documentation] Modify and verify IPv6 address of BMC.
661 [Arguments] ${ipv6_gw_addr} ${new_static_def_gw} ${prefix_length}
662 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED}]
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500663
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500664 # Description of argument(s):
665 # ipv6_gw_addr IPv6 static default gateway address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
666 # new_static_def_gw New static default gateway address to be configured.
667 # prefix length Prefix length value (Range 1 to 128).
668 # valid_status_codes Expected return code from patch operation
669 # (e.g. "200", "204").
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500670
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500671 ${empty_dict}= Create Dictionary
672 ${patch_list}= Create List
673 # Prefix Length is passed as None.
674 IF '${prefix_length_def}' == '${None}'
675 ${modified_ipv6_gw_addripv6_data}= Create Dictionary Address=${new_static_def_gw}
676 ELSE
677 ${modified_ipv6_gw_addripv6_data}= Create Dictionary Address=${new_static_def_gw} Prefix Length=${prefix_length_def}
678 END
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500679
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500680 @{ipv6_static_def_gw_list}= Get IPv6 Static Default Gateway
681
682 FOR ${ipv6_static_def_gw} IN @{ipv6_static_def_gw_list}
683 IF '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
684 Append To List ${patch_list} ${modified_ipv6_gw_addripv6_data}
685 ELSE
686 Append To List ${patch_list} ${empty_dict}
687 END
688 END
689
690 # Modify the IPv6 address only if given IPv6 static default gateway is found.
691 ${ip_static_def_gw_found}= Run Keyword And Return Status List Should Contain Value
692 ... ${patch_list} ${modified_ipv6_gw_addripv6_data} msg=${ipv6_gw_addr} does not exist on BMC
693 Pass Execution If ${ip_static_def_gw_found} == ${False} ${ipv6_gw_addr} does not exist on BMC
694
695 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
696
697 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
698 ... body=&{data} valid_status_codes=${valid_status_codes}
699
700 ${ipv6_staticdef_gateway}= Get IPv6 Static Default Gateway
701
702 ${ipv6_static_def_gw_list}= Create List
703 FOR ${ipv6_staticdef_gateway} IN @{ipv6_staticdef_gateway}
Sweta Potthuri2d085732025-07-16 09:10:08 -0500704 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500705 Append To List ${ipv6_static_def_gw_list} ${value}
706 END
707
708 Should Contain ${ipv6_static_def_gw_list} ${new_static_def_gw}
709 # Verify if old static default gateway address is erased.
710 Should Not Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
711
Sweta Potthuri2d085732025-07-16 09:10:08 -0500712
713Delete IPv6 Static Default Gateway
714 [Documentation] Delete IPv6 static default gateway on BMC.
715 [Arguments] ${ipv6_gw_addr}
716 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
717
718 # Description of argument(s):
719 # ipv6_gw_addr IPv6 Static Default Gateway address to be deleted.
720 # valid_status_codes Expected return code from patch operation
721 # (e.g. "200").
722
723 ${patch_list}= Create List
724 ${empty_dict}= Create Dictionary
725
726 ${ipv6_static_def_gw_list}= Create List
727 @{ipv6_static_defgw_configurations}= Get IPv6 Static Default Gateway
728
729 FOR ${ipv6_staticdef_gateway} IN @{ipv6_static_defgw_configurations}
730 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
731 Append To List ${ipv6_static_def_gw_list} ${value}
732 END
733
734 ${defgw_found}= Run Keyword And Return Status List Should Contain Value
735 ... ${ipv6_static_def_gw_list} ${ipv6_gw_addr} msg=${ipv6_gw_addr} does not exist on BMC
736 Skip If ${defgw_found} == ${False} ${ipv6_gw_addr} does not exist on BMC
737
738 FOR ${ipv6_static_def_gw} IN @{ipv6_static_defgw_configurations}
739 IF '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
740 Append To List ${patch_list} ${null}
741 ELSE
742 Append To List ${patch_list} ${empty_dict}
743 END
744 END
745
746 # Run patch command only if given IP is found on BMC.
747 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
748
749 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
750 ... valid_status_codes=${valid_status_codes}
751
752 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
753
754 @{ipv6_static_defgw_configurations}= Get IPv6 Static Default Gateway
755 Should Not Contain Match ${ipv6_static_defgw_configurations} ${ipv6_gw_addr}
756 ... msg=IPv6 Static default gateway does not exist.
Sweta Potthuri35c503b2025-07-27 23:36:20 -0500757
758
759Check Coexistence Of Linklocalv6 And Static IPv6
760 [Documentation] Verify both linklocalv6 and static IPv6 exist.
761
762 ${active_channel_config}= Get Active Channel Config
763 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
764
765 # Verify the address origin contains static and linklocal.
766 @{ipv6_addresses}= Get From Dictionary ${resp.dict} IPv6Addresses
767 ${ipv6_linklocal_addr}= Set Variable ${None}
768 ${ipv6_static_addr}= Set Variable ${None}
769 ${ipv6_addressorigin_list}= Create List
770
771 FOR ${ipv6_address} IN @{ipv6_addresses}
772 ${ipv6_addressorigin}= Get From Dictionary ${ipv6_address} AddressOrigin
773 IF '${ipv6_addressorigin}' == 'LinkLocal'
774 Set Test Variable ${ipv6_linklocal_addr} ${ipv6_address['Address']}
775 END
776 Append To List ${ipv6_addressorigin_list} ${ipv6_addressorigin}
777 END
778
779 Should Match Regexp ${ipv6_linklocal_addr} ${linklocal_addr_format}
780 Should Contain ${ipv6_addressorigin_list} LinkLocal
781 Should Contain ${ipv6_addressorigin_list} Static
Sweta Potthuri3c6f97d2025-08-06 00:30:19 -0500782
783
784Check If Linklocal Address Is In Correct Format
785 [Documentation] Linklocal address has network part fe80 and host part EUI64.
786
787 # Fetch the linklocal address.
788 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
789
790 @{ipv6_addresses}= Get From Dictionary ${resp.dict} IPv6Addresses
791 ${ipv6_linklocal_addr}= Set Variable ${None}
792 ${ipv6_addressorigin_list}= Create List
793 FOR ${ipv6_address} IN @{ipv6_addresses}
794 ${ipv6_addressorigin}= Get From Dictionary ${ipv6_address} AddressOrigin
795 IF '${ipv6_addressorigin}' == 'LinkLocal'
796 Set Test Variable ${ipv6_linklocal_addr} ${ipv6_address['Address']}
797 END
798 END
799
800 # Follow EUI64 from MAC.
801 ${system_mac}= Get BMC MAC Address
802 ${split_octets}= Split String ${system_mac} :
803 ${first_octet}= Evaluate int('${split_octets[0]}', 16)
804 ${flipped_hex}= Evaluate format(${first_octet} ^ 2, '02x')
805 ${grp1}= Evaluate re.sub(r'^0+', '', '${flipped_hex}${split_octets[1]}') modules=re
806 ${grp2}= Evaluate re.sub(r'^0+', '', '${split_octets[2]}ff') modules=re
807 ${grp3}= Evaluate re.sub(r'^0+', '', '${split_octets[4]}${split_octets[5]}') modules=re
808 ${linklocal}= Set Variable fe80::${grp1}:${grp2}:fe${split_octets[3]}:${grp3}
809
810 # Verify the linklocal obtained is the same as on the machine.
811 Should Be Equal ${linklocal} ${ipv6_linklocal_addr}
812