xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_ipv6.robot (revision 2067a770fe31056ce24dcc630b99b03c77efa2b8)
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${new_mac_addr}              AA:E2:84:14:28:79
33${linklocal_addr_format}     fe80::[0-9a-f:]+$
34${link_local_addr}           fe80::
35${link_local_prefix_len}     10
36${ipv6_leading_zero}         2001:0022:0033::0111
37${ipv6_firsthextet_zero}    2001:0022:1133::1111
38${ipv6_eliminate_zero}       2001:22:33::111
39${ipv6_eliminate_zero1}      2001:22:1133::1111
40${ipv6_contigeous_zero}      2001:0022:0000:0000:1:2:3:8
41${ipv6_zero_compression}     2001:22::1:2:3:8
42
43*** Test Cases ***
44
45Get IPv6 Address And Verify
46    [Documentation]  Get IPv6 Address And Verify.
47    [Tags]  Get_IPv6_Address_And_Verify
48
49    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
50      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
51    END
52
53
54Get PrefixLength And Verify
55    [Documentation]  Get IPv6 prefix length and verify.
56    [Tags]  Get_PrefixLength_And_Verify
57
58    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
59      Verify IPv6 On BMC  ${ipv6_network_configuration['PrefixLength']}
60    END
61
62
63Get IPv6 Default Gateway And Verify
64    [Documentation]  Get IPv6 default gateway and verify.
65    [Tags]  Get_IPv6_Default_Gateway_And_Verify
66
67    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
68    ${ipv6_gateway}=  Get From Dictionary  ${resp.dict}  IPv6DefaultGateway
69    Verify IPv6 Default Gateway On BMC  ${ipv6_gateway}
70
71
72Verify All Configured IPv6 And PrefixLength On BMC
73    [Documentation]  Verify IPv6 address and its prefix length on BMC.
74    [Tags]  Verify_All_Configured_IPv6_And_PrefixLength_On_BMC
75
76    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
77      Verify IPv6 And PrefixLength  ${ipv6_network_configuration['Address']}
78      ...  ${ipv6_network_configuration['PrefixLength']}
79    END
80
81
82Configure IPv6 Address And Verify
83    [Documentation]  Configure IPv6 address and verify.
84    [Tags]  Configure_IPv6_Address_And_Verify
85    [Teardown]  Run Keywords
86    ...  Delete IPv6 Address  ${test_ipv6_addr}  AND  Test Teardown Execution
87    [Template]  Configure IPv6 Address On BMC
88
89
90    # IPv6 address     Prefix length
91    ${test_ipv6_addr}  ${test_prefix_length}
92
93
94Configure IPv6 Address On BMC And Verify On Both Interfaces
95    [Documentation]  Configure IPv6 address on both interfaces and verify.
96    [Tags]  Configure_IPv6_Address_On_BMC_And_Verify_On_Both_Interfaces
97    [Teardown]  Run Keywords
98    ...  Delete IPv6 Address  ${test_ipv6_addr}  ${1}
99    ...  AND  Delete IPv6 Address  ${test_ipv6_addr1}  ${2}
100    ...  AND  Test Teardown Execution
101
102    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}  ${None}  ${1}
103    Configure IPv6 Address On BMC  ${test_ipv6_addr1}  ${test_prefix_length}  ${None}  ${2}
104
105    Verify All The Addresses Are Intact  ${1}
106    Verify All The Addresses Are Intact  ${2}
107    ...    ${eth1_initial_ipv4_addressorigin_list}  ${eth1_initial_ipv4_addr_list}
108
109    # Verify Static IPv6 on eth0
110    @{ipv6_addressorigin_list}  ${ipv6_static_addr}=
111    ...  Get Address Origin List And Address For Type  Static  ${1}
112    Should Contain  ${ipv6_addressorigin_list}  Static
113    Should Not Be Empty  ${ipv6_static_addr}  msg=${ipv6_static_addr} address is not present
114
115    # Verify Static IPv6 on eth1
116    @{ipv6_addressorigin_list}  ${ipv6_static_addr}=
117    ...  Get Address Origin List And Address For Type  Static  ${2}
118    Should Contain  ${ipv6_addressorigin_list}  Static
119    Should Not Be Empty  ${ipv6_static_addr}  msg=${ipv6_static_addr} address is not present
120
121
122Delete IPv6 Address And Verify
123    [Documentation]  Delete IPv6 address and verify.
124    [Tags]  Delete_IPv6_Address_And_Verify
125
126    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
127
128    Delete IPv6 Address  ${test_ipv6_addr}
129
130
131Modify IPv6 Address And Verify
132    [Documentation]  Modify IPv6 address and verify.
133    [Tags]  Modify_IPv6_Address_And_Verify
134    [Teardown]  Run Keywords
135    ...  Delete IPv6 Address  ${test_ipv6_addr1}  AND  Test Teardown Execution
136
137    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
138
139    Modify IPv6 Address  ${test_ipv6_addr}  ${test_ipv6_addr1}  ${test_prefix_length}
140
141
142Verify Persistency Of IPv6 After BMC Reboot
143    [Documentation]  Verify persistency of IPv6 after BMC reboot.
144    [Tags]  Verify_Persistency_Of_IPv6_After_BMC_Reboot
145    [Teardown]  Run Keywords
146    ...  Delete IPv6 Address  ${test_ipv6_addr}  AND  Test Teardown Execution
147
148    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
149
150    Redfish OBMC Reboot (off)  stack_mode=skip
151
152    # Verifying persistency of IPv6.
153    Verify IPv6 On BMC  ${test_ipv6_addr}
154
155
156Enable SLAAC On BMC And Verify
157    [Documentation]  Enable SLAAC on BMC and verify.
158    [Tags]  Enable_SLAAC_On_BMC_And_Verify
159
160    Set SLAAC Configuration State And Verify  ${True}
161
162
163Enable DHCPv6 Property On BMC And Verify
164    [Documentation]  Enable DHCPv6 property on BMC and verify.
165    [Tags]  Enable_DHCPv6_Property_On_BMC_And_Verify
166
167    Set And Verify DHCPv6 Property  Enabled
168
169
170Disable DHCPv6 Property On BMC And Verify
171    [Documentation]  Disable DHCPv6 property on BMC and verify.
172    [Tags]  Disable_DHCPv6_Property_On_BMC_And_Verify
173
174    Set And Verify DHCPv6 Property  Disabled
175
176
177Verify Persistency Of DHCPv6 On Reboot
178    [Documentation]  Verify persistency of DHCPv6 property on reboot.
179    [Tags]  Verify_Persistency_Of_DHCPv6_On_Reboot
180
181    Set And Verify DHCPv6 Property  Enabled
182    Redfish OBMC Reboot (off)       stack_mode=skip
183    Verify DHCPv6 Property          Enabled
184
185
186Verify Persistency Of DHCPv6 On BMC Reboot On Eth1
187    [Documentation]  Verify persistency of DHCPv6 property and
188    ...    all existing n/w configurations on BMC reboot on eth1.
189    [Tags]  Verify_Persistency_Of_DHCPv6_On_BMC_Reboot_On_Eth1
190    [Setup]  Set And Verify DHCPv6 Property  Enabled  ${2}
191
192    Redfish OBMC Reboot (off)  stack_mode=skip
193
194    Verify DHCPv6 Property  Enabled  ${2}
195
196    Verify All The Addresses Are Intact  ${1}
197    Verify All The Addresses Are Intact  ${2}
198    ...    ${eth1_initial_ipv4_addressorigin_list}  ${eth1_initial_ipv4_addr_list}
199
200
201Verify Persistency Of SLAAC On BMC Reboot On Eth0
202    [Documentation]  Verify persistency of SLAAC property on reboot on eth0.
203    [Tags]  Verify_Persistency_Of_SLAAC_On_BMC_Reboot_On_Eth0
204
205    Set SLAAC Configuration State And Verify  ${True}  [${HTTP_OK}]  ${1}  ${False}
206    Redfish OBMC Reboot (off)      stack_mode=skip
207    Verify SLAAC Property          ${True}
208
209
210Verify Persistency Of SLAAC On BMC Reboot On Eth1
211    [Documentation]  Verify persistency of SLAAC property on reboot on eth1.
212    [Tags]  Verify_Persistency_Of_SLAAC_On_BMC_Reboot_On_Eth1
213
214    Set SLAAC Configuration State And Verify  ${True}  [${HTTP_OK}]  ${2}  ${False}
215    Redfish OBMC Reboot (off)      stack_mode=skip
216    Verify SLAAC Property          ${True}  ${2}
217
218
219Configure Invalid Static IPv6 And Verify
220    [Documentation]  Configure invalid static IPv6 and verify.
221    [Tags]  Configure_Invalid_Static_IPv6_And_Verify
222    [Template]  Configure IPv6 Address On BMC
223
224    #invalid_ipv6            prefix length           valid_status_code
225    ${ipv4_hexword_addr}     ${test_prefix_length}   ${HTTP_BAD_REQUEST}
226    ${invalid_hexadec_ipv6}  ${test_prefix_length}   ${HTTP_BAD_REQUEST}
227    ${ipv6_multi_short}      ${test_prefix_length}   ${HTTP_BAD_REQUEST}
228
229
230Configure IPv6 Static Default Gateway And Verify
231    [Documentation]  Configure IPv6 static default gateway and verify.
232    [Tags]  Configure_IPv6_Static_Default_Gateway_And_Verify
233    [Template]  Configure IPv6 Static Default Gateway On BMC
234
235    # static_def_gw              prefix length           valid_status_code
236    ${ipv6_gw_addr}              ${prefix_length_def}    ${HTTP_OK}
237    ${invalid_staticv6_gateway}  ${test_prefix_length}   ${HTTP_BAD_REQUEST}
238
239
240Modify Static Default Gateway And Verify
241    [Documentation]  Modify static default gateway and verify.
242    [Tags]  Modify_Static_Default_Gateway_And_Verify
243    [Setup]  Configure IPv6 Static Default Gateway On BMC  ${ipv6_gw_addr}  ${prefix_length_def}
244
245    Modify IPv6 Static Default Gateway On BMC  ${test_ipv6_addr1}  ${prefix_length_def}  ${HTTP_OK}  ${ipv6_gw_addr}
246
247
248Delete IPv6 Static Default Gateway And Verify
249    [Documentation]  Delete IPv6 static default gateway and verify.
250    [Tags]  Delete_IPv6_Static_Default_Gateway_And_Verify
251    [Setup]  Configure IPv6 Static Default Gateway On BMC  ${ipv6_gw_addr}  ${prefix_length_def}
252
253    Delete IPv6 Static Default Gateway  ${ipv6_gw_addr}
254
255
256Verify Coexistence Of Linklocalv6 And Static IPv6 On BMC
257    [Documentation]  Verify linklocalv6 And static IPv6 both exist.
258    [Tags]  Verify_Coexistence_Of_Linklocalv6_And_Static_IPv6_On_BMC
259    [Setup]  Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
260    [Teardown]  Delete IPv6 Address  ${test_ipv6_addr}
261
262    Check Coexistence Of Linklocalv6 And Static IPv6
263
264
265Verify IPv6 Linklocal Address Is In Correct Format
266    [Documentation]  Verify linklocal address has network part as fe80 and
267    ...  host part as EUI64.
268    [Tags]  Verify_IPv6_Linklocal_Address_Is_In_Correct_Format
269
270    Check If Linklocal Address Is In Correct Format
271
272
273Verify BMC Gets SLAAC Address On Enabling SLAAC
274    [Documentation]  On enabling SLAAC verify SLAAC address comes up.
275    [Tags]  Verify_BMC_Gets_SLAAC_Address_On_Enabling_SLAAC
276    [Setup]  Set SLAAC Configuration State And Verify  ${False}
277
278    Set SLAAC Configuration State And Verify  ${True}
279    Sleep  ${NETWORK_TIMEOUT}
280    Check BMC Gets SLAAC Address
281
282
283Verify Enable And Disable SLAAC On Both Interfaces
284    [Documentation]  Verify enable and disable SLAAC on both the interfaces.
285    [Tags]  Verify_Enable_And_Disable_SLAAC_On_Both_Interfaces
286    [Setup]  Get The Initial SLAAC Settings
287    [Template]  Set And Verify SLAAC Property On Both Interfaces
288    [Teardown]  Run Keywords  Set SLAAC Configuration State And Verify  ${slaac_channel_1}  [${HTTP_OK}]  ${1}
289    ...  AND  Set SLAAC Configuration State And Verify  ${slaac_channel_2}  [${HTTP_OK}]  ${2}
290
291    # slaac_eth0       slaac_eth1
292    ${True}            ${True}
293    ${True}            ${False}
294    ${False}           ${True}
295    ${False}           ${False}
296
297
298Configure And Validate DHCPv6 Settings On Both Network Interfaces
299    [Documentation]  Configure and validate the DHCPv6 enable/disable settings
300    ...  on both network interfaces.
301    [Tags]  Configure_And_Validate_DHCPv6_Settings_On_Both_Network_Interfaces
302    [Setup]  Get The Initial DHCPv6 Settings
303    [Template]  Set And Verify DHCPv6 Property On Both Interfaces
304    [Teardown]  Run Keywords  Set And Verify DHCPv6 Property  ${dhcpv6_channel_1}  ${1}  AND
305    ...  Set And Verify DHCPv6 Property  ${dhcpv6_channel_2}  ${2}
306
307    # DHCPv6_eth0      DHCPv6_eth1
308    Enabled            Enabled
309    Enabled            Disabled
310    Disabled           Enabled
311    Disabled           Disabled
312
313
314Verify Autoconfig Is Present On Ethernet Interface
315    [Documentation]  Verify autoconfig is present on ethernet interface.
316    [Tags]  Verify_Autoconfig_Is_Present_On_Ethernet_Interface
317
318    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
319    Should Contain  ${resp.dict}  StatelessAddressAutoConfig
320
321
322Verify Interface ID Of SLAAC And LinkLocal Addresses Are Same
323    [Documentation]  Validate interface id of SLAAC and link-local addresses are same.
324    [Tags]  Verify_Interface_ID_Of_SLAAC_And_LinkLocal_Addresses_Are_Same
325
326    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
327    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=  Get Address Origin List And Address For Type  SLAAC
328
329    ${linklocal_interface_id}=  Get Interface ID Of IPv6  ${ipv6_linklocal_addr}
330    ${slaac_interface_id}=  Get Interface ID Of IPv6  ${ipv6_slaac_addr}
331
332    Should Be Equal    ${linklocal_interface_id}    ${slaac_interface_id}
333
334
335Verify Persistency Of Link Local IPv6 On BMC Reboot
336    [Documentation]  Verify persistency of link local on BMC reboot.
337    [Tags]  Verify_Persistency_Of_Link_Local_IPv6_On_BMC_Reboot
338
339    # Capturing the linklocal before reboot.
340    @{ipv6_address_origin_list}  ${linklocal_addr_before_reboot}=
341    ...  Get Address Origin List And Address For Type  LinkLocal
342
343    # Rebooting BMC.
344    Redfish OBMC Reboot (off)  stack_mode=skip
345
346    @{ipv6_address_origin_list}  ${linklocal_addr_after_reboot}=
347    ...  Get Address Origin List And Address For Type  LinkLocal
348
349    # Verifying the linklocal must be the same before and after reboot.
350    Should Be Equal    ${linklocal_addr_before_reboot}    ${linklocal_addr_after_reboot}
351    ...    msg=IPv6 Linklocal address has changed after reboot.
352
353
354Modify MAC and Verify BMC Reinitializing Linklocal
355    [Documentation]  Modify MAC and verify BMC reinitializing linklocal.
356    [Tags]  Modify_MAC_and_Verify_BMC_Reinitializing_Linklocal
357    [Teardown]  Configure MAC Settings  ${original_address}
358
359    ${original_address}=  Get BMC MAC Address
360    @{ipv6_addressorigin_list}  ${ipv6_before_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
361
362    # Modify MAC Address Of Ethernet Interface.
363    Configure MAC Settings  ${new_mac_addr}
364    Sleep  30s
365    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
366    @{ipv6_addressorigin_list}  ${ipv6_linklocal_after_addr}=  Get Address Origin List And Address For Type  LinkLocal
367
368    # Verify whether the linklocal has changed and is in the the correct format.
369    Check If Linklocal Address Is In Correct Format
370    Should Not Be Equal    ${ipv6_before_linklocal_addr}    ${ipv6_linklocal_after_addr}
371
372
373Add Multiple IPv6 Address And Verify
374    [Documentation]  Add multiple IPv6 address and verify.
375    [Tags]  Add_Multiple_IPv6_Address_And_Verify
376    [Teardown]  Run Keywords
377    ...  Delete IPv6 Address  ${test_ipv6_addr}  AND  Delete IPv6 Address  ${test_ipv6_addr1}
378    ...  AND  Test Teardown Execution
379
380    Configure Multiple IPv6 Address on BMC  ${test_prefix_length}
381
382
383Verify Coexistence Of Static IPv6 And SLAAC On BMC
384    [Documentation]  Verify static IPv6 And SLAAC both coexist.
385    [Tags]  Verify_Coexistence_Of_Static_IPv6_And_SLAAC_On_BMC
386    [Setup]  Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
387             Set SLAAC Configuration State And Verify  ${True}
388    [Teardown]  Delete IPv6 Address  ${test_ipv6_addr}
389
390    Sleep  ${NETWORK_TIMEOUT}s
391
392    Check Coexistence Of Static IPv6 And SLAAC
393
394
395Verify Coexistence Of Link Local And DHCPv6 On BMC
396    [Documentation]  Verify link local And dhcpv6 both coexist.
397    [Tags]  Verify_Coexistence_Of_Link_Local_And_DHCPv6_On_BMC
398    [Setup]  Set DHCPv6 Property  Enabled  ${2}
399
400    Sleep  ${NETWORK_TIMEOUT}s
401
402    Check Coexistence Of Link Local And DHCPv6
403
404
405Verify Coexistence Of Link Local And SLAAC On BMC
406    [Documentation]  Verify link local And SLAAC both coexist.
407    [Tags]  Verify_Coexistence_Of_Link_Local_And_SLAAC_On_BMC
408    [Setup]  Set SLAAC Configuration State And Verify  ${True}
409
410    Sleep  ${NETWORK_TIMEOUT}s
411
412    Check Coexistence Of Link Local And SLAAC
413
414
415Verify Coexistence Of All IPv6 Type Addresses On BMC
416    [Documentation]  Verify coexistence of link local, static, DHCPv6 and SLAAC ipv6 addresses.
417    [Tags]  Verify_Coexistence_Of_All_IPv6_Type_Addresses_On_BMC
418    [Setup]  Run Keywords  Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
419    ...      AND  Get The Initial DHCPv6 Setting On Each Interface  ${1}
420    ...      AND  Set And Verify DHCPv6 Property  Enabled
421    ...      AND  Get The Initial SLAAC Setting On Each Interface  ${1}
422    ...      AND  Set SLAAC Configuration State And Verify  ${True}
423    [Teardown]  Run Keywords  Delete IPv6 Address  ${test_ipv6_addr}
424    ...         AND  Set And Verify DHCPv6 Property  ${dhcpv6_channel_1}  ${1}
425    ...         AND  Set SLAAC Configuration State And Verify  ${slaac_channel_1}  [${HTTP_OK}]  ${1}
426
427    Sleep  ${NETWORK_TIMEOUT}s
428
429    # Verify link local, static, DHCPv6 and SLAAC ipv6 addresses coexist.
430    Verify The Coexistence Of The Address Type  LinkLocal  Static  DHCPv6  SLAAC
431
432
433Configure Link Local IPv6 Address And Verify
434    [Documentation]  Configure link local IPv6 address and verify.
435    [Tags]  Configure_Link_Local_IPv6_Address_And_Verify
436
437    Configure IPv6 Address On BMC  ${link_local_addr}  ${link_local_prefix_len}
438
439    # Verify the address origin contains link local.
440    @{ipv6_address_origin_list}  ${ipv6_link_local_addr}=
441    ...    Get Address Origin List And Address For Type  LinkLocal
442
443    ${count}=  Evaluate  ${ipv6_address_origin_list}.count("LinkLocal")
444
445    Should Be Equal As Integers  ${count}  2
446
447
448Configure Valid IPv6 Address And Verify
449    [Documentation]  Configure valid IPv6 address and verify it is getting added as expected format.
450    [Tags]  Configure_Valid_IPv6_Address_And_Verify
451    [Teardown]  Run Keywords
452    ...  Delete IPv6 Address  ${ipv6_zero_compression}
453    ...    AND  Delete IPv6 Address  ${ipv6_eliminate_zero}
454    ...    AND  Delete IPv6 Address  ${ipv6_eliminate_zero1}
455    ...    AND  Test Teardown Execution
456    [Template]  Configure IPv6 Address On BMC
457
458    # IPv6 address            prefix length          IPv6 address verified.
459    ${ipv6_contigeous_zero}   ${test_prefix_length}  ${ipv6_zero_compression}
460    ${ipv6_firsthextet_zero}  ${test_prefix_length}  ${ipv6_eliminate_zero1}
461    ${ipv6_leading_zero}      ${test_prefix_length}  ${ipv6_eliminate_zero}
462
463
464Verify Coexistence Of IPv6 Addresses Type Combination On BMC
465    [Documentation]  Verify coexistence of IPv6 addresses type combination on BMC.
466    [Tags]  Verify_Coexistence_Of_IPv6_Addresses_Type_Combination_On_BMC
467    [Setup]  Run Keywords
468    ...    Get The Initial DHCPv6 Setting On Each Interface  ${1}
469    ...    AND  Get The Initial SLAAC Setting On Each Interface  ${1}
470    [Teardown]  Run Keywords
471    ...    Set And Verify DHCPv6 Property  ${dhcpv6_channel_1}  ${1}
472    ...    AND  Set SLAAC Configuration State And Verify  ${slaac_channel_1}  [${HTTP_OK}]  ${1}
473    [Template]  Verify IPv6 Addresses Coexist
474
475   # type1  type2.
476    Static  DHCPv6
477    DHCPv6  SLAAC
478    SLAAC   Static
479    Static  Static
480
481
482Verify Eth0 Static IPv4 Functions Properly In The Presence Of DHCPv6
483    [Documentation]  Verify eth0 static IPv4 functions properly in the presence of DHCPv6.
484    [Tags]  Verify_Eth0_Static_IPv4_Functions_Properly_In_The_Presence_Of_DHCPv6
485    [Setup]  Set And Verify DHCPv6 Property  Enabled
486
487    # Verify that on enabling DHCPv6 other configurations are not impacted.
488    Sleep  ${NETWORK_TIMEOUT}
489    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
490
491    Verify All The Addresses Are Intact  ${1}
492    Verify All The Addresses Are Intact  ${2}
493    ...    ${eth1_initial_ipv4_addressorigin_list}  ${eth1_initial_ipv4_addr_list}
494
495
496Disable And Verify AutoConfig On Both Interfaces When AutoConfig Enabled
497    [Documentation]  Enable and then disable both eth0 & eth1 with auto-config and
498    ...    check both interfaces gets disabled with SLAAC.
499    [Tags]  Disable_And_Verify_AutoConfig_On_Both_Interfaces_When_AutoConfig_Enabled
500    [Setup]  Set And Verify SLAAC Property On Both Interfaces  ${True}  ${True}
501    [Template]  Set And Verify SLAAC Property On Both Interfaces
502
503    # slaac_eth0       slaac_eth1.
504    ${False}           ${False}
505
506
507Verify Eth1 DHCPv4 Functionality In The Presence Of Static IPv6
508    [Documentation]  Verify eth1 dhcpv4 functionality in the presence of Static IPv6
509    ...    and verify link local IPv6 and SLAAC.
510    ...    Run on setup with DHCPv4 available on eth1.
511    [Tags]  Verify_Eth1_DHCPv4_Functionality_In_The_Presence_Of_Static_IPv6
512    [Setup]  Run Keywords
513    ...  Set DHCPEnabled To Enable Or Disable  True  eth1
514    ...  AND  Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}  ${None}  ${2}
515    ...  AND  Set SLAAC Configuration State And Verify  ${True}  [${HTTP_OK}]  ${2}
516
517    # Verify presence of static IPv6 address and origin.
518    @{ipv6_address_origin_list}  ${static_ipv6_addr}=
519    ...  Get Address Origin List And Address For Type  Static  ${2}
520    Should Contain  ${ipv6_address_origin_list}  Static
521    Should Not Be Empty  ${static_ipv6_addr}  msg=${test_ipv6_addr} address is not present
522
523    # Verify presence of link local IPv6 address and origin.
524    @{ipv6_address_origin_list}  ${link_local_ipv6_addr}=
525    ...  Get Address Origin List And Address For Type  LinkLocal  ${2}
526    Should Contain  ${ipv6_address_origin_list}  LinkLocal
527    Should Match Regexp  ${link_local_ipv6_addr}  ${linklocal_addr_format}
528    Should Not Be Empty  ${link_local_ipv6_addr}  msg=link local IPv6 address is not present
529
530    # Verify presence of SLAAC address and origin.
531    Sleep  ${NETWORK_TIMEOUT}s
532    @{ipv6_address_origin_list}  ${slaac_addr}=
533    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
534    Should Contain  ${ipv6_address_origin_list}  SLAAC
535    Should Not Be Empty  ${slaac_addr}  msg=SLAAC address is not present
536
537    Verify DHCPv4 Functionality On Eth1
538
539
540Verify Eth1 DHCPv4 Functionality In The Presence Of DHCPv6
541    [Documentation]  Verify eth1 dhcpv4 functionality in the presence of dhcpv6.
542    ...    Run on setup with DHCPv4 available on eth1.
543    [Tags]  Verify_Eth1_DHCPv4_Functionality_In_The_Presence_Of_DHCPv6
544    [Setup]  Run Keywords
545    ...  Set DHCPEnabled To Enable Or Disable  True  eth1
546    ...  AND  Set And Verify DHCPv6 Property  Enabled  ${2}
547
548    # Verify presence of DHCPv6 address and origin.
549    @{ipv6_address_origin_list}  ${dhcpv6_addr}=
550    ...  Get Address Origin List And Address For Type  DHCPv6  ${2}
551    Should Contain  ${ipv6_address_origin_list}  DHCPv6
552    Should Not Be Empty  ${dhcpv6_addr}  msg=dhcpv6 address is not present
553
554    Verify DHCPv4 Functionality On Eth1
555
556
557*** Keywords ***
558
559Suite Setup Execution
560    [Documentation]  Do suite setup execution.
561
562    Redfish.Login
563    ${active_channel_config}=  Get Active Channel Config
564    Set Suite Variable  ${active_channel_config}
565
566    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
567
568    Set Suite variable  ${ethernet_interface}
569
570    # Get initial IPv4 and IPv6 addresses and address origins for eth0.
571    ${initial_ipv4_addressorigin_list}  ${initial_ipv4_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv4Addresses
572    ${initial_ipv6_addressorigin_list}  ${initial_ipv6_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses
573
574    Set Suite Variable   ${initial_ipv4_addressorigin_list}
575    Set Suite Variable   ${initial_ipv4_addr_list}
576    Set Suite Variable   ${initial_ipv6_addressorigin_list}
577    Set Suite Variable   ${initial_ipv6_addr_list}
578
579    # Get initial IPv4 and IPv6 addresses and address origins for eth1.
580    ${eth1_initial_ipv4_addressorigin_list}  ${eth1_initial_ipv4_addr_list}=
581    ...  Get Address Origin List And IPv4 or IPv6 Address  IPv4Addresses  ${2}
582    ${eth1_initial_ipv6_addressorigin_list}  ${eth1_initial_ipv6_addr_list}=
583    ...  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses  ${2}
584    Set Suite Variable   ${eth1_initial_ipv4_addressorigin_list}
585    Set Suite Variable   ${eth1_initial_ipv4_addr_list}
586    Set Suite Variable   ${eth1_initial_ipv6_addressorigin_list}
587    Set Suite Variable   ${eth1_initial_ipv6_addr_list}
588
589
590Test Setup Execution
591    [Documentation]  Test setup execution.
592
593    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
594    Set Test Variable  @{ipv6_network_configurations}
595
596    # Get BMC IPv6 address and prefix length.
597    ${ipv6_data}=  Get BMC IPv6 Info
598    Set Test Variable  ${ipv6_data}
599
600
601Test Teardown Execution
602    [Documentation]  Test teardown execution.
603
604    FFDC On Test Case Fail
605
606
607Get IPv6 Network Configuration
608    [Documentation]  Get Ipv6 network configuration.
609    [Arguments]  ${channel_number}=${CHANNEL_NUMBER}
610
611    # Description of argument(s):
612    # channel_number  Channel number (1 - eth0 and 2 - eth1).
613
614    # Sample output:
615    # {
616    #  "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0",
617    #  "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
618    #   "DHCPv4": {
619    #    "DHCPEnabled": false,
620    #    "UseDNSServers": false,
621    #    "UseDomainName": true,
622    #    "UseNTPServers": false
623    #  },
624    #  "DHCPv6": {
625    #    "OperatingMode": "Disabled",
626    #    "UseDNSServers": false,
627    #    "UseDomainName": true,
628    #    "UseNTPServers": false
629    #  },
630    #  "Description": "Management Network Interface",
631    #  "FQDN": "localhost",
632    #  "HostName": "localhost",
633    #  "IPv4Addresses": [
634    #    {
635    #      "Address": "xx.xx.xx.xx",
636    #      "AddressOrigin": "Static",
637    #      "Gateway": "xx.xx.xx.1",
638    #      "SubnetMask": "xx.xx.xx.0"
639    #    },
640    #    {
641    #      "Address": "169.254.xx.xx",
642    #      "AddressOrigin": "IPv4LinkLocal",
643    #      "Gateway": "0.0.0.0",
644    #      "SubnetMask": "xx.xx.0.0"
645    #    },
646    #  ],
647    #  "IPv4StaticAddresses": [
648    #    {
649    #      "Address": "xx.xx.xx.xx",
650    #      "AddressOrigin": "Static",
651    #      "Gateway": "xx.xx.xx.1",
652    #      "SubnetMask": "xx.xx.0.0"
653    #    }
654    # }
655    #  ],
656    #  "IPv6AddressPolicyTable": [],
657    #  "IPv6Addresses": [
658    #    {
659    #      "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
660    #      "AddressOrigin": "LinkLocal",
661    #      "AddressState": null,
662    #      "PrefixLength": xx
663    #    }
664    #  ],
665    #  "IPv6DefaultGateway": "",
666    #  "IPv6StaticAddresses": [
667    #    { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
668    #      "AddressOrigin": "Static",
669    #      "AddressState": null,
670    #      "PrefixLength": xxx
671    #    }
672    #  ],
673    #  "Id": "eth0",
674    #  "InterfaceEnabled": true,
675    #  "LinkStatus": "LinkUp",
676    #  "MACAddress": "xx:xx:xx:xx:xx:xx",
677    #  "Name": "Manager Ethernet Interface",
678    #  "NameServers": [],
679    #  "SpeedMbps": 0,
680    #  "StaticNameServers": [],
681    #  "Status": {
682    #    "Health": "OK",
683    #    "HealthRollup": "OK",
684    #    "State": "Enabled"
685    #  },
686    #  "VLANs": {
687    #    "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs"
688
689
690    ${active_channel_config}=  Get Active Channel Config
691    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${channel_number}']['name']}
692
693    @{ipv6_network_configurations}=  Get From Dictionary  ${resp.dict}  IPv6StaticAddresses
694    RETURN  @{ipv6_network_configurations}
695
696
697Verify IPv6 And PrefixLength
698    [Documentation]  Verify IPv6 address and prefix length on BMC.
699    [Arguments]  ${ipv6_addr}  ${prefix_len}
700
701    # Description of the argument(s):
702    # ipv6_addr   IPv6 address to be verified.
703    # prefix_len  PrefixLength value to be verified.
704
705    # Catenate IPv6 address and its prefix length.
706    ${ipv6_with_prefix}=  Catenate  ${ipv6_addr}/${prefix_len}
707
708    # Get IPv6 address details on BMC using IP command.
709    @{ip_data}=  Get BMC IPv6 Info
710
711    # Verify if IPv6 and prefix length is configured on BMC.
712
713    Should Contain  ${ip_data}  ${ipv6_with_prefix}
714    ...  msg=IPv6 and prefix length pair does not exist.
715
716Configure IPv6 Address On BMC
717    [Documentation]  Add IPv6 Address on BMC.
718    [Arguments]  ${ipv6_addr1}  ${prefix_len}  ${ipv6_addr2}=${None}
719    ...  ${channel_number}=${CHANNEL_NUMBER}
720    ...  ${valid_status_codes}=[${HTTP_OK},${HTTP_NO_CONTENT}]
721
722    # Description of argument(s):
723    # ipv6_addr1          IPv6 address to be added (e.g. "2001:0022:0033::0111").
724    # ipv6_addr2          IPv6 address to be Verified (e.g. "2001:22:33::111").
725    # prefix_len          Prefix length for the IPv6 to be added
726    #                     (e.g. "64").
727    # channel_number      Channel number (1 - eth0 and 2 - eth1).
728    # valid_status_codes  Expected return code from patch operation
729    #                     (e.g. "200").
730
731    ${prefix_length}=  Convert To Integer  ${prefix_len}
732    ${empty_dict}=  Create Dictionary
733    ${ipv6_data}=  Create Dictionary  Address=${ipv6_addr1}
734    ...  PrefixLength=${prefix_length}
735
736    ${patch_list}=  Create List
737
738    # Get existing static IPv6 configurations on BMC.
739    ${ipv6_network_configurations}=  Get IPv6 Network Configuration  ${channel_number}
740    ${num_entries}=  Get Length  ${ipv6_network_configurations}
741
742    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
743      Append To List  ${patch_list}  ${empty_dict}
744    END
745
746    # We need not check for existence of IPv6 on BMC while adding.
747    Append To List  ${patch_list}  ${ipv6_data}
748    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
749
750    ${active_channel_config}=  Get Active Channel Config
751    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
752
753    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
754    ...  valid_status_codes=${valid_status_codes}
755
756    IF  ${valid_status_codes} != [${HTTP_OK}, ${HTTP_NO_CONTENT}]
757        Fail  msg=Static address not added correctly
758    END
759
760    # Note: Network restart takes around 15-18s after patch request processing.
761    Sleep  ${NETWORK_TIMEOUT}s
762    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
763
764    # Verify ip address on CLI.
765    IF  '${ipv6_addr2}' != '${None}'
766        Verify IPv6 And PrefixLength  ${ipv6_addr2}  ${prefix_len}
767    ELSE
768        Verify IPv6 And PrefixLength  ${ipv6_addr1}  ${prefix_len}
769    END
770
771    # Verify if existing static IPv6 addresses still exist.
772    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
773      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
774    END
775
776    #Verify redfish and CLI data matches.
777    Validate IPv6 Network Config On BMC
778
779
780Configure Multiple IPv6 Address on BMC
781    [Documentation]  Add multiple IPv6 address on BMC.
782    [Arguments]  ${prefix_len}
783    ...          ${valid_status_codes}=[${HTTP_OK},${HTTP_NO_CONTENT}]
784
785    # Description of argument(s):
786    # prefix_len          Prefix length for the IPv6 to be added
787    #                     (e.g. "64").
788    # valid_status_codes  Expected return code from patch operation
789    #                     (e.g. "200").
790
791    ${ipv6_list}=  Create List  ${test_ipv6_addr}  ${test_ipv6_addr1}
792    ${prefix_length}=  Convert To Integer  ${prefix_len}
793    ${empty_dict}=  Create Dictionary
794    ${patch_list}=  Create List
795
796    # Get existing static IPv6 configurations on BMC.
797    ${ipv6_network_configurations}=  Get IPv6 Network Configuration
798    ${num_entries}=  Get Length  ${ipv6_network_configurations}
799
800    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
801      Append To List  ${patch_list}  ${empty_dict}
802    END
803
804    # We need not check for existence of IPv6 on BMC while adding.
805    FOR  ${ipv6_addr}  IN  @{ipv6_list}
806      ${ipv6_data}=  Create Dictionary  Address=${ipv6_addr}  PrefixLength=${prefix_length}
807      Append To List  ${patch_list}  ${ipv6_data}
808    END
809    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
810
811    ${active_channel_config}=  Get Active Channel Config
812    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
813
814    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
815    ...  valid_status_codes=${valid_status_codes}
816
817    IF  ${valid_status_codes} != [${HTTP_OK}, ${HTTP_NO_CONTENT}]
818        Fail  msg=Static address not added correctly
819    END
820
821    # Note: Network restart takes around 15-18s after patch request processing.
822    Sleep  ${NETWORK_TIMEOUT}s
823    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
824
825    # Verify newly added ip address on CLI.
826    FOR  ${ipv6_addr}  IN  @{ipv6_list}
827      Verify IPv6 And PrefixLength  ${ipv6_addr}  ${prefix_len}
828    END
829
830    # Verify if existing static IPv6 addresses still exist.
831    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
832      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
833    END
834
835    # Get the latest ipv6 network configurations.
836    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
837
838    # Verify newly added ip address on BMC.
839    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
840      Should Contain Match  ${ipv6_list}  ${ipv6_network_configuration['Address']}
841    END
842
843    Validate IPv6 Network Config On BMC
844
845
846Validate IPv6 Network Config On BMC
847    [Documentation]  Check that IPv6 network info obtained via redfish matches info
848    ...              obtained via CLI.
849
850    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
851    ${ipv6_data}=  Get BMC IPv6 Info
852    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
853      Should Contain Match  ${ipv6_data}  ${ipv6_network_configuration['Address']}/*
854      ...  msg=IPv6 address does not exist.
855    END
856
857
858Delete IPv6 Address
859    [Documentation]  Delete IPv6 address of BMC.
860    [Arguments]  ${ipv6_addr}
861    ...    ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
862    ...    ${channel_number}=${CHANNEL_NUMBER}
863
864    # Description of argument(s):
865    # ipv6_addr           IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234").
866    # channel_number     Channel number (1 - eth0 and 2 - eth1).
867    # valid_status_codes  Expected return code from patch operation
868    #                     (e.g. "200").  See prolog of rest_request
869    #                     method in redfish_plus.py for details.
870
871    ${empty_dict}=  Create Dictionary
872    ${patch_list}=  Create List
873
874    @{ipv6_network_configurations}=  Get IPv6 Network Configuration  ${channel_number}
875    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
876        IF  '${ipv6_network_configuration['Address']}' == '${ipv6_addr}'
877            Append To List  ${patch_list}  ${null}
878        ELSE
879            Append To List  ${patch_list}  ${empty_dict}
880        END
881    END
882
883    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
884    ...  ${patch_list}  ${null}  msg=${ipv6_addr} does not exist on BMC
885    Pass Execution If  ${ip_found} == ${False}  ${ipv6_addr} does not exist on BMC
886
887    # Run patch command only if given IP is found on BMC
888    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
889
890    ${active_channel_config}=  Get Active Channel Config
891    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
892
893    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
894    ...  valid_status_codes=${valid_status_codes}
895
896    # Note: Network restart takes around 15-18s after patch request processing
897    Sleep  ${NETWORK_TIMEOUT}s
898    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
899
900    # IPv6 address that is deleted should not be there on BMC.
901    ${delete_status}=  Run Keyword And Return Status  Verify IPv6 On BMC  ${ipv6_addr}
902    IF  '${valid_status_codes}' == '[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]'
903        Should Be True  '${delete_status}' == '${False}'
904    ELSE
905        Should Be True  '${delete_status}' == '${True}'
906    END
907
908    Validate IPv6 Network Config On BMC
909
910
911Modify IPv6 Address
912    [Documentation]  Modify and verify IPv6 address of BMC.
913    [Arguments]  ${ipv6}  ${new_ipv6}  ${prefix_len}
914    ...  ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
915
916    # Description of argument(s):
917    # ipv6                  IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
918    # new_ipv6              New IPv6 address to be configured.
919    # prefix_len            Prefix length value (Range 1 to 128).
920    # valid_status_codes    Expected return code from patch operation
921    #                       (e.g. "200", "201").
922
923    ${empty_dict}=  Create Dictionary
924    ${patch_list}=  Create List
925    ${prefix_length}=  Convert To Integer  ${prefix_len}
926    ${ipv6_data}=  Create Dictionary
927    ...  Address=${new_ipv6}  PrefixLength=${prefix_length}
928
929    # Sample IPv6 network configurations:
930    #  "IPv6AddressPolicyTable": [],
931    #  "IPv6Addresses": [
932    #    {
933    #      "Address": "X002:db8:0:2::XX0",
934    #      "AddressOrigin": "DHCPv6",
935    #      "PrefixLength": 128
936    #    },
937    #    {
938    #      "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX",
939    #      "AddressOrigin": "SLAAC",
940    #      "PrefixLength": 64
941    #    },
942    #    {
943    #      "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
944    #      "AddressOrigin": "Static",
945    #      "PrefixLength": 56
946    #    },
947    #    {
948    #      "Address": “Z002:db8:0:2:a94:efff:fe82:5000",
949    #      "AddressOrigin": "Static",
950    #      "PrefixLength": 56
951    #    },
952    #    {
953    #      "Address": “Xe80::a94:efff:YYYY:XXXX",
954    #      "AddressOrigin": "LinkLocal",
955    #      "PrefixLength": 64
956    #    },
957    #    {
958    #     "Address": “X002:db8:1:2:eff:233:fee:546",
959    #      "AddressOrigin": "Static",
960    #      "PrefixLength": 56
961    #    }
962    #  ],
963    #  "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”,
964    #  "IPv6StaticAddresses": [
965    #    {
966    #      "Address": “X002:db8:0:2:a94:efff:fe82:5000",
967    #      "PrefixLength": 56
968    #    },
969    #    {
970    #      "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
971    #      "PrefixLength": 56
972    #    },
973    #    {
974    #      "Address": “Z002:db8:1:2:eff:233:fee:546",
975    #      "PrefixLength": 56
976    #    }
977    #  ],
978    #  "IPv6StaticDefaultGateways": [],
979
980    # Find the position of IPv6 address to be modified.
981    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
982    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
983      IF  '${ipv6_network_configuration['Address']}' == '${ipv6}'
984          Append To List  ${patch_list}  ${ipv6_data}
985      ELSE
986          Append To List  ${patch_list}  ${empty_dict}
987      END
988    END
989
990    # Modify the IPv6 address only if given IPv6 is found
991    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
992    ...  ${patch_list}  ${ipv6_data}  msg=${ipv6} does not exist on BMC
993    Pass Execution If  ${ip_found} == ${False}  ${ipv6} does not exist on BMC
994
995    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
996
997    ${active_channel_config}=  Get Active Channel Config
998    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
999
1000    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1001    ...  body=&{data}  valid_status_codes=${valid_status_codes}
1002
1003    # Note: Network restart takes around 15-18s after patch request processing.
1004    Sleep  ${NETWORK_TIMEOUT}s
1005    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
1006
1007    # Verify if new IPv6 address is configured on BMC.
1008    Verify IPv6 On BMC  ${new_ipv6}
1009
1010    # Verify if old IPv6 address is erased.
1011    ${cmd_status}=  Run Keyword And Return Status
1012    ...  Verify IPv6 On BMC  ${ipv6}
1013    Should Be Equal  ${cmd_status}  ${False}  msg=Old IPv6 address is not deleted.
1014
1015    Validate IPv6 Network Config On BMC
1016
1017
1018Set SLAAC Configuration State And Verify
1019    [Documentation]  Set SLAAC configuration state.
1020    [Arguments]  ${slaac_state}  ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
1021    ...  ${channel_number}=${CHANNEL_NUMBER}  ${is_slaac_verify_state}=${True}
1022
1023    # Description of argument(s):
1024    # slaac_state             SLAAC state('True' or 'False').
1025    # valid_status_code       Expected valid status codes.
1026    # channel_number          Channel number 1(eth0) or 2(eth1).
1027    # is_slaac_verify_state   Flag to check verification is required.
1028
1029    ${active_channel_config}=  Get Active Channel Config
1030    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
1031
1032    ${data}=  Set Variable If  ${slaac_state} == ${False}  ${DISABLE_SLAAC}  ${ENABLE_SLAAC}
1033    ${resp}=  Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1034    ...  body=${data}  valid_status_codes=${valid_status_codes}
1035    IF  ${is_slaac_verify_state}
1036        Verify SLAAC Property  ${slaac_state}  ${channel_number}
1037    END
1038
1039
1040Verify SLAAC Property
1041    [Documentation]  Verify SLAAC property.
1042    [Arguments]  ${slaac_state}  ${channel_number}=${CHANNEL_NUMBER}
1043
1044    # Description of argument(s):
1045    # slaac_state     SLAAC state('True' or 'False').
1046    # channel_number  Channel number 1(eth0) or 2(eth1).
1047
1048    # Verify SLAAC is set correctly.
1049    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1050    ${slaac_verify}=  Get From Dictionary  ${resp.dict}  StatelessAddressAutoConfig
1051
1052    IF  '${slaac_verify['IPv6AutoConfigEnabled']}' != '${slaac_state}'
1053        Fail  msg=SLAAC not set properly.
1054    END
1055
1056
1057Set And Verify DHCPv6 Property
1058    [Documentation]  Set DHCPv6 property and verify.
1059    [Arguments]  ${dhcpv6_operating_mode}=${Disabled}  ${channel_number}=${CHANNEL_NUMBER}
1060
1061    # Description of argument(s):
1062    # dhcpv6_operating_mode    Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled').
1063    # channel_number           Channel number 1 or 2.
1064
1065    Set DHCPv6 Property  ${dhcpv6_operating_mode}  ${channel_number}
1066    Verify DHCPv6 Property  ${dhcpv6_operating_mode}  ${channel_number}
1067
1068
1069Set DHCPv6 Property
1070    [Documentation]  Set DHCPv6 attribute is enables or disabled.
1071    [Arguments]  ${dhcpv6_operating_mode}=${Disabled}  ${channel_number}=${CHANNEL_NUMBER}
1072
1073    # Description of argument(s):
1074    # dhcpv6_operating_mode    Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled').
1075    # channel_number           Channel number 1 or 2.
1076
1077    ${data}=  Set Variable If  '${dhcpv6_operating_mode}' == 'Disabled'  ${DISABLE_DHCPv6}  ${ENABLE_DHCPv6}
1078    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
1079
1080    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1081    ...  body=${data}  valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
1082
1083
1084Verify DHCPv6 Property
1085    [Documentation]  Verify DHCPv6 settings is enabled or disabled.
1086    [Arguments]  ${dhcpv6_operating_mode}  ${channel_number}=${CHANNEL_NUMBER}
1087
1088    # Description of Argument(s):
1089    # dhcpv6_operating_mode  Enable/ Disable DHCPv6.
1090    # channel_number         Channel number 1 or 2.
1091
1092    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
1093
1094    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1095    ${dhcpv6_verify}=  Get From Dictionary  ${resp.dict}  DHCPv6
1096
1097    Should Be Equal  '${dhcpv6_verify['OperatingMode']}'  '${dhcpv6_operating_mode}'
1098
1099    Sleep  30s
1100
1101    @{ipv6_addressorigin_list}  ${ipv6_dhcpv6_addr}=
1102    ...  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses  ${channel_number}
1103
1104    IF  "${dhcpv6_operating_mode}" == "Enabled"
1105        @{ipv6_addressorigin_list}  ${ipv6_dhcpv6_addr}=
1106        ...  Get Address Origin List And Address For Type  DHCPv6  ${channel_number}
1107        Should Not Be Empty  ${ipv6_dhcpv6_addr}  msg=DHCPv6 must be present.
1108    ELSE
1109        Should Not Contain  ${ipv6_addressorigin_list}  DHCPv6
1110    END
1111
1112
1113
1114Get IPv6 Static Default Gateway
1115    [Documentation]  Get IPv6 static default gateway.
1116
1117    ${active_channel_config}=  Get Active Channel Config
1118    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
1119
1120    @{ipv6_static_defgw_configurations}=  Get From Dictionary  ${resp.dict}  IPv6StaticDefaultGateways
1121    RETURN  @{ipv6_static_defgw_configurations}
1122
1123
1124Configure IPv6 Static Default Gateway On BMC
1125    [Documentation]  Configure IPv6 static default gateway on BMC.
1126    [Arguments]  ${ipv6_gw_addr}  ${prefix_length_def}
1127    ...  ${valid_status_codes}=${HTTP_OK}
1128
1129    # Description of argument(s):
1130    # ipv6_gw_addr          IPv6 Static Default Gateway address to be configured.
1131    # prefix_len_def        Prefix length value (Range 1 to 128).
1132    # valid_status_codes    Expected return code from patch operation
1133    #                       (e.g. "200", "204".)
1134
1135    # Prefix Length is passed as None.
1136    IF   '${prefix_length_def}' == '${None}'
1137        ${ipv6_gw}=  Create Dictionary  Address=${ipv6_gw_addr}
1138    ELSE
1139        ${ipv6_gw}=  Create Dictionary  Address=${ipv6_gw_addr}  Prefix Length=${prefix_length_def}
1140    END
1141
1142    ${ipv6_static_def_gw}=  Get IPv6 Static Default Gateway
1143
1144    ${num_entries}=  Get Length  ${ipv6_static_def_gw}
1145
1146    ${patch_list}=  Create List
1147    ${empty_dict}=  Create Dictionary
1148
1149    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
1150      Append To List  ${patch_list}  ${empty_dict}
1151    END
1152
1153    ${valid_status_codes}=  Set Variable If  '${valid_status_codes}' == '${HTTP_OK}'
1154    ...  ${HTTP_OK},${HTTP_NO_CONTENT}
1155    ...  ${valid_status_codes}
1156
1157    Append To List  ${patch_list}  ${ipv6_gw}
1158    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
1159
1160    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1161    ...  body=${data}  valid_status_codes=[${valid_status_codes}]
1162
1163    # Verify the added static default gateway is present in Redfish Get Output.
1164    ${ipv6_staticdef_gateway}=  Get IPv6 Static Default Gateway
1165
1166    ${ipv6_static_def_gw_list}=  Create List
1167    FOR  ${ipv6_staticdef_gateway}  IN  @{ipv6_staticdef_gateway}
1168        ${value}=    Get From Dictionary    ${ipv6_staticdef_gateway}    Address
1169        Append To List  ${ipv6_static_def_gw_list}  ${value}
1170    END
1171
1172    IF  '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
1173        Should Not Contain  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}
1174    ELSE
1175        Should Contain  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}
1176    END
1177
1178
1179Modify IPv6 Static Default Gateway On BMC
1180    [Documentation]  Modify and verify IPv6 address of BMC.
1181    [Arguments]  ${ipv6_gw_addr}  ${new_static_def_gw}  ${prefix_length}
1182    ...  ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED}]
1183
1184    # Description of argument(s):
1185    # ipv6_gw_addr          IPv6 static default gateway address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
1186    # new_static_def_gw     New static default gateway address to be configured.
1187    # prefix_length         Prefix length value (Range 1 to 128).
1188    # valid_status_codes    Expected return code from patch operation
1189    #                       (e.g. "200", "204").
1190
1191    ${empty_dict}=  Create Dictionary
1192    ${patch_list}=  Create List
1193    # Prefix Length is passed as None.
1194    IF   '${prefix_length_def}' == '${None}'
1195        ${modified_ipv6_gw_addripv6_data}=  Create Dictionary  Address=${new_static_def_gw}
1196    ELSE
1197        ${modified_ipv6_gw_addripv6_data}=  Create Dictionary  Address=${new_static_def_gw}  Prefix Length=${prefix_length_def}
1198    END
1199
1200    @{ipv6_static_def_gw_list}=  Get IPv6 Static Default Gateway
1201
1202    FOR  ${ipv6_static_def_gw}  IN  @{ipv6_static_def_gw_list}
1203      IF  '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
1204          Append To List  ${patch_list}  ${modified_ipv6_gw_addripv6_data}
1205      ELSE
1206          Append To List  ${patch_list}  ${empty_dict}
1207      END
1208    END
1209
1210    # Modify the IPv6 address only if given IPv6 static default gateway is found.
1211    ${ip_static_def_gw_found}=  Run Keyword And Return Status  List Should Contain Value
1212    ...  ${patch_list}  ${modified_ipv6_gw_addripv6_data}  msg=${ipv6_gw_addr} does not exist on BMC
1213    Pass Execution If  ${ip_static_def_gw_found} == ${False}  ${ipv6_gw_addr} does not exist on BMC
1214
1215    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
1216
1217    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1218    ...  body=&{data}  valid_status_codes=${valid_status_codes}
1219
1220    ${ipv6_staticdef_gateway}=  Get IPv6 Static Default Gateway
1221
1222    ${ipv6_static_def_gw_list}=  Create List
1223    FOR  ${ipv6_staticdef_gateway}  IN  @{ipv6_staticdef_gateway}
1224        ${value}=  Get From Dictionary  ${ipv6_staticdef_gateway}  Address
1225        Append To List  ${ipv6_static_def_gw_list}  ${value}
1226    END
1227
1228    Should Contain  ${ipv6_static_def_gw_list}  ${new_static_def_gw}
1229    # Verify if old static default gateway address is erased.
1230    Should Not Contain  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}
1231
1232
1233Delete IPv6 Static Default Gateway
1234    [Documentation]  Delete IPv6 static default gateway on BMC.
1235    [Arguments]  ${ipv6_gw_addr}
1236    ...          ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
1237
1238    # Description of argument(s):
1239    # ipv6_gw_addr          IPv6 Static Default Gateway address to be deleted.
1240    # valid_status_codes    Expected return code from patch operation
1241    #                       (e.g. "200").
1242
1243    ${patch_list}=  Create List
1244    ${empty_dict}=  Create Dictionary
1245
1246    ${ipv6_static_def_gw_list}=  Create List
1247    @{ipv6_static_defgw_configurations}=  Get IPv6 Static Default Gateway
1248
1249    FOR  ${ipv6_staticdef_gateway}  IN  @{ipv6_static_defgw_configurations}
1250        ${value}=  Get From Dictionary  ${ipv6_staticdef_gateway}  Address
1251        Append To List  ${ipv6_static_def_gw_list}  ${value}
1252    END
1253
1254    ${defgw_found}=  Run Keyword And Return Status  List Should Contain Value
1255    ...  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}  msg=${ipv6_gw_addr} does not exist on BMC
1256    Skip If  ${defgw_found} == ${False}  ${ipv6_gw_addr} does not exist on BMC
1257
1258    FOR  ${ipv6_static_def_gw}  IN  @{ipv6_static_defgw_configurations}
1259        IF  '${ipv6_static_def_gw['Address']}' == '${ipv6_gw_addr}'
1260            Append To List  ${patch_list}  ${null}
1261        ELSE
1262            Append To List  ${patch_list}  ${empty_dict}
1263      END
1264    END
1265
1266    # Run patch command only if given IP is found on BMC.
1267    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
1268
1269    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
1270    ...  valid_status_codes=${valid_status_codes}
1271
1272    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
1273
1274    @{ipv6_static_defgw_configurations}=  Get IPv6 Static Default Gateway
1275    Should Not Contain Match  ${ipv6_static_defgw_configurations}  ${ipv6_gw_addr}
1276    ...  msg=IPv6 Static default gateway does not exist.
1277
1278
1279Check Coexistence Of Linklocalv6 And Static IPv6
1280    [Documentation]  Verify both linklocalv6 and static IPv6 exist.
1281
1282    # Verify the address origin contains static and linklocal.
1283    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
1284
1285    Should Match Regexp  ${ipv6_linklocal_addr}        ${linklocal_addr_format}
1286    Should Contain       ${ipv6_addressorigin_list}    Static
1287
1288
1289Check Coexistence Of Static IPv6 And SLAAC
1290    [Documentation]  Verify both static IPv6 and SLAAC coexist.
1291
1292    # Verify the address origin contains static and slaac.
1293    @{ipv6_addressorigin_list}  ${ipv6_static_addr}=
1294    ...    Get Address Origin List And Address For Type  Static
1295
1296    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
1297    ...    Get Address Origin List And Address For Type  SLAAC
1298
1299
1300Check Coexistence Of Link Local And SLAAC
1301    [Documentation]  Verify both link local and SLAAC coexist.
1302
1303    # Verify the address origin contains SLAAC and link local.
1304    @{ipv6_addressorigin_list}  ${ipv6_link_local_addr}=
1305    ...    Get Address Origin List And Address For Type  LinkLocal
1306
1307    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
1308    ...    Get Address Origin List And Address For Type  SLAAC
1309
1310    Should Match Regexp    ${ipv6_link_local_addr}    ${linklocal_addr_format}
1311
1312
1313Check Coexistence Of Link Local And DHCPv6
1314    [Documentation]  Verify both link local and dhcpv6 coexist.
1315
1316    # Verify the address origin contains dhcpv6 and link local.
1317    @{ipv6_address_origin_list}  ${ipv6_link_local_addr}=
1318    ...    Get Address Origin List And Address For Type  LinkLocal
1319
1320    @{ipv6_address_origin_list}  ${ipv6_dhcpv6_addr}=
1321    ...    Get Address Origin List And Address For Type  DHCPv6
1322
1323    Should Match Regexp    ${ipv6_link_local_addr}    ${linklocal_addr_format}
1324
1325
1326Check If Linklocal Address Is In Correct Format
1327    [Documentation]  Linklocal address has network part fe80 and host part EUI64.
1328
1329    # Fetch the linklocal address.
1330    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
1331
1332    # Follow EUI64 from MAC.
1333    ${system_mac}=  Get BMC MAC Address
1334    ${split_octets}=  Split String  ${system_mac}  :
1335    ${first_octet}=  Evaluate  int('${split_octets[0]}', 16)
1336    ${flipped_hex}=  Evaluate  format(${first_octet} ^ 2, '02x')
1337    ${grp1}=  Evaluate  re.sub(r'^0+', '', '${flipped_hex}${split_octets[1]}')  modules=re
1338    ${grp2}=  Evaluate  re.sub(r'^0+', '', '${split_octets[2]}ff')  modules=re
1339    ${grp3}=  Evaluate  re.sub(r'^0+', '', '${split_octets[4]}${split_octets[5]}')  modules=re
1340    ${linklocal}=  Set Variable  fe80::${grp1}:${grp2}:fe${split_octets[3]}:${grp3}
1341
1342    # Verify the linklocal obtained is the same as on the machine.
1343    Should Be Equal  ${linklocal}  ${ipv6_linklocal_addr}
1344
1345
1346Check BMC Gets SLAAC Address
1347    [Documentation]  Check BMC gets slaac address.
1348
1349    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=  Get Address Origin List And Address For Type  SLAAC
1350
1351
1352Get The Initial DHCPv6 Setting On Each Interface
1353    [Documentation]  Get the initial DHCPv6 setting of each interface.
1354    [Arguments]  ${channel_number}
1355
1356    # Description of the argument(s):
1357    # channel_number    Channel number 1 or 2.
1358
1359    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
1360    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1361    ${initial_dhcpv6_iface}=  Get From Dictionary  ${resp.dict}  DHCPv6
1362    IF  ${channel_number}==${1}
1363        Set Test Variable  ${dhcpv6_channel_1}  ${initial_dhcpv6_iface['OperatingMode']}
1364    ELSE
1365        Set Test Variable  ${dhcpv6_channel_2}  ${initial_dhcpv6_iface['OperatingMode']}
1366    END
1367
1368
1369Get The Initial DHCPv6 Settings
1370    [Documentation]  Get the initial DHCPv6 settings of both the interfaces.
1371
1372    Get The Initial DHCPv6 Setting On Each Interface  ${1}
1373    Get The Initial DHCPv6 Setting On Each Interface  ${2}
1374
1375
1376Get The Initial SLAAC Settings
1377    [Documentation]  Get the initial SLAAC settings of both the interfaces.
1378
1379    Get The Initial SLAAC Setting On Each Interface   ${1}
1380    Get The Initial SLAAC Setting On Each Interface   ${2}
1381
1382
1383Get The Initial SLAAC Setting On Each Interface
1384    [Documentation]  Get the initial SLAAC setting of the interface.
1385    [Arguments]  ${channel_number}
1386
1387    # Description of the argument(s):
1388    # channel_number     Channel number 1 or 2.
1389
1390    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
1391    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
1392    ${initial_slaac_iface}=  Get From Dictionary  ${resp.dict}  StatelessAddressAutoConfig
1393    IF  ${channel_number}==${1}
1394        Set Test Variable  ${slaac_channel_1}  ${initial_slaac_iface['IPv6AutoConfigEnabled']}
1395    ELSE
1396        Set Test Variable  ${slaac_channel_2}  ${initial_slaac_iface['IPv6AutoConfigEnabled']}
1397    END
1398
1399
1400Verify All The Addresses Are Intact
1401    [Documentation]  Verify all the addresses and address origins remain intact.
1402    [Arguments]    ${channel_number}=${CHANNEL_NUMBER}
1403    ...  ${initial_ipv4_addressorigin_list}=${initial_ipv4_addressorigin_list}
1404    ...  ${initial_ipv4_addr_list}=${initial_ipv4_addr_list}
1405
1406    # Description of argument(s):
1407    # channel_number                   Channel number 1(eth0) or 2(eth1).
1408    # initial_ipv4_addressorigin_list  Initial IPv4 address origin list.
1409    # initial_ipv4_addr_list           Initial IPv4 address list.
1410
1411    # Verify that it will not impact the IPv4 configuration.
1412    Sleep  ${NETWORK_TIMEOUT}
1413    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
1414
1415    # IPv6 Linklocal address must be present.
1416    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=
1417    ...  Get Address Origin List And Address For Type  LinkLocal  ${channel_number}
1418
1419    # IPv4 addresses must remain intact.
1420    ${ipv4_addressorigin_list}  ${ipv4_addr_list}=
1421    ...  Get Address Origin List And IPv4 or IPv6 Address  IPv4Addresses  ${channel_number}
1422
1423    Should be Equal  ${initial_ipv4_addressorigin_list}  ${ipv4_addressorigin_list}
1424    Should be Equal  ${initial_ipv4_addr_list}  ${ipv4_addr_list}
1425
1426
1427Get Interface ID Of IPv6
1428    [Documentation]  Get interface id of IPv6 address.
1429    [Arguments]    ${ipv6_address}
1430
1431    # Description of the argument(s):
1432    # ${ipv6_address}  IPv6 Address to extract the last 4 hextets.
1433
1434    # Last 64 bits of SLAAC and Linklocal must be the same.
1435    # Sample IPv6 network configurations.
1436    #"IPv6AddressPolicyTable": [],
1437    #  "IPv6Addresses": [
1438    #    {
1439    #      "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
1440    #      "AddressOrigin": "LinkLocal",
1441    #      "AddressState": null,
1442    #      "PrefixLength": xx
1443    #    }
1444    #  ],
1445    #    {
1446    #      "Address": "2002:xxxx:xxxx:xxxx:xxxx",
1447    #      "AddressOrigin": "SLAAC",
1448    #      "PrefixLength": 64
1449    #    }
1450    #  ],
1451
1452    ${split_ip_address}=  Split String  ${ipv6_address}  :
1453    ${missing_ip}=  Evaluate  8 - len(${split_ip_address}) + 1
1454    ${expanded_ip}=  Create List
1455
1456    FOR  ${hextet}  IN  @{split_ip_address}
1457       IF  '${hextet}' == ''
1458           FOR  ${i}  IN RANGE  ${missing_ip}
1459               Append To List  ${expanded_ip}  0000
1460           END
1461       ELSE
1462           Append To List  ${expanded_ip}  ${hextet}
1463       END
1464    END
1465    ${interface_id}=  Evaluate  ':'.join(${expanded_ip}[-4:])
1466    RETURN  ${interface_id}
1467
1468
1469Set And Verify SLAAC Property On Both Interfaces
1470    [Documentation]  Set and verify SLAAC property on both interfaces.
1471    [Arguments]  ${slaac_value_1}  ${slaac_value_2}
1472
1473    # Description of the argument(s):
1474    # slaac_value_1  SLAAC value for channel 1.
1475    # slaac_value_2  SLAAC value for channel 2.
1476
1477    Set SLAAC Configuration State And Verify  ${slaac_value_1}  [${HTTP_OK}]  ${1}
1478    Set SLAAC Configuration State And Verify  ${slaac_value_2}  [${HTTP_OK}]  ${2}
1479
1480    Sleep  30s
1481
1482    # Check SLAAC Settings for eth0.
1483    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
1484    ...  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses  ${1}
1485    IF  "${slaac_value_1}" == "${True}"
1486         Should Not Be Empty  ${ipv6_slaac_addr}  SLAAC
1487    ELSE
1488        Should Not Contain  ${ipv6_addressorigin_list}  SLAAC
1489    END
1490
1491    # Check SLAAC Settings for eth1.
1492    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
1493    ...  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses  ${2}
1494    IF  "${slaac_value_2}" == "${True}"
1495         Should Not Be Empty  ${ipv6_slaac_addr}  SLAAC
1496    ELSE
1497        Should Not Contain  ${ipv6_addressorigin_list}  SLAAC
1498    END
1499
1500    Verify All The Addresses Are Intact  ${1}
1501    Verify All The Addresses Are Intact  ${2}
1502    ...    ${eth1_initial_ipv4_addressorigin_list}  ${eth1_initial_ipv4_addr_list}
1503
1504
1505Set And Verify DHCPv6 Property On Both Interfaces
1506    [Documentation]  Set and verify DHCPv6 property on both interfaces.
1507    [Arguments]  ${dhcpv6_value_1}  ${dhcpv6_value_2}
1508
1509    # Description of the argument(s):
1510    # dhcpv6_value_1  DHCPv6 value for channel 1.
1511    # dhcpv6_value_2  DHCPv6 value for channel 2.
1512
1513    Set And Verify DHCPv6 Property  ${dhcpv6_value_1}  ${1}
1514    Set And Verify DHCPv6 Property  ${dhcpv6_value_2}  ${2}
1515
1516    Verify All The Addresses Are Intact  ${1}
1517    Verify All The Addresses Are Intact  ${2}
1518    ...    ${eth1_initial_ipv4_addressorigin_list}  ${eth1_initial_ipv4_addr_list}
1519
1520
1521Verify IPv6 Addresses Coexist
1522    [Documentation]  Verify IPv6 address type coexist.
1523    [Arguments]   ${ipv6_address_type1}  ${ipv6_address_type2}
1524
1525    # Description of the argument(s):
1526    # ipv6_address_type1  IPv6 address type.
1527    # ipv6_address_type2  IPv6 address type.
1528    # Valid IPv6 address type (Static, DHCPv6, SLAAC).
1529
1530    IF  '${ipv6_address_type1}' == 'Static' and '${ipv6_address_type2}' == 'DHCPv6'
1531        Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
1532        Set And Verify DHCPv6 Property  Enabled
1533    ELSE IF  '${ipv6_address_type1}' == 'DHCPv6' and '${ipv6_address_type2}' == 'SLAAC'
1534        Set And Verify DHCPv6 Property  Enabled
1535        Set SLAAC Configuration State And Verify  ${True}
1536    ELSE IF  '${ipv6_address_type1}' == 'SLAAC' and '${ipv6_address_type2}' == 'Static'
1537        Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
1538        Set SLAAC Configuration State And Verify  ${True}
1539    ELSE IF  '${ipv6_address_type1}' == 'Static' and '${ipv6_address_type2}' == 'Static'
1540        Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
1541        Configure IPv6 Address On BMC  ${test_ipv6_addr1}  ${test_prefix_length}
1542    END
1543
1544    Sleep  ${NETWORK_TIMEOUT}s
1545
1546    # Verify coexistence.
1547    Verify The Coexistence Of The Address Type  ${ipv6_address_type1}  ${ipv6_address_type2}
1548
1549    IF  '${ipv6_address_type1}' == 'Static' or '${ipv6_address_type2}' == 'Static'
1550        Delete IPv6 Address  ${test_ipv6_addr}
1551    END
1552    IF  '${ipv6_address_type1}' == 'Static' and '${ipv6_address_type2}' == 'Static'
1553        Delete IPv6 Address  ${test_ipv6_addr1}
1554    END
1555
1556    Set And Verify DHCPv6 Property  Disabled
1557    Set SLAAC Configuration State And Verify  ${False}
1558
1559
1560Verify DHCPv4 Functionality On Eth1
1561    [Documentation]  Verify DHCPv4 functions are present as expected on eth1.
1562
1563    # Verify eth1 DHCPv4 is enabled.
1564    ${DHCPEnabled}=  Get IPv4 DHCP Enabled Status  ${2}
1565    Should Be Equal  ${DHCPEnabled}  ${True}
1566
1567    # Verify presence of DHCPv4 address origin.
1568    @{ipv4_addressorigin_list}  ${ipv4_addr_list}=
1569    ...  Get Address Origin List And IPv4 or IPv6 Address  IPv4Addresses  ${2}
1570    ${ipv4_addressorigin_list}=  Combine Lists  @{ipv4_addressorigin_list}
1571    Should Contain  ${ipv4_addressorigin_list}  DHCP
1572
1573    # Verify static is not present in address origin when DHPCv4 enabled.
1574    List Should Not Contain Value  ${ipv4_addressorigin_list}  Static