xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_ipv6.robot (revision 94041a34a992d9b5f6418a43e1cd5273a6d9f9b2)
1*** 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
8Resource       ../../lib/external_intf/vmi_utils.robot
9Resource       ../../lib/bmc_network_utils.robot
10Library        ../../lib/bmc_network_utils.py
11Library        Collections
12Library        Process
13
14Test Setup      Test Setup Execution
15Test Teardown   Test Teardown Execution
16Suite Setup     Suite Setup Execution
17Suite Teardown  Redfish.Logout
18
19Test Tags     BMC_IPv6
20
21*** Variables ***
22${test_ipv6_addr}            2001:db8:3333:4444:5555:6666:7777:8888
23${test_ipv6_invalid_addr}    2001:db8:3333:4444:5555:6666:7777:JJKK
24${test_ipv6_addr1}           2001:db8:3333:4444:5555:6666:7777:9999
25${invalid_hexadec_ipv6}      x:x:x:x:x:x:10.5.5.6
26${ipv6_multi_short}          2001::33::111
27# Valid prefix length is a integer ranges from 1 to 128.
28${test_prefix_length}        64
29${ipv6_gw_addr}              2002:903:15F:32:9:3:32:1
30${prefix_length_def}         None
31${invalid_staticv6_gateway}  9.41.164.1
32${linklocal_addr_format}     fe80::[0-9a-f:]+$
33${new_mac_addr}              AA:E2:84:14:28:79
34
35*** Test Cases ***
36
37Get IPv6 Address And Verify
38    [Documentation]  Get IPv6 Address And Verify.
39    [Tags]  Get_IPv6_Address_And_Verify
40
41    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
42      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
43    END
44
45
46Get PrefixLength And Verify
47    [Documentation]  Get IPv6 prefix length and verify.
48    [Tags]  Get_PrefixLength_And_Verify
49
50    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
51      Verify IPv6 On BMC  ${ipv6_network_configuration['PrefixLength']}
52    END
53
54
55Get IPv6 Default Gateway And Verify
56    [Documentation]  Get IPv6 default gateway and verify.
57    [Tags]  Get_IPv6_Default_Gateway_And_Verify
58
59    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
60    ${ipv6_gateway}=  Get From Dictionary  ${resp.dict}  IPv6DefaultGateway
61    Verify IPv6 Default Gateway On BMC  ${ipv6_gateway}
62
63
64Verify All Configured IPv6 And PrefixLength On BMC
65    [Documentation]  Verify IPv6 address and its prefix length on BMC.
66    [Tags]  Verify_All_Configured_IPv6_And_PrefixLength_On_BMC
67
68    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
69      Verify IPv6 And PrefixLength  ${ipv6_network_configuration['Address']}
70      ...  ${ipv6_network_configuration['PrefixLength']}
71    END
72
73
74Configure IPv6 Address And Verify
75    [Documentation]  Configure IPv6 address and verify.
76    [Tags]  Configure_IPv6_Address_And_Verify
77    [Teardown]  Run Keywords
78    ...  Delete IPv6 Address  ${test_ipv6_addr}  AND  Test Teardown Execution
79    [Template]  Configure IPv6 Address On BMC
80
81
82    # IPv6 address     Prefix length
83    ${test_ipv6_addr}  ${test_prefix_length}
84
85
86Delete IPv6 Address And Verify
87    [Documentation]  Delete IPv6 address and verify.
88    [Tags]  Delete_IPv6_Address_And_Verify
89
90    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
91
92    Delete IPv6 Address  ${test_ipv6_addr}
93
94
95Modify IPv6 Address And Verify
96    [Documentation]  Modify IPv6 address and verify.
97    [Tags]  Modify_IPv6_Address_And_Verify
98    [Teardown]  Run Keywords
99    ...  Delete IPv6 Address  ${test_ipv6_addr1}  AND  Test Teardown Execution
100
101    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
102
103    Modify IPv6 Address  ${test_ipv6_addr}  ${test_ipv6_addr1}  ${test_prefix_length}
104
105
106Verify Persistency Of IPv6 After BMC Reboot
107    [Documentation]  Verify persistency of IPv6 after BMC reboot.
108    [Tags]  Verify_Persistency_Of_IPv6_After_BMC_Reboot
109    [Teardown]  Run Keywords
110    ...  Delete IPv6 Address  ${test_ipv6_addr}  AND  Test Teardown Execution
111
112    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
113
114    Redfish OBMC Reboot (off)  stack_mode=skip
115
116    # Verifying persistency of IPv6.
117    Verify IPv6 On BMC  ${test_ipv6_addr}
118
119
120Enable SLAAC On BMC And Verify
121    [Documentation]  Enable SLAAC on BMC and verify.
122    [Tags]  Enable_SLAAC_On_BMC_And_Verify
123
124    Set SLAAC Configuration State And Verify  ${True}
125
126
127Enable DHCPv6 Property On BMC And Verify
128    [Documentation]  Enable DHCPv6 property on BMC and verify.
129    [Tags]  Enable_DHCPv6_Property_On_BMC_And_Verify
130
131    Set And Verify DHCPv6 Property  Enabled
132
133
134Disable DHCPv6 Property On BMC And Verify
135    [Documentation]  Disable DHCPv6 property on BMC and verify.
136    [Tags]  Disable_DHCPv6_Property_On_BMC_And_Verify
137
138    Set And Verify DHCPv6 Property  Disabled
139
140
141Verify Persistency Of DHCPv6 On Reboot
142    [Documentation]  Verify persistency of DHCPv6 property on reboot.
143    [Tags]  Verify_Persistency_Of_DHCPv6_On_Reboot
144
145    Set And Verify DHCPv6 Property  Enabled
146    Redfish OBMC Reboot (off)       stack_mode=skip
147    Verify DHCPv6 Property          Enabled
148
149
150Configure Invalid Static IPv6 And Verify
151    [Documentation]  Configure invalid static IPv6 and verify.
152    [Tags]  Configure_Invalid_Static_IPv6_And_Verify
153    [Template]  Configure IPv6 Address On BMC
154
155    #invalid_ipv6            prefix length           valid_status_code
156    ${ipv4_hexword_addr}     ${test_prefix_length}   ${HTTP_BAD_REQUEST}
157    ${invalid_hexadec_ipv6}  ${test_prefix_length}   ${HTTP_BAD_REQUEST}
158    ${ipv6_multi_short}      ${test_prefix_length}   ${HTTP_BAD_REQUEST}
159
160
161
162Configure IPv6 Static Default Gateway And Verify
163    [Documentation]  Configure IPv6 static default gateway and verify.
164    [Tags]  Configure_IPv6_Static_Default_Gateway_And_Verify
165    [Template]  Configure IPv6 Static Default Gateway On BMC
166
167    # static_def_gw              prefix length           valid_status_code
168    ${ipv6_gw_addr}              ${prefix_length_def}    ${HTTP_OK}
169    ${invalid_staticv6_gateway}  ${test_prefix_length}   ${HTTP_BAD_REQUEST}
170
171
172Modify Static Default Gateway And Verify
173    [Documentation]  Modify static default gateway and verify.
174    [Tags]  Modify_Static_Default_Gateway_And_Verify
175    [Setup]  Configure IPv6 Static Default Gateway On BMC  ${ipv6_gw_addr}  ${prefix_length_def}
176
177    Modify IPv6 Static Default Gateway On BMC  ${test_ipv6_addr1}  ${prefix_length_def}  ${HTTP_OK}  ${ipv6_gw_addr}
178
179
180Delete IPv6 Static Default Gateway And Verify
181    [Documentation]  Delete IPv6 static default gateway and verify.
182    [Tags]  Delete_IPv6_Static_Default_Gateway_And_Verify
183    [Setup]  Configure IPv6 Static Default Gateway On BMC  ${ipv6_gw_addr}  ${prefix_length_def}
184
185    Delete IPv6 Static Default Gateway  ${ipv6_gw_addr}
186
187
188Verify Coexistence Of Linklocalv6 And Static IPv6 On BMC
189    [Documentation]  Verify linklocalv6 And static IPv6 both exist.
190    [Tags]  Verify_Coexistence_Of_Linklocalv6_And_Static_IPv6_On_BMC
191    [Setup]  Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
192    [Teardown]  Delete IPv6 Address  ${test_ipv6_addr}
193
194    Check Coexistence Of Linklocalv6 And Static IPv6
195
196
197Verify IPv6 Linklocal Address Is In Correct Format
198    [Documentation]  Verify linklocal address has network part as fe80 and
199    ...  host part as EUI64.
200    [Tags]  Verify_IPv6_Linklocal_Address_Is_In_Correct_Format
201
202    Check If Linklocal Address Is In Correct Format
203
204
205Verify BMC Gets SLAAC Address On Enabling SLAAC
206    [Documentation]  On enabling SLAAC verify SLAAC address comes up.
207    [Tags]  Verify_BMC_Gets_SLAAC_Address_On_Enabling_SLAAC
208    [Setup]  Set SLAAC Configuration State And Verify  ${False}
209
210    Set SLAAC Configuration State And Verify  ${True}
211    Sleep  ${NETWORK_TIMEOUT}
212    Check BMC Gets SLAAC Address
213
214
215Enable And Verify DHCPv6 Property On Eth1 When DHCPv6 Property Enabled On Eth0
216    [Documentation]  Verify DHCPv6 on eth1 when DHCPv6 property is enabled on eth0.
217    [Tags]  Enable_And_Verify_DHCPv6_Property_On_Eth1_When_DHCPv6_Property_Enabled_On_Eth0
218    [Setup]  Get The Initial DHCPv6 Settings
219    [Teardown]  Run Keywords  Set And Verify DHCPv6 Property  ${dhcpv6_channel_1}  ${1}
220    ...  AND  Set And Verify DHCPv6 Property  ${dhcpv6_channel_2}  ${2}
221
222    Set And Verify DHCPv6 Property  Enabled  ${1}
223    Set And Verify DHCPv6 Property  Enabled  ${2}
224
225
226Enable And Verify SLAAC Property On Eth1 When SLAAC Property Enabled On Eth0
227    [Documentation]  Enable and verify SLAAC property on Eth1 when SLAAC property enabled on Eth0.
228    [Tags]  Enable_And_Verify_SLAAC_Property_On_Eth1_When_SLAAC_Property_Enabled_On_Eth0
229    [Setup]  Get The Initial SLAAC Settings
230    [Teardown]  Run Keywords  Set SLAAC Configuration State And Verify  ${slaac_channel_1}  [${HTTP_OK}]  ${1}
231    ...  AND  Set SLAAC Configuration State And Verify  ${slaac_channel_2}  [${HTTP_OK}]  ${2}
232
233    Set SLAAC Configuration State And Verify   ${True}  [${HTTP_OK}]  ${1}
234    Set SLAAC Configuration State And Verify   ${True}  [${HTTP_OK}]  ${2}
235
236    # Check all the addresses and address origins remain intact.
237    Verify All The Addresses Are Intact
238
239
240Verify Autoconfig Is Present On Ethernet Interface
241    [Documentation]  Verify autoconfig is present on ethernet interface.
242    [Tags]  Verify_Autoconfig_Is_Present_On_Ethernet_Interface
243
244    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
245    Should Contain  ${resp.dict}  StatelessAddressAutoConfig
246
247
248Verify Interface ID Of SLAAC And LinkLocal Addresses Are Same
249    [Documentation]  Validate interface id of SLAAC and link-local addresses are same.
250    [Tags]  Verify_Interface_ID_Of_SLAAC_And_LinkLocal_Addresses_Are_Same
251
252    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
253    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=  Get Address Origin List And Address For Type  SLAAC
254
255    ${linklocal_interface_id}=  Get Interface ID Of IPv6  ${ipv6_linklocal_addr}
256    ${slaac_interface_id}=  Get Interface ID Of IPv6  ${ipv6_slaac_addr}
257
258    Should Be Equal    ${linklocal_interface_id}    ${slaac_interface_id}
259
260
261Verify Persistency Of Link Local IPv6 On BMC Reboot
262    [Documentation]  Verify persistency of link local on BMC reboot.
263    [Tags]  Verify_Persistency_Of_Link_Local_IPv6_On_BMC_Reboot
264
265    # Capturing the linklocal before reboot.
266    @{ipv6_address_origin_list}  ${linklocal_addr_before_reboot}=
267    ...  Get Address Origin List And Address For Type  LinkLocal
268
269    # Rebooting BMC.
270    Redfish OBMC Reboot (off)  stack_mode=skip
271
272    @{ipv6_address_origin_list}  ${linklocal_addr_after_reboot}=
273    ...  Get Address Origin List And Address For Type  LinkLocal
274
275    # Verifying the linklocal must be the same before and after reboot.
276    Should Be Equal    ${linklocal_addr_before_reboot}    ${linklocal_addr_after_reboot}
277    ...    msg=IPv6 Linklocal address has changed after reboot.
278
279
280Modify MAC and Verify BMC Reinitializing Linklocal
281    [Documentation]  Modify MAC and verify BMC reinitializing linklocal.
282    [Tags]  Modify_MAC_and_Verify_BMC_Reinitializing_Linklocal
283    [Teardown]  Configure MAC Settings  ${original_address}
284
285    ${original_address}=  Get BMC MAC Address
286    @{ipv6_addressorigin_list}  ${ipv6_before_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
287
288    # Modify MAC Address Of Ethernet Interface.
289    Configure MAC Settings  ${new_mac_addr}
290    Sleep  30s
291    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
292    @{ipv6_addressorigin_list}  ${ipv6_linklocal_after_addr}=  Get Address Origin List And Address For Type  LinkLocal
293
294    # Verify whether the linklocal has changed and is in the the correct format.
295    Check If Linklocal Address Is In Correct Format
296    Should Not Be Equal    ${ipv6_before_linklocal_addr}    ${ipv6_linklocal_after_addr}
297
298
299Add Multiple IPv6 Address And Verify
300    [Documentation]  Add multiple IPv6 address and verify.
301    [Tags]  Add_Multiple_IPv6_Address_And_Verify
302    [Teardown]  Run Keywords
303    ...  Delete IPv6 Address  ${test_ipv6_addr}  AND  Delete IPv6 Address  ${test_ipv6_addr1}
304    ...  AND  Test Teardown Execution
305
306    Configure Multiple IPv6 Address on BMC  ${test_prefix_length}
307
308
309*** Keywords ***
310
311Suite Setup Execution
312    [Documentation]  Do suite setup execution.
313
314    Redfish.Login
315    ${active_channel_config}=  Get Active Channel Config
316    Set Suite Variable  ${active_channel_config}
317
318    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
319
320    Set Suite variable  ${ethernet_interface}
321
322    ${initial_ipv4_addressorigin_list}  ${initial_ipv4_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv4Addresses
323    ${initial_ipv6_addressorigin_list}  ${initial_ipv6_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses
324
325    Set Suite Variable   ${initial_ipv4_addressorigin_list}
326    Set Suite Variable   ${initial_ipv4_addr_list}
327    Set Suite Variable   ${initial_ipv6_addressorigin_list}
328    Set Suite Variable   ${initial_ipv6_addr_list}
329
330
331Test Setup Execution
332    [Documentation]  Test setup execution.
333
334    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
335    Set Test Variable  @{ipv6_network_configurations}
336
337    # Get BMC IPv6 address and prefix length.
338    ${ipv6_data}=  Get BMC IPv6 Info
339    Set Test Variable  ${ipv6_data}
340
341
342Test Teardown Execution
343    [Documentation]  Test teardown execution.
344
345    FFDC On Test Case Fail
346
347
348Get IPv6 Network Configuration
349    [Documentation]  Get Ipv6 network configuration.
350    # Sample output:
351    # {
352    #  "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0",
353    #  "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
354    #   "DHCPv4": {
355    #    "DHCPEnabled": false,
356    #    "UseDNSServers": false,
357    #    "UseDomainName": true,
358    #    "UseNTPServers": false
359    #  },
360    #  "DHCPv6": {
361    #    "OperatingMode": "Disabled",
362    #    "UseDNSServers": false,
363    #    "UseDomainName": true,
364    #    "UseNTPServers": false
365    #  },
366    #  "Description": "Management Network Interface",
367    #  "FQDN": "localhost",
368    #  "HostName": "localhost",
369    #  "IPv4Addresses": [
370    #    {
371    #      "Address": "xx.xx.xx.xx",
372    #      "AddressOrigin": "Static",
373    #      "Gateway": "xx.xx.xx.1",
374    #      "SubnetMask": "xx.xx.xx.0"
375    #    },
376    #    {
377    #      "Address": "169.254.xx.xx",
378    #      "AddressOrigin": "IPv4LinkLocal",
379    #      "Gateway": "0.0.0.0",
380    #      "SubnetMask": "xx.xx.0.0"
381    #    },
382    #  ],
383    #  "IPv4StaticAddresses": [
384    #    {
385    #      "Address": "xx.xx.xx.xx",
386    #      "AddressOrigin": "Static",
387    #      "Gateway": "xx.xx.xx.1",
388    #      "SubnetMask": "xx.xx.0.0"
389    #    }
390    # }
391    #  ],
392    #  "IPv6AddressPolicyTable": [],
393    #  "IPv6Addresses": [
394    #    {
395    #      "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
396    #      "AddressOrigin": "LinkLocal",
397    #      "AddressState": null,
398    #      "PrefixLength": xx
399    #    }
400    #  ],
401    #  "IPv6DefaultGateway": "",
402    #  "IPv6StaticAddresses": [
403    #    { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
404    #      "AddressOrigin": "Static",
405    #      "AddressState": null,
406    #      "PrefixLength": xxx
407    #    }
408    #  ],
409    #  "Id": "eth0",
410    #  "InterfaceEnabled": true,
411    #  "LinkStatus": "LinkUp",
412    #  "MACAddress": "xx:xx:xx:xx:xx:xx",
413    #  "Name": "Manager Ethernet Interface",
414    #  "NameServers": [],
415    #  "SpeedMbps": 0,
416    #  "StaticNameServers": [],
417    #  "Status": {
418    #    "Health": "OK",
419    #    "HealthRollup": "OK",
420    #    "State": "Enabled"
421    #  },
422    #  "VLANs": {
423    #    "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs"
424
425
426    ${active_channel_config}=  Get Active Channel Config
427    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
428
429    @{ipv6_network_configurations}=  Get From Dictionary  ${resp.dict}  IPv6StaticAddresses
430    RETURN  @{ipv6_network_configurations}
431
432
433Verify IPv6 And PrefixLength
434    [Documentation]  Verify IPv6 address and prefix length on BMC.
435    [Arguments]  ${ipv6_addr}  ${prefix_len}
436
437    # Description of the argument(s):
438    # ipv6_addr   IPv6 address to be verified.
439    # prefix_len  PrefixLength value to be verified.
440
441    # Catenate IPv6 address and its prefix length.
442    ${ipv6_with_prefix}=  Catenate  ${ipv6_addr}/${prefix_len}
443
444    # Get IPv6 address details on BMC using IP command.
445    @{ip_data}=  Get BMC IPv6 Info
446
447    # Verify if IPv6 and prefix length is configured on BMC.
448
449    Should Contain  ${ip_data}  ${ipv6_with_prefix}
450    ...  msg=IPv6 and prefix length pair does not exist.
451
452
453Configure IPv6 Address On BMC
454    [Documentation]  Add IPv6 Address on BMC.
455    [Arguments]  ${ipv6_addr}  ${prefix_len}  ${valid_status_codes}=${HTTP_OK}
456
457    # Description of argument(s):
458    # ipv6_addr           IPv6 address to be added (e.g. "2001:EEEE:2222::2022").
459    # prefix_len          Prefix length for the IPv6 to be added
460    #                     (e.g. "64").
461    # valid_status_codes  Expected return code from patch operation
462    #                     (e.g. "200").
463
464    ${prefix_length}=  Convert To Integer  ${prefix_len}
465    ${empty_dict}=  Create Dictionary
466    ${ipv6_data}=  Create Dictionary  Address=${ipv6_addr}
467    ...  PrefixLength=${prefix_length}
468
469    ${patch_list}=  Create List
470
471    # Get existing static IPv6 configurations on BMC.
472    ${ipv6_network_configurations}=  Get IPv6 Network Configuration
473    ${num_entries}=  Get Length  ${ipv6_network_configurations}
474
475    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
476      Append To List  ${patch_list}  ${empty_dict}
477    END
478
479    ${valid_status_codes}=  Set Variable If  '${valid_status_codes}' == '${HTTP_OK}'
480    ...  ${HTTP_OK},${HTTP_NO_CONTENT}
481    ...  ${valid_status_codes}
482
483    # We need not check for existence of IPv6 on BMC while adding.
484    Append To List  ${patch_list}  ${ipv6_data}
485    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
486
487    ${active_channel_config}=  Get Active Channel Config
488    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
489
490    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
491    ...  valid_status_codes=[${valid_status_codes}]
492
493    Return From Keyword If  '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
494
495    # Note: Network restart takes around 15-18s after patch request processing.
496    Sleep  ${NETWORK_TIMEOUT}s
497    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
498
499    Verify IPv6 And PrefixLength  ${ipv6_addr}  ${prefix_len}
500
501    # Verify if existing static IPv6 addresses still exist.
502    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
503      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
504    END
505
506    Validate IPv6 Network Config On BMC
507
508
509Configure Multiple IPv6 Address on BMC
510    [Documentation]  Add multiple IPv6 address on BMC.
511    [Arguments]  ${prefix_len}
512    ...          ${valid_status_codes}=[${HTTP_OK},${HTTP_NO_CONTENT}]
513
514    # Description of argument(s):
515    # prefix_len          Prefix length for the IPv6 to be added
516    #                     (e.g. "64").
517    # valid_status_codes  Expected return code from patch operation
518    #                     (e.g. "200").
519
520    ${ipv6_list}=  Create List  ${test_ipv6_addr}  ${test_ipv6_addr1}
521    ${prefix_length}=  Convert To Integer  ${prefix_len}
522    ${empty_dict}=  Create Dictionary
523    ${patch_list}=  Create List
524
525    # Get existing static IPv6 configurations on BMC.
526    ${ipv6_network_configurations}=  Get IPv6 Network Configuration
527    ${num_entries}=  Get Length  ${ipv6_network_configurations}
528
529    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
530      Append To List  ${patch_list}  ${empty_dict}
531    END
532
533    # We need not check for existence of IPv6 on BMC while adding.
534    FOR  ${ipv6_addr}  IN  @{ipv6_list}
535      ${ipv6_data}=  Create Dictionary  Address=${ipv6_addr}  PrefixLength=${prefix_length}
536      Append To List  ${patch_list}  ${ipv6_data}
537    END
538    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
539
540    ${active_channel_config}=  Get Active Channel Config
541    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
542
543    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
544    ...  valid_status_codes=${valid_status_codes}
545
546    IF  ${valid_status_codes} != [${HTTP_OK}, ${HTTP_NO_CONTENT}]
547        Fail  msg=Static address not added correctly
548    END
549
550    # Note: Network restart takes around 15-18s after patch request processing.
551    Sleep  ${NETWORK_TIMEOUT}s
552    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
553
554    # Verify newly added ip address on CLI.
555    FOR  ${ipv6_addr}  IN  @{ipv6_list}
556      Verify IPv6 And PrefixLength  ${ipv6_addr}  ${prefix_len}
557    END
558
559    # Verify if existing static IPv6 addresses still exist.
560    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
561      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
562    END
563
564    # Get the latest ipv6 network configurations.
565    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
566
567    # Verify newly added ip address on BMC.
568    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
569      Should Contain Match  ${ipv6_list}  ${ipv6_network_configuration['Address']}
570    END
571
572    Validate IPv6 Network Config On BMC
573
574
575Validate IPv6 Network Config On BMC
576    [Documentation]  Check that IPv6 network info obtained via redfish matches info
577    ...              obtained via CLI.
578
579    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
580    ${ipv6_data}=  Get BMC IPv6 Info
581    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
582      Should Contain Match  ${ipv6_data}  ${ipv6_network_configuration['Address']}/*
583      ...  msg=IPv6 address does not exist.
584    END
585
586
587Delete IPv6 Address
588    [Documentation]  Delete IPv6 address of BMC.
589    [Arguments]  ${ipv6_addr}
590    ...          ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
591
592    # Description of argument(s):
593    # ipv6_addr           IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234").
594    # valid_status_codes  Expected return code from patch operation
595    #                     (e.g. "200").  See prolog of rest_request
596    #                     method in redfish_plus.py for details.
597
598    ${empty_dict}=  Create Dictionary
599    ${patch_list}=  Create List
600
601    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
602    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
603        IF  '${ipv6_network_configuration['Address']}' == '${ipv6_addr}'
604            Append To List  ${patch_list}  ${null}
605        ELSE
606            Append To List  ${patch_list}  ${empty_dict}
607        END
608    END
609
610    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
611    ...  ${patch_list}  ${null}  msg=${ipv6_addr} does not exist on BMC
612    Pass Execution If  ${ip_found} == ${False}  ${ipv6_addr} does not exist on BMC
613
614    # Run patch command only if given IP is found on BMC
615    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
616
617    ${active_channel_config}=  Get Active Channel Config
618    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
619
620    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
621    ...  valid_status_codes=${valid_status_codes}
622
623    # Note: Network restart takes around 15-18s after patch request processing
624    Sleep  ${NETWORK_TIMEOUT}s
625    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
626
627    # IPv6 address that is deleted should not be there on BMC.
628    ${delete_status}=  Run Keyword And Return Status  Verify IPv6 On BMC  ${ipv6_addr}
629    IF  '${valid_status_codes}' == '[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]'
630        Should Be True  '${delete_status}' == '${False}'
631    ELSE
632        Should Be True  '${delete_status}' == '${True}'
633    END
634
635    Validate IPv6 Network Config On BMC
636
637
638Modify IPv6 Address
639    [Documentation]  Modify and verify IPv6 address of BMC.
640    [Arguments]  ${ipv6}  ${new_ipv6}  ${prefix_len}
641    ...  ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
642
643    # Description of argument(s):
644    # ipv6                  IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
645    # new_ipv6              New IPv6 address to be configured.
646    # prefix_len            Prefix length value (Range 1 to 128).
647    # valid_status_codes    Expected return code from patch operation
648    #                       (e.g. "200", "201").
649
650    ${empty_dict}=  Create Dictionary
651    ${patch_list}=  Create List
652    ${prefix_length}=  Convert To Integer  ${prefix_len}
653    ${ipv6_data}=  Create Dictionary
654    ...  Address=${new_ipv6}  PrefixLength=${prefix_length}
655
656    # Sample IPv6 network configurations:
657    #  "IPv6AddressPolicyTable": [],
658    #  "IPv6Addresses": [
659    #    {
660    #      "Address": "X002:db8:0:2::XX0",
661    #      "AddressOrigin": "DHCPv6",
662    #      "PrefixLength": 128
663    #    },
664    #    {
665    #      "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX",
666    #      "AddressOrigin": "SLAAC",
667    #      "PrefixLength": 64
668    #    },
669    #    {
670    #      "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
671    #      "AddressOrigin": "Static",
672    #      "PrefixLength": 56
673    #    },
674    #    {
675    #      "Address": “Z002:db8:0:2:a94:efff:fe82:5000",
676    #      "AddressOrigin": "Static",
677    #      "PrefixLength": 56
678    #    },
679    #    {
680    #      "Address": “Xe80::a94:efff:YYYY:XXXX",
681    #      "AddressOrigin": "LinkLocal",
682    #      "PrefixLength": 64
683    #    },
684    #    {
685    #     "Address": “X002:db8:1:2:eff:233:fee:546",
686    #      "AddressOrigin": "Static",
687    #      "PrefixLength": 56
688    #    }
689    #  ],
690    #  "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”,
691    #  "IPv6StaticAddresses": [
692    #    {
693    #      "Address": “X002:db8:0:2:a94:efff:fe82:5000",
694    #      "PrefixLength": 56
695    #    },
696    #    {
697    #      "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
698    #      "PrefixLength": 56
699    #    },
700    #    {
701    #      "Address": “Z002:db8:1:2:eff:233:fee:546",
702    #      "PrefixLength": 56
703    #    }
704    #  ],
705    #  "IPv6StaticDefaultGateways": [],
706
707    # Find the position of IPv6 address to be modified.
708    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
709    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
710      IF  '${ipv6_network_configuration['Address']}' == '${ipv6}'
711          Append To List  ${patch_list}  ${ipv6_data}
712      ELSE
713          Append To List  ${patch_list}  ${empty_dict}
714      END
715    END
716
717    # Modify the IPv6 address only if given IPv6 is found
718    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
719    ...  ${patch_list}  ${ipv6_data}  msg=${ipv6} does not exist on BMC
720    Pass Execution If  ${ip_found} == ${False}  ${ipv6} does not exist on BMC
721
722    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
723
724    ${active_channel_config}=  Get Active Channel Config
725    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
726
727    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
728    ...  body=&{data}  valid_status_codes=${valid_status_codes}
729
730    # Note: Network restart takes around 15-18s after patch request processing.
731    Sleep  ${NETWORK_TIMEOUT}s
732    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
733
734    # Verify if new IPv6 address is configured on BMC.
735    Verify IPv6 On BMC  ${new_ipv6}
736
737    # Verify if old IPv6 address is erased.
738    ${cmd_status}=  Run Keyword And Return Status
739    ...  Verify IPv6 On BMC  ${ipv6}
740    Should Be Equal  ${cmd_status}  ${False}  msg=Old IPv6 address is not deleted.
741
742    Validate IPv6 Network Config On BMC
743
744
745Set SLAAC Configuration State And Verify
746    [Documentation]  Set SLAAC configuration state and verify.
747    [Arguments]  ${slaac_state}  ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
748    ...  ${channel_number}=${CHANNEL_NUMBER}
749
750    # Description of argument(s):
751    # slaac_state         SLAAC state('True' or 'False').
752    # valid_status_code   Expected valid status codes.
753    # channel_number      Channel number 1(eth0) or 2(eth1).
754
755    ${active_channel_config}=  Get Active Channel Config
756    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
757
758    ${data}=  Set Variable If  ${slaac_state} == ${False}  ${DISABLE_SLAAC}  ${ENABLE_SLAAC}
759    ${resp}=  Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
760    ...  body=${data}  valid_status_codes=${valid_status_codes}
761
762    # Verify SLAAC is set correctly.
763    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
764    ${slaac_verify}=  Get From Dictionary  ${resp.dict}  StatelessAddressAutoConfig
765
766    IF  '${slaac_verify['IPv6AutoConfigEnabled']}' != '${slaac_state}'
767        Fail  msg=SLAAC not set properly.
768    END
769
770Set And Verify DHCPv6 Property
771    [Documentation]  Set DHCPv6 property and verify.
772    [Arguments]  ${dhcpv6_operating_mode}=${Disabled}  ${channel_number}=${CHANNEL_NUMBER}
773
774    # Description of argument(s):
775    # dhcpv6_operating_mode    Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled').
776    # channel_number           Channel number 1 or 2.
777
778    Set DHCPv6 Property  ${dhcpv6_operating_mode}  ${channel_number}
779    Verify DHCPv6 Property  ${dhcpv6_operating_mode}  ${channel_number}
780
781
782Set DHCPv6 Property
783    [Documentation]  Set DHCPv6 attribute is enables or disabled.
784    [Arguments]  ${dhcpv6_operating_mode}=${Disabled}  ${channel_number}=${CHANNEL_NUMBER}
785
786    # Description of argument(s):
787    # dhcpv6_operating_mode    Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled').
788    # channel_number           Channel number 1 or 2.
789
790    ${data}=  Set Variable If  '${dhcpv6_operating_mode}' == 'Disabled'  ${DISABLE_DHCPv6}  ${ENABLE_DHCPv6}
791    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
792
793    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
794    ...  body=${data}  valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
795
796
797Verify DHCPv6 Property
798    [Documentation]  Verify DHCPv6 settings is enabled or disabled.
799    [Arguments]  ${dhcpv6_operating_mode}  ${channel_number}=${CHANNEL_NUMBER}
800
801    # Description of Argument(s):
802    # dhcpv6_operating_mode  Enable/ Disable DHCPv6.
803    # channel_number         Channel number 1 or 2.
804
805    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
806
807    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
808    ${dhcpv6_verify}=  Get From Dictionary  ${resp.dict}  DHCPv6
809
810    Should Be Equal  '${dhcpv6_verify['OperatingMode']}'  '${dhcpv6_operating_mode}'
811
812
813Get IPv6 Static Default Gateway
814    [Documentation]  Get IPv6 static default gateway.
815
816    ${active_channel_config}=  Get Active Channel Config
817    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
818
819    @{ipv6_static_defgw_configurations}=  Get From Dictionary  ${resp.dict}  IPv6StaticDefaultGateways
820    RETURN  @{ipv6_static_defgw_configurations}
821
822
823Configure IPv6 Static Default Gateway On BMC
824    [Documentation]  Configure IPv6 static default gateway on BMC.
825    [Arguments]  ${ipv6_gw_addr}  ${prefix_length_def}
826    ...  ${valid_status_codes}=${HTTP_OK}
827
828    # Description of argument(s):
829    # ipv6_gw_addr          IPv6 Static Default Gateway address to be configured.
830    # prefix_len_def        Prefix length value (Range 1 to 128).
831    # valid_status_codes    Expected return code from patch operation
832    #                       (e.g. "200", "204".)
833
834    # Prefix Length is passed as None.
835    IF   '${prefix_length_def}' == '${None}'
836        ${ipv6_gw}=  Create Dictionary  Address=${ipv6_gw_addr}
837    ELSE
838        ${ipv6_gw}=  Create Dictionary  Address=${ipv6_gw_addr}  Prefix Length=${prefix_length_def}
839    END
840
841    ${ipv6_static_def_gw}=  Get IPv6 Static Default Gateway
842
843    ${num_entries}=  Get Length  ${ipv6_static_def_gw}
844
845    ${patch_list}=  Create List
846    ${empty_dict}=  Create Dictionary
847
848    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
849      Append To List  ${patch_list}  ${empty_dict}
850    END
851
852    ${valid_status_codes}=  Set Variable If  '${valid_status_codes}' == '${HTTP_OK}'
853    ...  ${HTTP_OK},${HTTP_NO_CONTENT}
854    ...  ${valid_status_codes}
855
856    Append To List  ${patch_list}  ${ipv6_gw}
857    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
858
859    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
860    ...  body=${data}  valid_status_codes=[${valid_status_codes}]
861
862    # Verify the added static default gateway is present in Redfish Get Output.
863    ${ipv6_staticdef_gateway}=  Get IPv6 Static Default Gateway
864
865    ${ipv6_static_def_gw_list}=  Create List
866    FOR  ${ipv6_staticdef_gateway}  IN  @{ipv6_staticdef_gateway}
867        ${value}=    Get From Dictionary    ${ipv6_staticdef_gateway}    Address
868        Append To List  ${ipv6_static_def_gw_list}  ${value}
869    END
870
871    IF  '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
872        Should Not Contain  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}
873    ELSE
874        Should Contain  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}
875    END
876
877
878Modify IPv6 Static Default Gateway On BMC
879    [Documentation]  Modify and verify IPv6 address of BMC.
880    [Arguments]  ${ipv6_gw_addr}  ${new_static_def_gw}  ${prefix_length}
881    ...  ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED}]
882
883    # Description of argument(s):
884    # ipv6_gw_addr          IPv6 static default gateway address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
885    # new_static_def_gw     New static default gateway address to be configured.
886    # prefix_length         Prefix length value (Range 1 to 128).
887    # valid_status_codes    Expected return code from patch operation
888    #                       (e.g. "200", "204").
889
890    ${empty_dict}=  Create Dictionary
891    ${patch_list}=  Create List
892    # Prefix Length is passed as None.
893    IF   '${prefix_length_def}' == '${None}'
894        ${modified_ipv6_gw_addripv6_data}=  Create Dictionary  Address=${new_static_def_gw}
895    ELSE
896        ${modified_ipv6_gw_addripv6_data}=  Create Dictionary  Address=${new_static_def_gw}  Prefix Length=${prefix_length_def}
897    END
898
899    @{ipv6_static_def_gw_list}=  Get IPv6 Static Default Gateway
900
901    FOR  ${ipv6_static_def_gw}  IN  @{ipv6_static_def_gw_list}
902      IF  '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
903          Append To List  ${patch_list}  ${modified_ipv6_gw_addripv6_data}
904      ELSE
905          Append To List  ${patch_list}  ${empty_dict}
906      END
907    END
908
909    # Modify the IPv6 address only if given IPv6 static default gateway is found.
910    ${ip_static_def_gw_found}=  Run Keyword And Return Status  List Should Contain Value
911    ...  ${patch_list}  ${modified_ipv6_gw_addripv6_data}  msg=${ipv6_gw_addr} does not exist on BMC
912    Pass Execution If  ${ip_static_def_gw_found} == ${False}  ${ipv6_gw_addr} does not exist on BMC
913
914    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
915
916    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
917    ...  body=&{data}  valid_status_codes=${valid_status_codes}
918
919    ${ipv6_staticdef_gateway}=  Get IPv6 Static Default Gateway
920
921    ${ipv6_static_def_gw_list}=  Create List
922    FOR  ${ipv6_staticdef_gateway}  IN  @{ipv6_staticdef_gateway}
923        ${value}=  Get From Dictionary  ${ipv6_staticdef_gateway}  Address
924        Append To List  ${ipv6_static_def_gw_list}  ${value}
925    END
926
927    Should Contain  ${ipv6_static_def_gw_list}  ${new_static_def_gw}
928    # Verify if old static default gateway address is erased.
929    Should Not Contain  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}
930
931
932Delete IPv6 Static Default Gateway
933    [Documentation]  Delete IPv6 static default gateway on BMC.
934    [Arguments]  ${ipv6_gw_addr}
935    ...          ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
936
937    # Description of argument(s):
938    # ipv6_gw_addr          IPv6 Static Default Gateway address to be deleted.
939    # valid_status_codes    Expected return code from patch operation
940    #                       (e.g. "200").
941
942    ${patch_list}=  Create List
943    ${empty_dict}=  Create Dictionary
944
945    ${ipv6_static_def_gw_list}=  Create List
946    @{ipv6_static_defgw_configurations}=  Get IPv6 Static Default Gateway
947
948    FOR  ${ipv6_staticdef_gateway}  IN  @{ipv6_static_defgw_configurations}
949        ${value}=  Get From Dictionary  ${ipv6_staticdef_gateway}  Address
950        Append To List  ${ipv6_static_def_gw_list}  ${value}
951    END
952
953    ${defgw_found}=  Run Keyword And Return Status  List Should Contain Value
954    ...  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}  msg=${ipv6_gw_addr} does not exist on BMC
955    Skip If  ${defgw_found} == ${False}  ${ipv6_gw_addr} does not exist on BMC
956
957    FOR  ${ipv6_static_def_gw}  IN  @{ipv6_static_defgw_configurations}
958        IF  '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
959            Append To List  ${patch_list}  ${null}
960        ELSE
961            Append To List  ${patch_list}  ${empty_dict}
962      END
963    END
964
965    # Run patch command only if given IP is found on BMC.
966    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
967
968    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
969    ...  valid_status_codes=${valid_status_codes}
970
971    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
972
973    @{ipv6_static_defgw_configurations}=  Get IPv6 Static Default Gateway
974    Should Not Contain Match  ${ipv6_static_defgw_configurations}  ${ipv6_gw_addr}
975    ...  msg=IPv6 Static default gateway does not exist.
976
977
978Check Coexistence Of Linklocalv6 And Static IPv6
979    [Documentation]  Verify both linklocalv6 and static IPv6 exist.
980
981    # Verify the address origin contains static and linklocal.
982    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
983
984    Should Match Regexp  ${ipv6_linklocal_addr}        ${linklocal_addr_format}
985    Should Contain       ${ipv6_addressorigin_list}    Static
986
987
988Check If Linklocal Address Is In Correct Format
989    [Documentation]  Linklocal address has network part fe80 and host part EUI64.
990
991    # Fetch the linklocal address.
992    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
993
994    # Follow EUI64 from MAC.
995    ${system_mac}=  Get BMC MAC Address
996    ${split_octets}=  Split String  ${system_mac}  :
997    ${first_octet}=  Evaluate  int('${split_octets[0]}', 16)
998    ${flipped_hex}=  Evaluate  format(${first_octet} ^ 2, '02x')
999    ${grp1}=  Evaluate  re.sub(r'^0+', '', '${flipped_hex}${split_octets[1]}')  modules=re
1000    ${grp2}=  Evaluate  re.sub(r'^0+', '', '${split_octets[2]}ff')  modules=re
1001    ${grp3}=  Evaluate  re.sub(r'^0+', '', '${split_octets[4]}${split_octets[5]}')  modules=re
1002    ${linklocal}=  Set Variable  fe80::${grp1}:${grp2}:fe${split_octets[3]}:${grp3}
1003
1004    # Verify the linklocal obtained is the same as on the machine.
1005    Should Be Equal  ${linklocal}  ${ipv6_linklocal_addr}
1006
1007
1008Check BMC Gets SLAAC Address
1009    [Documentation]  Check BMC gets slaac address.
1010
1011    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=  Get Address Origin List And Address For Type  SLAAC
1012
1013
1014Get The Initial DHCPv6 Setting On Each Interface
1015    [Documentation]  Get the initial DHCPv6 setting of each interface.
1016    [Arguments]  ${channel_number}
1017
1018    # Description of the argument(s):
1019    # channel_number    Channel number 1 or 2.
1020
1021    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
1022    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1023    ${initial_dhcpv6_iface}=  Get From Dictionary  ${resp.dict}  DHCPv6
1024    IF  ${channel_number}==${1}
1025        Set Test Variable  ${dhcpv6_channel_1}  ${initial_dhcpv6_iface['OperatingMode']}
1026    ELSE
1027        Set Test Variable  ${dhcpv6_channel_2}  ${initial_dhcpv6_iface['OperatingMode']}
1028    END
1029
1030
1031Get The Initial DHCPv6 Settings
1032    [Documentation]  Get the initial DHCPv6 settings of both the interfaces.
1033
1034    Get The Initial DHCPv6 Setting On Each Interface  ${1}
1035    Get The Initial DHCPv6 Setting On Each Interface  ${2}
1036
1037
1038Get The Initial SLAAC Settings
1039    [Documentation]  Get the initial SLAAC settings of both the interfaces.
1040
1041    Get The Initial SLAAC Setting On Each Interface  ${1}
1042    Get The Initial SLAAC Setting On Each Interface   ${2}
1043
1044
1045Get The Initial SLAAC Setting On Each Interface
1046    [Documentation]  Get the initial SLAAC setting of the interface.
1047    [Arguments]  ${channel_number}
1048
1049    # Description of the argument(s):
1050    # channel_number     Channel number 1 or 2.
1051
1052    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
1053    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1054    ${initial_slaac_iface}=  Get From Dictionary  ${resp.dict}  StatelessAddressAutoConfig
1055    IF  ${channel_number}==${1}
1056        Set Test Variable  ${slaac_channel_1}  ${initial_slaac_iface['IPv6AutoConfigEnabled']}
1057    ELSE
1058        Set Test Variable  ${slaac_channel_2}  ${initial_slaac_iface['IPv6AutoConfigEnabled']}
1059    END
1060
1061
1062Get Address Origin List And IPv4 or IPv6 Address
1063    [Documentation]  Get address origin list and address for type.
1064    [Arguments]  ${ip_address_type}
1065
1066    # Description of the argument(s):
1067    # ip_address_type  Type of IPv4 or IPv6 address to be checked.
1068
1069    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
1070    @{ip_addresses}=  Get From Dictionary  ${resp.dict}  ${ip_address_type}
1071
1072    ${ip_addressorigin_list}=  Create List
1073    ${ip_addr_list}=  Create List
1074    FOR  ${ip_address}  IN  @{ip_addresses}
1075        ${ip_addressorigin}=  Get From Dictionary  ${ip_address}  AddressOrigin
1076        Append To List  ${ip_addressorigin_list}  ${ip_addressorigin}
1077        Append To List  ${ip_addr_list}  ${ip_address['Address']}
1078    END
1079    RETURN  ${ip_addressorigin_list}  ${ip_addr_list}
1080
1081
1082Verify All The Addresses Are Intact
1083    [Documentation]  Verify all the addresses and address origins remain intact.
1084
1085    # Verify that it will not impact the IPv4 configuration.
1086    Sleep  ${NETWORK_TIMEOUT}
1087    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
1088
1089    # IPv6 address must be present.
1090    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=  Get Address Origin List And Address For Type  SLAAC
1091    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
1092
1093    # IPv4 and IPv6 addresses must remain intact.
1094    ${ipv4_addressorigin_list}  ${ipv4_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv4Addresses
1095    ${ipv6_addressorigin_list}  ${ipv6_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses
1096
1097    ${ipv6_is_subset}=  Evaluate  set(${initial_ipv6_addr_list}).issubset(set(${ipv6_addr_list}))
1098    Should Be True  ${ipv6_is_subset}
1099
1100    Should be Equal  ${initial_ipv4_addressorigin_list}  ${ipv4_addressorigin_list}
1101    Should be Equal  ${initial_ipv4_addr_list}  ${ipv4_addr_list}
1102
1103
1104Get Interface ID Of IPv6
1105    [Documentation]  Get interface id of IPv6 address.
1106    [Arguments]    ${ipv6_address}
1107
1108    # Description of the argument(s):
1109    # ${ipv6_address}  IPv6 Address to extract the last 4 hextets.
1110
1111    # Last 64 bits of SLAAC and Linklocal must be the same.
1112    # Sample IPv6 network configurations.
1113    #"IPv6AddressPolicyTable": [],
1114    #  "IPv6Addresses": [
1115    #    {
1116    #      "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
1117    #      "AddressOrigin": "LinkLocal",
1118    #      "AddressState": null,
1119    #      "PrefixLength": xx
1120    #    }
1121    #  ],
1122    #    {
1123    #      "Address": "2002:xxxx:xxxx:xxxx:xxxx",
1124    #      "AddressOrigin": "SLAAC",
1125    #      "PrefixLength": 64
1126    #    }
1127    #  ],
1128
1129    ${split_ip_address}=  Split String  ${ipv6_address}  :
1130    ${missing_ip}=  Evaluate  8 - len(${split_ip_address}) + 1
1131    ${expanded_ip}=  Create List
1132
1133    FOR  ${hextet}  IN  @{split_ip_address}
1134       IF  '${hextet}' == ''
1135           FOR  ${i}  IN RANGE  ${missing_ip}
1136               Append To List  ${expanded_ip}  0000
1137           END
1138       ELSE
1139           Append To List  ${expanded_ip}  ${hextet}
1140       END
1141    END
1142    ${interface_id}=  Evaluate  ':'.join(${expanded_ip}[-4:])
1143    RETURN  ${interface_id}
1144