xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_ipv6.robot (revision 5d4b3eb34d5c71af92fd71bd5ef611578c57beaa)
1*** Settings ***
2Documentation  Network interface IPv6 configuration and verification
3               ...  tests.
4
5Resource       ../../lib/bmc_redfish_resource.robot
6Resource       ../../lib/openbmc_ffdc.robot
7Resource       ../../lib/bmc_ipv6_utils.robot
8Resource       ../../lib/external_intf/vmi_utils.robot
9Library        ../../lib/bmc_network_utils.py
10Library        Collections
11
12Test Setup     Test Setup Execution
13Test Teardown  Test Teardown Execution
14Suite Setup    Suite Setup Execution
15
16Test Tags     BMC_IPv6
17
18*** Variables ***
19${test_ipv6_addr}            2001:db8:3333:4444:5555:6666:7777:8888
20${test_ipv6_invalid_addr}    2001:db8:3333:4444:5555:6666:7777:JJKK
21${test_ipv6_addr1}           2001:db8:3333:4444:5555:6666:7777:9999
22
23# Valid prefix length is a integer ranges from 1 to 128.
24${test_prefix_length}        64
25${ipv6_gw_addr}              2002:903:15F:32:9:3:32:1
26${prefix_length_def}         None
27${invalid_staticv6_gateway}  9.41.164.1
28
29*** Test Cases ***
30
31Get IPv6 Address And Verify
32    [Documentation]  Get IPv6 Address And Verify.
33    [Tags]  Get_IPv6_Address_And_Verify
34
35    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
36      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
37    END
38
39
40Get PrefixLength And Verify
41    [Documentation]  Get IPv6 prefix length and verify.
42    [Tags]  Get_PrefixLength_And_Verify
43
44    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
45      Verify IPv6 On BMC  ${ipv6_network_configuration['PrefixLength']}
46    END
47
48
49Get IPv6 Default Gateway And Verify
50    [Documentation]  Get IPv6 default gateway and verify.
51    [Tags]  Get_IPv6_Default_Gateway_And_Verify
52
53    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
54    ${ipv6_gateway}=  Get From Dictionary  ${resp.dict}  IPv6DefaultGateway
55    Verify IPv6 Default Gateway On BMC  ${ipv6_gateway}
56
57
58Verify All Configured IPv6 And PrefixLength On BMC
59    [Documentation]  Verify IPv6 address and its prefix length on BMC.
60    [Tags]  Verify_All_Configured_IPv6_And_PrefixLength_On_BMC
61
62    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
63      Verify IPv6 And PrefixLength  ${ipv6_network_configuration['Address']}
64      ...  ${ipv6_network_configuration['PrefixLength']}
65    END
66
67
68Configure IPv6 Address And Verify
69    [Documentation]  Configure IPv6 address and verify.
70    [Tags]  Configure_IPv6_Address_And_Verify
71    [Teardown]  Run Keywords
72    ...  Delete IPv6 Address  ${test_ipv6_addr}  AND  Test Teardown Execution
73    [Template]  Configure IPv6 Address On BMC
74
75
76    # IPv6 address     Prefix length
77    ${test_ipv6_addr}  ${test_prefix_length}
78
79
80Delete IPv6 Address And Verify
81    [Documentation]  Delete IPv6 address and verify.
82    [Tags]  Delete_IPv6_Address_And_Verify
83
84    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
85
86    Delete IPv6 Address  ${test_ipv6_addr}
87
88
89
90Modify IPv6 Address And Verify
91    [Documentation]  Modify IPv6 address and verify.
92    [Tags]  Modify_IPv6_Address_And_Verify
93    [Teardown]  Run Keywords
94    ...  Delete IPv6 Address  ${test_ipv6_addr1}  AND  Test Teardown Execution
95
96    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
97
98    Modify IPv6 Address  ${test_ipv6_addr}  ${test_ipv6_addr1}  ${test_prefix_length}
99
100
101Verify Persistency Of IPv6 After BMC Reboot
102    [Documentation]  Verify persistency of IPv6 after BMC reboot.
103    [Tags]  Verify_Persistency_Of_IPv6_After_BMC_Reboot
104    [Teardown]  Run Keywords
105    ...  Delete IPv6 Address  ${test_ipv6_addr}  AND  Test Teardown Execution
106
107    Configure IPv6 Address On BMC  ${test_ipv6_addr}  ${test_prefix_length}
108
109    Redfish OBMC Reboot (off)  stack_mode=skip
110
111    # Verifying persistency of IPv6.
112    Verify IPv6 On BMC  ${test_ipv6_addr}
113
114
115Enable SLAACv6 On BMC And Verify
116    [Documentation]  Enable SLAACv6 on BMC and verify.
117    [Tags]  Enable_SLAACv6_On_BMC_And_Verify
118
119    Set SLAACv6 Configuration State And Verify  ${True}
120
121
122Enable DHCPv6 Property On BMC And Verify
123    [Documentation]  Enable DHCPv6 property on BMC and verify.
124    [Tags]  Enable_DHCPv6_Property_On_BMC_And_Verify
125
126    Set And Verify DHCPv6 Property  Enabled
127
128Disable DHCPv6 Property On BMC And Verify
129    [Documentation]  Disable DHCPv6 property on BMC and verify.
130    [Tags]  Disable_DHCPv6_Property_On_BMC_And_Verify
131
132    Set And Verify DHCPv6 Property  Disabled
133
134Configure Invalid Static IPv6 And Verify
135    [Documentation]  Configure invalid static IPv6 and verify.
136    [Tags]  Configure_Invalid_Static_IPv6_And_Verify
137    [Template]  Configure IPv6 Address On BMC
138
139    #invalid_ipv6         prefix length           valid_status_code
140    ${ipv4_hexword_addr}  ${test_prefix_length}   ${HTTP_BAD_REQUEST}
141
142
143Configure IPv6 Static Default Gateway And Verify
144    [Documentation]  Configure IPv6 static default gateway and verify.
145    [Tags]  Configure_IPv6_Static_Default_Gateway_And_Verify
146    [Template]  Configure IPv6 Static Default Gateway On BMC
147
148    # static_def_gw              prefix length           valid_status_code
149    ${ipv6_gw_addr}              ${prefix_length_def}    ${HTTP_OK}
150    ${invalid_staticv6_gateway}  ${test_prefix_length}   ${HTTP_BAD_REQUEST}
151
152
153*** Keywords ***
154
155Suite Setup Execution
156    [Documentation]  Do suite setup execution.
157
158    ${active_channel_config}=  Get Active Channel Config
159    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
160
161    Set Suite variable  ${ethernet_interface}
162
163
164Test Setup Execution
165    [Documentation]  Test setup execution.
166
167    Redfish.Login
168
169    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
170    Set Test Variable  @{ipv6_network_configurations}
171
172    # Get BMC IPv6 address and prefix length.
173    ${ipv6_data}=  Get BMC IPv6 Info
174    Set Test Variable  ${ipv6_data}
175
176
177Test Teardown Execution
178    [Documentation]  Test teardown execution.
179
180    FFDC On Test Case Fail
181    Redfish.Logout
182
183
184Get IPv6 Network Configuration
185    [Documentation]  Get Ipv6 network configuration.
186    # Sample output:
187    # {
188    #  "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0",
189    #  "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
190    #   "DHCPv4": {
191    #    "DHCPEnabled": false,
192    #    "UseDNSServers": false,
193    #    "UseDomainName": true,
194    #    "UseNTPServers": false
195    #  },
196    #  "DHCPv6": {
197    #    "OperatingMode": "Disabled",
198    #    "UseDNSServers": false,
199    #    "UseDomainName": true,
200    #    "UseNTPServers": false
201    #  },
202    #  "Description": "Management Network Interface",
203    #  "FQDN": "localhost",
204    #  "HostName": "localhost",
205    #  "IPv4Addresses": [
206    #    {
207    #      "Address": "xx.xx.xx.xx",
208    #      "AddressOrigin": "Static",
209    #      "Gateway": "xx.xx.xx.1",
210    #      "SubnetMask": "xx.xx.xx.0"
211    #    },
212    #    {
213    #      "Address": "169.254.xx.xx",
214    #      "AddressOrigin": "IPv4LinkLocal",
215    #      "Gateway": "0.0.0.0",
216    #      "SubnetMask": "xx.xx.0.0"
217    #    },
218    #  ],
219    #  "IPv4StaticAddresses": [
220    #    {
221    #      "Address": "xx.xx.xx.xx",
222    #      "AddressOrigin": "Static",
223    #      "Gateway": "xx.xx.xx.1",
224    #      "SubnetMask": "xx.xx.0.0"
225    #    }
226    # }
227    #  ],
228    #  "IPv6AddressPolicyTable": [],
229    #  "IPv6Addresses": [
230    #    {
231    #      "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
232    #      "AddressOrigin": "LinkLocal",
233    #      "AddressState": null,
234    #      "PrefixLength": xx
235    #    }
236    #  ],
237    #  "IPv6DefaultGateway": "",
238    #  "IPv6StaticAddresses": [
239    #    { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
240    #      "AddressOrigin": "Static",
241    #      "AddressState": null,
242    #      "PrefixLength": xxx
243    #    }
244    #  ],
245    #  "Id": "eth0",
246    #  "InterfaceEnabled": true,
247    #  "LinkStatus": "LinkUp",
248    #  "MACAddress": "xx:xx:xx:xx:xx:xx",
249    #  "Name": "Manager Ethernet Interface",
250    #  "NameServers": [],
251    #  "SpeedMbps": 0,
252    #  "StaticNameServers": [],
253    #  "Status": {
254    #    "Health": "OK",
255    #    "HealthRollup": "OK",
256    #    "State": "Enabled"
257    #  },
258    #  "VLANs": {
259    #    "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0/VLANs"
260
261
262    ${active_channel_config}=  Get Active Channel Config
263    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
264
265    @{ipv6_network_configurations}=  Get From Dictionary  ${resp.dict}  IPv6StaticAddresses
266    RETURN  @{ipv6_network_configurations}
267
268
269Verify IPv6 And PrefixLength
270    [Documentation]  Verify IPv6 address and prefix length on BMC.
271    [Arguments]  ${ipv6_addr}  ${prefix_len}
272
273    # Description of the argument(s):
274    # ipv6_addr   IPv6 address to be verified.
275    # prefix_len  PrefixLength value to be verified.
276
277    # Catenate IPv6 address and its prefix length.
278    ${ipv6_with_prefix}=  Catenate  ${ipv6_addr}/${prefix_len}
279
280    # Get IPv6 address details on BMC using IP command.
281    @{ip_data}=  Get BMC IPv6 Info
282
283    # Verify if IPv6 and prefix length is configured on BMC.
284
285    Should Contain  ${ip_data}  ${ipv6_with_prefix}
286    ...  msg=IPv6 and prefix length pair does not exist.
287
288
289Configure IPv6 Address On BMC
290    [Documentation]  Add IPv6 Address on BMC.
291    [Arguments]  ${ipv6_addr}  ${prefix_len}  ${valid_status_codes}=${HTTP_OK}
292
293    # Description of argument(s):
294    # ipv6_addr           IPv6 address to be added (e.g. "2001:EEEE:2222::2022").
295    # prefix_len          Prefix length for the IPv6 to be added
296    #                     (e.g. "64").
297    # valid_status_codes  Expected return code from patch operation
298    #                     (e.g. "200").
299
300    ${prefix_length}=  Convert To Integer  ${prefix_len}
301    ${empty_dict}=  Create Dictionary
302    ${ipv6_data}=  Create Dictionary  Address=${ipv6_addr}
303    ...  PrefixLength=${prefix_length}
304
305    ${patch_list}=  Create List
306
307    # Get existing static IPv6 configurations on BMC.
308    ${ipv6_network_configurations}=  Get IPv6 Network Configuration
309    ${num_entries}=  Get Length  ${ipv6_network_configurations}
310
311    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
312      Append To List  ${patch_list}  ${empty_dict}
313    END
314
315    ${valid_status_codes}=  Set Variable If  '${valid_status_codes}' == '${HTTP_OK}'
316    ...  ${HTTP_OK},${HTTP_NO_CONTENT}
317    ...  ${valid_status_codes}
318
319    # We need not check for existence of IPv6 on BMC while adding.
320    Append To List  ${patch_list}  ${ipv6_data}
321    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
322
323    ${active_channel_config}=  Get Active Channel Config
324    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
325
326    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
327    ...  valid_status_codes=[${valid_status_codes}]
328
329    Return From Keyword If  '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
330
331    # Note: Network restart takes around 15-18s after patch request processing.
332    Sleep  ${NETWORK_TIMEOUT}s
333    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
334
335    Verify IPv6 And PrefixLength  ${ipv6_addr}  ${prefix_len}
336
337    # Verify if existing static IPv6 addresses still exist.
338    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
339      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
340    END
341
342    Validate IPv6 Network Config On BMC
343
344
345Validate IPv6 Network Config On BMC
346    [Documentation]  Check that IPv6 network info obtained via redfish matches info
347    ...              obtained via CLI.
348    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
349    ${ipv6_data}=  Get BMC IPv6 Info
350    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
351      Should Contain Match  ${ipv6_data}  ${ipv6_network_configuration['Address']}/*
352      ...  msg=IPv6 address does not exist.
353    END
354
355
356Delete IPv6 Address
357    [Documentation]  Delete IPv6 address of BMC.
358    [Arguments]  ${ipv6_addr}
359    ...          ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
360
361    # Description of argument(s):
362    # ipv6_addr           IPv6 address to be deleted (e.g. "2001:1234:1234:1234::1234").
363    # valid_status_codes  Expected return code from patch operation
364    #                     (e.g. "200").  See prolog of rest_request
365    #                     method in redfish_plus.py for details.
366
367    ${empty_dict}=  Create Dictionary
368    ${patch_list}=  Create List
369
370    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
371    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
372        IF  '${ipv6_network_configuration['Address']}' == '${ipv6_addr}'
373            Append To List  ${patch_list}  ${null}
374        ELSE
375            Append To List  ${patch_list}  ${empty_dict}
376        END
377    END
378
379    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
380    ...  ${patch_list}  ${null}  msg=${ipv6_addr} does not exist on BMC
381    Pass Execution If  ${ip_found} == ${False}  ${ipv6_addr} does not exist on BMC
382
383    # Run patch command only if given IP is found on BMC
384    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
385
386    ${active_channel_config}=  Get Active Channel Config
387    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
388
389    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{data}
390    ...  valid_status_codes=${valid_status_codes}
391
392    # Note: Network restart takes around 15-18s after patch request processing
393    Sleep  ${NETWORK_TIMEOUT}s
394    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
395
396    # IPv6 address that is deleted should not be there on BMC.
397    ${delete_status}=  Run Keyword And Return Status  Verify IPv6 On BMC  ${ipv6_addr}
398    IF  '${valid_status_codes}' == '[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]'
399        Should Be True  '${delete_status}' == '${False}'
400    ELSE
401        Should Be True  '${delete_status}' == '${True}'
402    END
403
404    Validate IPv6 Network Config On BMC
405
406
407Modify IPv6 Address
408    [Documentation]  Modify and verify IPv6 address of BMC.
409    [Arguments]  ${ipv6}  ${new_ipv6}  ${prefix_len}
410    ...  ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
411
412    # Description of argument(s):
413    # ipv6                  IPv6 address to be replaced (e.g. "2001:AABB:CCDD::AAFF").
414    # new_ipv6              New IPv6 address to be configured.
415    # prefix_len            Prefix length value (Range 1 to 128).
416    # valid_status_codes    Expected return code from patch operation
417    #                       (e.g. "200", "201").
418
419    ${empty_dict}=  Create Dictionary
420    ${patch_list}=  Create List
421    ${prefix_length}=  Convert To Integer  ${prefix_len}
422    ${ipv6_data}=  Create Dictionary
423    ...  Address=${new_ipv6}  PrefixLength=${prefix_length}
424
425    # Sample IPv6 network configurations:
426    #  "IPv6AddressPolicyTable": [],
427    #  "IPv6Addresses": [
428    #    {
429    #      "Address": "X002:db8:0:2::XX0",
430    #      "AddressOrigin": "DHCPv6",
431    #      "PrefixLength": 128
432    #    },
433    #    {
434    #      "Address": “X002:db8:0:2:a94:XXff:fe82:XXXX",
435    #      "AddressOrigin": "SLAAC",
436    #      "PrefixLength": 64
437    #    },
438    #    {
439    #      "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
440    #      "AddressOrigin": "Static",
441    #      "PrefixLength": 56
442    #    },
443    #    {
444    #      "Address": “Z002:db8:0:2:a94:efff:fe82:5000",
445    #      "AddressOrigin": "Static",
446    #      "PrefixLength": 56
447    #    },
448    #    {
449    #      "Address": “Xe80::a94:efff:YYYY:XXXX",
450    #      "AddressOrigin": "LinkLocal",
451    #      "PrefixLength": 64
452    #    },
453    #    {
454    #     "Address": “X002:db8:1:2:eff:233:fee:546",
455    #      "AddressOrigin": "Static",
456    #      "PrefixLength": 56
457    #    }
458    #  ],
459    #  "IPv6DefaultGateway": “XXXX::ab2e:80fe:87df:XXXX”,
460    #  "IPv6StaticAddresses": [
461    #    {
462    #      "Address": “X002:db8:0:2:a94:efff:fe82:5000",
463    #      "PrefixLength": 56
464    #    },
465    #    {
466    #      "Address": “Y002:db8:0:2:a94:efff:fe82:5000",
467    #      "PrefixLength": 56
468    #    },
469    #    {
470    #      "Address": “Z002:db8:1:2:eff:233:fee:546",
471    #      "PrefixLength": 56
472    #    }
473    #  ],
474    #  "IPv6StaticDefaultGateways": [],
475
476    # Find the position of IPv6 address to be modified.
477    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
478    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
479      IF  '${ipv6_network_configuration['Address']}' == '${ipv6}'
480          Append To List  ${patch_list}  ${ipv6_data}
481      ELSE
482          Append To List  ${patch_list}  ${empty_dict}
483      END
484    END
485
486    # Modify the IPv6 address only if given IPv6 is found
487    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
488    ...  ${patch_list}  ${ipv6_data}  msg=${ipv6} does not exist on BMC
489    Pass Execution If  ${ip_found} == ${False}  ${ipv6} does not exist on BMC
490
491    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
492
493    ${active_channel_config}=  Get Active Channel Config
494    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
495
496    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
497    ...  body=&{data}  valid_status_codes=${valid_status_codes}
498
499    # Note: Network restart takes around 15-18s after patch request processing.
500    Sleep  ${NETWORK_TIMEOUT}s
501    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
502
503    # Verify if new IPv6 address is configured on BMC.
504    Verify IPv6 On BMC  ${new_ipv6}
505
506    # Verify if old IPv6 address is erased.
507    ${cmd_status}=  Run Keyword And Return Status
508    ...  Verify IPv6 On BMC  ${ipv6}
509    Should Be Equal  ${cmd_status}  ${False}  msg=Old IPv6 address is not deleted.
510
511    Validate IPv6 Network Config On BMC
512
513
514Set SLAACv6 Configuration State And Verify
515    [Documentation]  Set SLAACv6 configuration state and verify.
516    [Arguments]  ${slaac_state}  ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
517
518    # Description of argument(s):
519    # slaac_state         SLAACv6 state('True' or 'False').
520    # valid_status_code   Expected valid status codes.
521
522    ${active_channel_config}=  Get Active Channel Config
523    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
524
525    ${data}=  Set Variable If  ${slaac_state} == ${False}  ${DISABLE_SLAAC}  ${ENABLE_SLAAC}
526    ${resp}=  Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
527    ...  body=${data}  valid_status_codes=${valid_status_codes}
528
529    # Verify SLAACv6 is set correctly.
530    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
531    ${slaac_verify}=  Get From Dictionary  ${resp.dict}  StatelessAddressAutoConfig
532
533    IF  '${slaac_verify['IPv6AutoConfigEnabled']}' != '${slaac_state}'
534        Fail  msg=SLAACv6 not set properly.
535    END
536
537
538Set And Verify DHCPv6 Property
539    [Documentation]  Set DHCPv6 attribute and verify.
540    [Arguments]  ${dhcpv6_operating_mode}=${Disabled}
541
542    # Description of argument(s):
543    # dhcpv6_operating_mode    Enabled if user wants to enable DHCPv6('Enabled' or 'Disabled').
544
545    ${data}=  Set Variable If  '${dhcpv6_operating_mode}' == 'Disabled'  ${DISABLE_DHCPv6}  ${ENABLE_DHCPv6}
546    ${active_channel_config}=  Get Active Channel Config
547    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
548
549    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
550    ...  body=${data}  valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
551
552    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
553    ${dhcpv6_verify}=  Get From Dictionary  ${resp.dict}  DHCPv6
554
555    Should Be Equal  '${dhcpv6_verify['OperatingMode']}'  '${dhcpv6_operating_mode}'
556
557
558Configure IPv6 Static Default Gateway On BMC
559    [Documentation]  Configure IPv6 static default gateway on BMC.
560    [Arguments]  ${ipv6_gw_addr}  ${prefix_length_def}
561    ...  ${valid_status_codes}=${HTTP_OK}
562
563    # Description of argument(s):
564    # ipv6_gw_addr          IPv6 Static Default Gateway address to be configured.
565    # prefix_len_def        Prefix length value (Range 1 to 128).
566    # valid_status_codes    Expected return code from patch operation
567    #                       (e.g. "200", "204".)
568
569    # Prefix Length is passed as None.
570    IF   '${prefix_length_def}' == '${None}'
571        ${ipv6_gw}=  Create Dictionary  Address=${ipv6_gw_addr}
572    ELSE
573        ${ipv6_gw}=  Create Dictionary  Address=${ipv6_gw_addr}  Prefix Length=${prefix_length_def}
574    END
575
576    ${ipv6_static_def_gw}=  Get IPv6 Static Default Gateway
577
578    ${num_entries}=  Get Length  ${ipv6_static_def_gw}
579
580    ${patch_list}=  Create List
581    ${empty_dict}=  Create Dictionary
582
583    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
584      Append To List  ${patch_list}  ${empty_dict}
585    END
586
587    ${valid_status_codes}=  Set Variable If  '${valid_status_codes}' == '${HTTP_OK}'
588    ...  ${HTTP_OK},${HTTP_NO_CONTENT}
589    ...  ${valid_status_codes}
590
591    Append To List  ${patch_list}  ${ipv6_gw}
592    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
593
594    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
595    ...  body=${data}  valid_status_codes=[${valid_status_codes}]
596
597    # Verify the added static default gateway is present in Redfish Get Output.
598    ${ipv6_staticdef_gateway}=  Get IPv6 Static Default Gateway
599
600    ${ipv6_static_def_gw_list}=  Create List
601    FOR  ${ipv6_staticdef_gateway}  IN  @{ipv6_staticdef_gateway}
602        ${value}=    Get From Dictionary    ${ipv6_staticdef_gateway}    Address
603        Append To List  ${ipv6_static_def_gw_list}  ${value}
604    END
605
606    IF  '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
607        Should Not Contain  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}
608    ELSE
609        Should Contain  ${ipv6_static_def_gw_list}  ${ipv6_gw_addr}
610    END
611
612
613Get IPv6 Static Default Gateway
614    [Documentation]  Get IPv6 static default gateway.
615
616    ${active_channel_config}=  Get Active Channel Config
617    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
618
619    @{ipv6_static_defgw_configurations}=  Get From Dictionary  ${resp.dict}  IPv6StaticDefaultGateways
620    RETURN  @{ipv6_static_defgw_configurations}
621