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