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