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