blob: 1554e1aea248c818cfe55a3d4832ab601be83214 [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
kvishalbd04bd62025-08-05 03:57:53 -0500127 Set DHCPv6 Property Enabled
128 Verify DHCPv6 Property Enabled
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500129
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500130
kvishal0d199a92025-05-29 02:35:18 -0500131Disable DHCPv6 Property On BMC And Verify
132 [Documentation] Disable DHCPv6 property on BMC and verify.
133 [Tags] Disable_DHCPv6_Property_On_BMC_And_Verify
134
kvishalbd04bd62025-08-05 03:57:53 -0500135 Set DHCPv6 Property Disabled
136 Verify DHCPv6 Property Disabled
137
138
139Verify Persistency Of DHCPv6 On Reboot
140 [Documentation] Verify persistency of DHCPv6 property on reboot.
141 [Tags] Verify_Persistency_Of_DHCPv6_On_Reboot
142
143 Set DHCPv6 Property Enabled
144 Redfish OBMC Reboot (off) stack_mode=skip
145 Verify DHCPv6 Property Enabled
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500146
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500147
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500148Configure Invalid Static IPv6 And Verify
149 [Documentation] Configure invalid static IPv6 and verify.
150 [Tags] Configure_Invalid_Static_IPv6_And_Verify
151 [Template] Configure IPv6 Address On BMC
152
153 #invalid_ipv6 prefix length valid_status_code
154 ${ipv4_hexword_addr} ${test_prefix_length} ${HTTP_BAD_REQUEST}
155
Sweta Potthuri565318d2025-06-09 06:13:46 -0500156
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500157Configure IPv6 Static Default Gateway And Verify
158 [Documentation] Configure IPv6 static default gateway and verify.
159 [Tags] Configure_IPv6_Static_Default_Gateway_And_Verify
160 [Template] Configure IPv6 Static Default Gateway On BMC
Sweta Potthuri565318d2025-06-09 06:13:46 -0500161
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500162 # static_def_gw prefix length valid_status_code
163 ${ipv6_gw_addr} ${prefix_length_def} ${HTTP_OK}
164 ${invalid_staticv6_gateway} ${test_prefix_length} ${HTTP_BAD_REQUEST}
Sweta Potthuri565318d2025-06-09 06:13:46 -0500165
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500166
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500167Modify Static Default Gateway And Verify
168 [Documentation] Modify static default gateway and verify.
169 [Tags] Modify_Static_Default_Gateway_And_Verify
170 [Setup] Configure IPv6 Static Default Gateway On BMC ${ipv6_gw_addr} ${prefix_length_def}
171
172 Modify IPv6 Static Default Gateway On BMC ${test_ipv6_addr1} ${prefix_length_def} ${HTTP_OK} ${ipv6_gw_addr}
173
174
Sweta Potthuri2d085732025-07-16 09:10:08 -0500175Delete IPv6 Static Default Gateway And Verify
176 [Documentation] Delete IPv6 static default gateway and verify.
177 [Tags] Delete_IPv6_Static_Default_Gateway_And_Verify
178 [Setup] Configure IPv6 Static Default Gateway On BMC ${ipv6_gw_addr} ${prefix_length_def}
179
180 Delete IPv6 Static Default Gateway ${ipv6_gw_addr}
181
182
Sweta Potthuri35c503b2025-07-27 23:36:20 -0500183Verify Coexistence Of Linklocalv6 And Static IPv6 On BMC
184 [Documentation] Verify linklocalv6 And static IPv6 both exist.
185 [Tags] Verify_Coexistence_Of_Linklocalv6_And_Static_IPv6_On_BMC
186 [Setup] Configure IPv6 Address On BMC ${IP_ADDR_TEST} ${test_prefix_length}
187 [Teardown] Delete IPv6 Address ${IP_ADDR_TEST}
188
189 Check Coexistence Of Linklocalv6 And Static IPv6
190
191
Sweta Potthuri3c6f97d2025-08-06 00:30:19 -0500192Verify IPv6 Linklocal Address Is In Corrrect Format
193 [Documentation] Verify linklocal address has network part as fe80 and host part as EUI64.
194 [Tags] Verify_IPv6_Linklocal_Address_Is_In_Correct_Format
195
196 Check If Linklocal Address Is In Correct Format
197
198
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600199*** Keywords ***
200
Prashanth Katti3270fd02021-06-11 08:02:22 -0500201Suite Setup Execution
202 [Documentation] Do suite setup execution.
203
204 ${active_channel_config}= Get Active Channel Config
Sweta Potthuri3c6f97d2025-08-06 00:30:19 -0500205 Set Suite Variable ${active_channel_config}
206
Prashanth Katti3270fd02021-06-11 08:02:22 -0500207 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
208
209 Set Suite variable ${ethernet_interface}
210
211
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600212Test Setup Execution
213 [Documentation] Test setup execution.
214
215 Redfish.Login
216
217 @{ipv6_network_configurations}= Get IPv6 Network Configuration
218 Set Test Variable @{ipv6_network_configurations}
219
220 # Get BMC IPv6 address and prefix length.
221 ${ipv6_data}= Get BMC IPv6 Info
222 Set Test Variable ${ipv6_data}
223
224
225Test Teardown Execution
226 [Documentation] Test teardown execution.
227
228 FFDC On Test Case Fail
229 Redfish.Logout
230
231
232Get IPv6 Network Configuration
233 [Documentation] Get Ipv6 network configuration.
234 # Sample output:
235 # {
ganesanb4d430282023-04-27 14:33:23 +0000236 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0",
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600237 # "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
238 # "DHCPv4": {
239 # "DHCPEnabled": false,
240 # "UseDNSServers": false,
241 # "UseDomainName": true,
242 # "UseNTPServers": false
243 # },
244 # "DHCPv6": {
245 # "OperatingMode": "Disabled",
246 # "UseDNSServers": false,
247 # "UseDomainName": true,
248 # "UseNTPServers": false
249 # },
250 # "Description": "Management Network Interface",
251 # "FQDN": "localhost",
252 # "HostName": "localhost",
253 # "IPv4Addresses": [
254 # {
255 # "Address": "xx.xx.xx.xx",
256 # "AddressOrigin": "Static",
257 # "Gateway": "xx.xx.xx.1",
258 # "SubnetMask": "xx.xx.xx.0"
259 # },
260 # {
261 # "Address": "169.254.xx.xx",
262 # "AddressOrigin": "IPv4LinkLocal",
263 # "Gateway": "0.0.0.0",
264 # "SubnetMask": "xx.xx.0.0"
265 # },
266 # ],
267 # "IPv4StaticAddresses": [
268 # {
269 # "Address": "xx.xx.xx.xx",
270 # "AddressOrigin": "Static",
271 # "Gateway": "xx.xx.xx.1",
272 # "SubnetMask": "xx.xx.0.0"
273 # }
274 # }
275 # ],
276 # "IPv6AddressPolicyTable": [],
277 # "IPv6Addresses": [
278 # {
279 # "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
280 # "AddressOrigin": "LinkLocal",
281 # "AddressState": null,
282 # "PrefixLength": xx
283 # }
284 # ],
285 # "IPv6DefaultGateway": "",
286 # "IPv6StaticAddresses": [
287 # { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
288 # "AddressOrigin": "Static",
289 # "AddressState": null,
290 # "PrefixLength": xxx
291 # }
292 # ],
293 # "Id": "eth0",
294 # "InterfaceEnabled": true,
295 # "LinkStatus": "LinkUp",
296 # "MACAddress": "xx:xx:xx:xx:xx:xx",
297 # "Name": "Manager Ethernet Interface",
298 # "NameServers": [],
299 # "SpeedMbps": 0,
300 # "StaticNameServers": [],
301 # "Status": {
302 # "Health": "OK",
303 # "HealthRollup": "OK",
304 # "State": "Enabled"
305 # },
306 # "VLANs": {
ganesanb4d430282023-04-27 14:33:23 +0000307 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs"
Prashanth Katti8abbb4d2021-01-29 02:17:45 -0600308
309
310 ${active_channel_config}= Get Active Channel Config
311 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
312
313 @{ipv6_network_configurations}= Get From Dictionary ${resp.dict} IPv6StaticAddresses
George Keishing409df052024-01-17 22:36:14 +0530314 RETURN @{ipv6_network_configurations}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500315
316
317Verify IPv6 And PrefixLength
318 [Documentation] Verify IPv6 address and prefix length on BMC.
319 [Arguments] ${ipv6_addr} ${prefix_len}
320
321 # Description of the argument(s):
322 # ipv6_addr IPv6 address to be verified.
323 # prefix_len PrefixLength value to be verified.
324
325 # Catenate IPv6 address and its prefix length.
326 ${ipv6_with_prefix}= Catenate ${ipv6_addr}/${prefix_len}
327
328 # Get IPv6 address details on BMC using IP command.
329 @{ip_data}= Get BMC IPv6 Info
330
331 # Verify if IPv6 and prefix length is configured on BMC.
332
333 Should Contain ${ip_data} ${ipv6_with_prefix}
334 ... msg=IPv6 and prefix length pair does not exist.
335
336
337Configure IPv6 Address On BMC
338 [Documentation] Add IPv6 Address on BMC.
339 [Arguments] ${ipv6_addr} ${prefix_len} ${valid_status_codes}=${HTTP_OK}
340
341 # Description of argument(s):
342 # ipv6_addr IPv6 address to be added (e.g. "2001:EEEE:2222::2022").
343 # prefix_len Prefix length for the IPv6 to be added
344 # (e.g. "64").
345 # valid_status_codes Expected return code from patch operation
346 # (e.g. "200").
347
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500348 ${prefix_length}= Convert To Integer ${prefix_len}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500349 ${empty_dict}= Create Dictionary
350 ${ipv6_data}= Create Dictionary Address=${ipv6_addr}
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500351 ... PrefixLength=${prefix_length}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500352
353 ${patch_list}= Create List
354
355 # Get existing static IPv6 configurations on BMC.
356 ${ipv6_network_configurations}= Get IPv6 Network Configuration
357 ${num_entries}= Get Length ${ipv6_network_configurations}
358
359 FOR ${INDEX} IN RANGE 0 ${num_entries}
360 Append To List ${patch_list} ${empty_dict}
361 END
362
George Keishinge6e161e2025-05-08 10:18:30 +0530363 ${valid_status_codes}= Set Variable If '${valid_status_codes}' == '${HTTP_OK}'
364 ... ${HTTP_OK},${HTTP_NO_CONTENT}
365 ... ${valid_status_codes}
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500366
367 # We need not check for existence of IPv6 on BMC while adding.
368 Append To List ${patch_list} ${ipv6_data}
369 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
370
371 ${active_channel_config}= Get Active Channel Config
372 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
373
374 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
375 ... valid_status_codes=[${valid_status_codes}]
376
377 Return From Keyword If '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
378
379 # Note: Network restart takes around 15-18s after patch request processing.
380 Sleep ${NETWORK_TIMEOUT}s
381 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
382
383 Verify IPv6 And PrefixLength ${ipv6_addr} ${prefix_len}
384
385 # Verify if existing static IPv6 addresses still exist.
386 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
387 Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
388 END
389
390 Validate IPv6 Network Config On BMC
391
392
393Validate IPv6 Network Config On BMC
394 [Documentation] Check that IPv6 network info obtained via redfish matches info
395 ... obtained via CLI.
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500396 @{ipv6_network_configurations}= Get IPv6 Network Configuration
Prashanth Kattic1d2daa2022-07-26 03:53:06 -0500397 ${ipv6_data}= Get BMC IPv6 Info
398 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
399 Should Contain Match ${ipv6_data} ${ipv6_network_configuration['Address']}/*
400 ... msg=IPv6 address does not exist.
401 END
402
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500403
404Delete IPv6 Address
405 [Documentation] Delete IPv6 address of BMC.
Prashanth Kattibcb9dab2025-04-01 12:58:37 -0500406 [Arguments] ${ipv6_addr}
407 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500408
409 # Description of argument(s):
410 # ipv6_addr IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234").
411 # valid_status_codes Expected return code from patch operation
412 # (e.g. "200"). See prolog of rest_request
413 # method in redfish_plus.py for details.
414
415 ${empty_dict}= Create Dictionary
416 ${patch_list}= Create List
417
418 @{ipv6_network_configurations}= Get IPv6 Network Configuration
419 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
420 IF '${ipv6_network_configuration['Address']}' == '${ipv6_addr}'
421 Append To List ${patch_list} ${null}
422 ELSE
423 Append To List ${patch_list} ${empty_dict}
424 END
425 END
426
427 ${ip_found}= Run Keyword And Return Status List Should Contain Value
428 ... ${patch_list} ${null} msg=${ipv6_addr} does not exist on BMC
429 Pass Execution If ${ip_found} == ${False} ${ipv6_addr} does not exist on BMC
430
431 # Run patch command only if given IP is found on BMC
432 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
433
434 ${active_channel_config}= Get Active Channel Config
435 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
436
437 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
Sweta Potthuria1981612025-05-09 05:41:10 -0500438 ... valid_status_codes=${valid_status_codes}
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500439
440 # Note: Network restart takes around 15-18s after patch request processing
441 Sleep ${NETWORK_TIMEOUT}s
442 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
443
444 # IPv6 address that is deleted should not be there on BMC.
445 ${delete_status}= Run Keyword And Return Status Verify IPv6 On BMC ${ipv6_addr}
Anvesh-Kumar_Rayankula3a26c662025-04-16 01:19:26 -0500446 IF '${valid_status_codes}' == '[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]'
Prashanth Katti12ed4b72023-05-16 05:24:00 -0500447 Should Be True '${delete_status}' == '${False}'
448 ELSE
449 Should Be True '${delete_status}' == '${True}'
450 END
451
452 Validate IPv6 Network Config On BMC
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500453
454
455Modify IPv6 Address
456 [Documentation] Modify and verify IPv6 address of BMC.
457 [Arguments] ${ipv6} ${new_ipv6} ${prefix_len}
458 ... ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
459
460 # Description of argument(s):
461 # ipv6 IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
462 # new_ipv6 New IPv6 address to be configured.
463 # prefix_len Prefix length value (Range 1 to 128).
464 # valid_status_codes Expected return code from patch operation
465 # (e.g. "200", "201").
466
467 ${empty_dict}= Create Dictionary
468 ${patch_list}= Create List
469 ${prefix_length}= Convert To Integer ${prefix_len}
470 ${ipv6_data}= Create Dictionary
471 ... Address=${new_ipv6} PrefixLength=${prefix_length}
472
473 # Sample IPv6 network configurations:
474 # "IPv6AddressPolicyTable": [],
475 # "IPv6Addresses": [
476 # {
477 # "Address": "X002:db8:0:2::XX0",
478 # "AddressOrigin": "DHCPv6",
479 # "PrefixLength": 128
480 # },
481 # {
482 # "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX",
483 # "AddressOrigin": "SLAAC",
484 # "PrefixLength": 64
485 # },
486 # {
487 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
488 # "AddressOrigin": "Static",
489 # "PrefixLength": 56
490 # },
491 # {
492 # "Address": “Z002:db8:0:2:a94:efff:fe82:5000",
493 # "AddressOrigin": "Static",
494 # "PrefixLength": 56
495 # },
496 # {
497 # "Address": “Xe80::a94:efff:YYYY:XXXX",
498 # "AddressOrigin": "LinkLocal",
499 # "PrefixLength": 64
500 # },
501 # {
502 # "Address": “X002:db8:1:2:eff:233:fee:546",
503 # "AddressOrigin": "Static",
504 # "PrefixLength": 56
505 # }
506 # ],
507 # "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”,
508 # "IPv6StaticAddresses": [
509 # {
510 # "Address": “X002:db8:0:2:a94:efff:fe82:5000",
511 # "PrefixLength": 56
512 # },
513 # {
514 # "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
515 # "PrefixLength": 56
516 # },
517 # {
518 # "Address": “Z002:db8:1:2:eff:233:fee:546",
519 # "PrefixLength": 56
520 # }
521 # ],
522 # "IPv6StaticDefaultGateways": [],
523
524 # Find the position of IPv6 address to be modified.
525 @{ipv6_network_configurations}= Get IPv6 Network Configuration
526 FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
George Keishinge6e161e2025-05-08 10:18:30 +0530527 IF '${ipv6_network_configuration['Address']}' == '${ipv6}'
528 Append To List ${patch_list} ${ipv6_data}
529 ELSE
530 Append To List ${patch_list} ${empty_dict}
531 END
Prashanth Katti5f7d2e42023-05-22 03:17:25 -0500532 END
533
534 # Modify the IPv6 address only if given IPv6 is found
535 ${ip_found}= Run Keyword And Return Status List Should Contain Value
536 ... ${patch_list} ${ipv6_data} msg=${ipv6} does not exist on BMC
537 Pass Execution If ${ip_found} == ${False} ${ipv6} does not exist on BMC
538
539 ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
540
541 ${active_channel_config}= Get Active Channel Config
542 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
543
544 Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
545 ... body=&{data} valid_status_codes=${valid_status_codes}
546
547 # Note: Network restart takes around 15-18s after patch request processing.
548 Sleep ${NETWORK_TIMEOUT}s
549 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
550
551 # Verify if new IPv6 address is configured on BMC.
552 Verify IPv6 On BMC ${new_ipv6}
553
554 # Verify if old IPv6 address is erased.
555 ${cmd_status}= Run Keyword And Return Status
556 ... Verify IPv6 On BMC ${ipv6}
557 Should Be Equal ${cmd_status} ${False} msg=Old IPv6 address is not deleted.
558
559 Validate IPv6 Network Config On BMC
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500560
561
562Set SLAACv6 Configuration State And Verify
563 [Documentation] Set SLAACv6 configuration state and verify.
Sweta Potthuri610f86f2025-05-30 00:47:23 -0500564 [Arguments] ${slaac_state} ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500565
566 # Description of argument(s):
567 # slaac_state SLAACv6 state('True' or 'False').
568 # valid_status_code Expected valid status codes.
569
570 ${active_channel_config}= Get Active Channel Config
571 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
572
573 ${data}= Set Variable If ${slaac_state} == ${False} ${DISABLE_SLAAC} ${ENABLE_SLAAC}
574 ${resp}= Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Sweta Potthuri610f86f2025-05-30 00:47:23 -0500575 ... body=${data} valid_status_codes=${valid_status_codes}
Sweta Potthuri8ba74322025-03-19 12:29:06 -0500576
577 # Verify SLAACv6 is set correctly.
578 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
579 ${slaac_verify}= Get From Dictionary ${resp.dict} StatelessAddressAutoConfig
580
George Keishinge6e161e2025-05-08 10:18:30 +0530581 IF '${slaac_verify['IPv6AutoConfigEnabled']}' != '${slaac_state}'
582 Fail msg=SLAACv6 not set properly.
583 END
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500584
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500585
kvishalbd04bd62025-08-05 03:57:53 -0500586Set DHCPv6 Property
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500587 [Documentation] Set DHCPv6 attribute and verify.
588 [Arguments] ${dhcpv6_operating_mode}=${Disabled}
589
590 # Description of argument(s):
591 # dhcpv6_operating_mode Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled').
592
593 ${data}= Set Variable If '${dhcpv6_operating_mode}' == 'Disabled' ${DISABLE_DHCPv6} ${ENABLE_DHCPv6}
594 ${active_channel_config}= Get Active Channel Config
595 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
596
597 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
598 ... body=${data} valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
599
kvishalbd04bd62025-08-05 03:57:53 -0500600
601Verify DHCPv6 Property
602 [Documentation] Verify DHCPv6 settings is enabled or disabled.
603 [Arguments] ${dhcpv6_operating_mode}
604
605 # Description of Argument(s):
606 # dhcpv6_operating_mode Enable/ Disable DHCPv6.
607
Sweta Potthuri0df4a862025-03-24 12:05:09 -0500608 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
609 ${dhcpv6_verify}= Get From Dictionary ${resp.dict} DHCPv6
610
611 Should Be Equal '${dhcpv6_verify['OperatingMode']}' '${dhcpv6_operating_mode}'
Sweta Potthuricb61ff02025-04-09 05:16:09 -0500612
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500613
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500614Get IPv6 Static Default Gateway
615 [Documentation] Get IPv6 static default gateway.
616
617 ${active_channel_config}= Get Active Channel Config
618 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
619
620 @{ipv6_static_defgw_configurations}= Get From Dictionary ${resp.dict} IPv6StaticDefaultGateways
621 RETURN @{ipv6_static_defgw_configurations}
622
Sweta Potthuri2d085732025-07-16 09:10:08 -0500623
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500624Configure IPv6 Static Default Gateway On BMC
625 [Documentation] Configure IPv6 static default gateway on BMC.
626 [Arguments] ${ipv6_gw_addr} ${prefix_length_def}
627 ... ${valid_status_codes}=${HTTP_OK}
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500628 # Description of argument(s):
629 # ipv6_gw_addr IPv6 Static Default Gateway address to be configured.
630 # prefix_len_def Prefix length value (Range 1 to 128).
631 # valid_status_codes Expected return code from patch operation
632 # (e.g. "200", "204".)
633
634 # Prefix Length is passed as None.
635 IF '${prefix_length_def}' == '${None}'
636 ${ipv6_gw}= Create Dictionary Address=${ipv6_gw_addr}
637 ELSE
638 ${ipv6_gw}= Create Dictionary Address=${ipv6_gw_addr} Prefix Length=${prefix_length_def}
639 END
640
641 ${ipv6_static_def_gw}= Get IPv6 Static Default Gateway
642
643 ${num_entries}= Get Length ${ipv6_static_def_gw}
644
645 ${patch_list}= Create List
646 ${empty_dict}= Create Dictionary
647
648 FOR ${INDEX} IN RANGE 0 ${num_entries}
649 Append To List ${patch_list} ${empty_dict}
650 END
651
652 ${valid_status_codes}= Set Variable If '${valid_status_codes}' == '${HTTP_OK}'
653 ... ${HTTP_OK},${HTTP_NO_CONTENT}
654 ... ${valid_status_codes}
655
656 Append To List ${patch_list} ${ipv6_gw}
657 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
658
659 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
660 ... body=${data} valid_status_codes=[${valid_status_codes}]
661
662 # Verify the added static default gateway is present in Redfish Get Output.
663 ${ipv6_staticdef_gateway}= Get IPv6 Static Default Gateway
664
665 ${ipv6_static_def_gw_list}= Create List
666 FOR ${ipv6_staticdef_gateway} IN @{ipv6_staticdef_gateway}
667 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
668 Append To List ${ipv6_static_def_gw_list} ${value}
669 END
670
671 IF '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
672 Should Not Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
673 ELSE
674 Should Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
675 END
676
Sweta Potthuri2d085732025-07-16 09:10:08 -0500677
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500678Modify Static Default Gateway
679 [Documentation] Modify and verify IPv6 address of BMC.
680 [Arguments] ${ipv6_gw_addr} ${new_static_def_gw} ${prefix_length}
681 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED}]
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500682
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500683 # Description of argument(s):
684 # ipv6_gw_addr IPv6 static default gateway address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
685 # new_static_def_gw New static default gateway address to be configured.
686 # prefix length Prefix length value (Range 1 to 128).
687 # valid_status_codes Expected return code from patch operation
688 # (e.g. "200", "204").
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500689
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500690 ${empty_dict}= Create Dictionary
691 ${patch_list}= Create List
692 # Prefix Length is passed as None.
693 IF '${prefix_length_def}' == '${None}'
694 ${modified_ipv6_gw_addripv6_data}= Create Dictionary Address=${new_static_def_gw}
695 ELSE
696 ${modified_ipv6_gw_addripv6_data}= Create Dictionary Address=${new_static_def_gw} Prefix Length=${prefix_length_def}
697 END
Sweta Potthuri2edacd32025-07-02 01:04:43 -0500698
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500699 @{ipv6_static_def_gw_list}= Get IPv6 Static Default Gateway
700
701 FOR ${ipv6_static_def_gw} IN @{ipv6_static_def_gw_list}
702 IF '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
703 Append To List ${patch_list} ${modified_ipv6_gw_addripv6_data}
704 ELSE
705 Append To List ${patch_list} ${empty_dict}
706 END
707 END
708
709 # Modify the IPv6 address only if given IPv6 static default gateway is found.
710 ${ip_static_def_gw_found}= Run Keyword And Return Status List Should Contain Value
711 ... ${patch_list} ${modified_ipv6_gw_addripv6_data} msg=${ipv6_gw_addr} does not exist on BMC
712 Pass Execution If ${ip_static_def_gw_found} == ${False} ${ipv6_gw_addr} does not exist on BMC
713
714 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
715
716 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
717 ... body=&{data} valid_status_codes=${valid_status_codes}
718
719 ${ipv6_staticdef_gateway}= Get IPv6 Static Default Gateway
720
721 ${ipv6_static_def_gw_list}= Create List
722 FOR ${ipv6_staticdef_gateway} IN @{ipv6_staticdef_gateway}
Sweta Potthuri2d085732025-07-16 09:10:08 -0500723 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
Sweta Potthuri4b0083f2025-07-09 11:34:40 -0500724 Append To List ${ipv6_static_def_gw_list} ${value}
725 END
726
727 Should Contain ${ipv6_static_def_gw_list} ${new_static_def_gw}
728 # Verify if old static default gateway address is erased.
729 Should Not Contain ${ipv6_static_def_gw_list} ${ipv6_gw_addr}
730
Sweta Potthuri2d085732025-07-16 09:10:08 -0500731
732Delete IPv6 Static Default Gateway
733 [Documentation] Delete IPv6 static default gateway on BMC.
734 [Arguments] ${ipv6_gw_addr}
735 ... ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
736
737 # Description of argument(s):
738 # ipv6_gw_addr IPv6 Static Default Gateway address to be deleted.
739 # valid_status_codes Expected return code from patch operation
740 # (e.g. "200").
741
742 ${patch_list}= Create List
743 ${empty_dict}= Create Dictionary
744
745 ${ipv6_static_def_gw_list}= Create List
746 @{ipv6_static_defgw_configurations}= Get IPv6 Static Default Gateway
747
748 FOR ${ipv6_staticdef_gateway} IN @{ipv6_static_defgw_configurations}
749 ${value}= Get From Dictionary ${ipv6_staticdef_gateway} Address
750 Append To List ${ipv6_static_def_gw_list} ${value}
751 END
752
753 ${defgw_found}= Run Keyword And Return Status List Should Contain Value
754 ... ${ipv6_static_def_gw_list} ${ipv6_gw_addr} msg=${ipv6_gw_addr} does not exist on BMC
755 Skip If ${defgw_found} == ${False} ${ipv6_gw_addr} does not exist on BMC
756
757 FOR ${ipv6_static_def_gw} IN @{ipv6_static_defgw_configurations}
758 IF '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
759 Append To List ${patch_list} ${null}
760 ELSE
761 Append To List ${patch_list} ${empty_dict}
762 END
763 END
764
765 # Run patch command only if given IP is found on BMC.
766 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
767
768 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
769 ... valid_status_codes=${valid_status_codes}
770
771 ${data}= Create Dictionary IPv6StaticDefaultGateways=${patch_list}
772
773 @{ipv6_static_defgw_configurations}= Get IPv6 Static Default Gateway
774 Should Not Contain Match ${ipv6_static_defgw_configurations} ${ipv6_gw_addr}
775 ... msg=IPv6 Static default gateway does not exist.
Sweta Potthuri35c503b2025-07-27 23:36:20 -0500776
777
778Check Coexistence Of Linklocalv6 And Static IPv6
779 [Documentation] Verify both linklocalv6 and static IPv6 exist.
780
781 ${active_channel_config}= Get Active Channel Config
782 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
783
784 # Verify the address origin contains static and linklocal.
785 @{ipv6_addresses}= Get From Dictionary ${resp.dict} IPv6Addresses
786 ${ipv6_linklocal_addr}= Set Variable ${None}
787 ${ipv6_static_addr}= Set Variable ${None}
788 ${ipv6_addressorigin_list}= Create List
789
790 FOR ${ipv6_address} IN @{ipv6_addresses}
791 ${ipv6_addressorigin}= Get From Dictionary ${ipv6_address} AddressOrigin
792 IF '${ipv6_addressorigin}' == 'LinkLocal'
793 Set Test Variable ${ipv6_linklocal_addr} ${ipv6_address['Address']}
794 END
795 Append To List ${ipv6_addressorigin_list} ${ipv6_addressorigin}
796 END
797
798 Should Match Regexp ${ipv6_linklocal_addr} ${linklocal_addr_format}
799 Should Contain ${ipv6_addressorigin_list} LinkLocal
800 Should Contain ${ipv6_addressorigin_list} Static
Sweta Potthuri3c6f97d2025-08-06 00:30:19 -0500801
802
803Check If Linklocal Address Is In Correct Format
804 [Documentation] Linklocal address has network part fe80 and host part EUI64.
805
806 # Fetch the linklocal address.
807 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
808
809 @{ipv6_addresses}= Get From Dictionary ${resp.dict} IPv6Addresses
810 ${ipv6_linklocal_addr}= Set Variable ${None}
811 ${ipv6_addressorigin_list}= Create List
812 FOR ${ipv6_address} IN @{ipv6_addresses}
813 ${ipv6_addressorigin}= Get From Dictionary ${ipv6_address} AddressOrigin
814 IF '${ipv6_addressorigin}' == 'LinkLocal'
815 Set Test Variable ${ipv6_linklocal_addr} ${ipv6_address['Address']}
816 END
817 END
818
819 # Follow EUI64 from MAC.
820 ${system_mac}= Get BMC MAC Address
821 ${split_octets}= Split String ${system_mac} :
822 ${first_octet}= Evaluate int('${split_octets[0]}', 16)
823 ${flipped_hex}= Evaluate format(${first_octet} ^ 2, '02x')
824 ${grp1}= Evaluate re.sub(r'^0+', '', '${flipped_hex}${split_octets[1]}') modules=re
825 ${grp2}= Evaluate re.sub(r'^0+', '', '${split_octets[2]}ff') modules=re
826 ${grp3}= Evaluate re.sub(r'^0+', '', '${split_octets[4]}${split_octets[5]}') modules=re
827 ${linklocal}= Set Variable fe80::${grp1}:${grp2}:fe${split_octets[3]}:${grp3}
828
829 # Verify the linklocal obtained is the same as on the machine.
830 Should Be Equal ${linklocal} ${ipv6_linklocal_addr}
831