xref: /openbmc/openbmc-test-automation/lib/external_intf/vmi_utils.robot (revision cb61ff0fd22543473630ba5a6e6d5714718efee0)
1d52b2731SSweta Potthuri*** Settings ***
2d52b2731SSweta PotthuriDocumentation    Vmi network utilities keywords.
3d52b2731SSweta Potthuri
4d52b2731SSweta PotthuriResource         ../../lib/resource.robot
5d52b2731SSweta PotthuriResource         ../../lib/bmc_redfish_resource.robot
6d52b2731SSweta PotthuriResource         ../../lib/openbmc_ffdc.robot
7d52b2731SSweta PotthuriResource         ../../lib/bmc_redfish_utils.robot
8d52b2731SSweta PotthuriResource         ../../lib/state_manager.robot
97ba02f31Sshrsuman123Resource         ../../lib/bmc_network_utils.robot
10d52b2731SSweta PotthuriLibrary          ../../lib/bmc_network_utils.py
11d52b2731SSweta Potthuri
12d52b2731SSweta Potthuri*** Variables ***
13d52b2731SSweta Potthuri
147e9b2127Sshrsuman123&{DHCP_ENABLED}           DHCPEnabled=${True}
157e9b2127Sshrsuman123&{DHCP_DISABLED}          DHCPEnabled=${False}
167e9b2127Sshrsuman123
177e9b2127Sshrsuman123&{ENABLE_DHCP}            DHCPv4=&{DHCP_ENABLED}
187e9b2127Sshrsuman123&{DISABLE_DHCP}           DHCPv4=&{DHCP_DISABLED}
197e9b2127Sshrsuman123
20a2148339SMegha G N&{SLAAC_ENABLED}          IPv6AutoConfigEnabled=${True}
21a2148339SMegha G N&{SLAAC_DISABLED}         IPv6AutoConfigEnabled=${False}
22a2148339SMegha G N
23a2148339SMegha G N&{ENABLE_SLAAC}           StatelessAddressAutoConfig=&{SLAAC_ENABLED}
24a2148339SMegha G N&{DISABLE_SLAAC}          StatelessAddressAutoConfig=&{SLAAC_DISABLED}
25a2148339SMegha G N
26a2148339SMegha G N&{DHCPv6_ENABLED}         OperatingMode=Enabled
27a2148339SMegha G N&{DHCPv6_DISABLED}        OperatingMode=Disabled
28a2148339SMegha G N
29a2148339SMegha G N&{ENABLE_DHCPv6}          DHCPv6=&{DHCPv6_ENABLED}
30a2148339SMegha G N&{DISABLE_DHCPv6}         DHCPv6=&{DHCPv6_DISABLED}
31a2148339SMegha G N
32a9cf2d86SMegha G N${wait_time}              40s
33a035578fSshrsuman123${ethernet_interface}     eth0
34*cb61ff0fSSweta Potthuri${ipv4_hexword_addr}      10.5.5.6:1A:1B:1C:1D:1E:1F
35d52b2731SSweta Potthuri
36d52b2731SSweta Potthuri*** Keywords ***
37d52b2731SSweta Potthuri
38d52b2731SSweta PotthuriSet Static IPv4 Address To VMI And Verify
39d52b2731SSweta Potthuri    [Documentation]  Set static IPv4 address to VMI.
40d52b2731SSweta Potthuri    [Arguments]  ${ip}  ${gateway}  ${netmask}  ${valid_status_code}=${HTTP_ACCEPTED}
41a035578fSshrsuman123    ...  ${interface}=${ethernet_interface}
42d52b2731SSweta Potthuri
43d52b2731SSweta Potthuri    # Description of argument(s):
44d52b2731SSweta Potthuri    # ip                 VMI IPv4 address.
45d52b2731SSweta Potthuri    # gateway            Gateway for VMI IP.
46d52b2731SSweta Potthuri    # netmask            Subnetmask for VMI IP.
47d52b2731SSweta Potthuri    # valid_status_code  Expected valid status code from GET request. Default is HTTP_ACCEPTED.
48298e8048Sshrsuman123    # interface          VMI interface (eg. eth0 or eth1).
49d52b2731SSweta Potthuri
50298e8048Sshrsuman123    ${ip_details}=  Create dictionary  Address=${ip}  SubnetMask=${netmask}  Gateway=${gateway}
51298e8048Sshrsuman123    ${ip_data}=  Create List  ${ip_details}
52298e8048Sshrsuman123    ${resp}=  Redfish.Patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
53298e8048Sshrsuman123    ...  body={'IPv4StaticAddresses':${ip_data}}  valid_status_codes=[${valid_status_code}]
54d52b2731SSweta Potthuri
55d52b2731SSweta Potthuri    # Wait few seconds for new configuration to get populated on runtime.
56d52b2731SSweta Potthuri    Sleep  ${wait_time}
57d52b2731SSweta Potthuri
58d52b2731SSweta Potthuri    Return From Keyword If  ${valid_status_code} != ${HTTP_ACCEPTED}
59d52b2731SSweta Potthuri    ${host_power_state}  ${host_state}=   Redfish Get Host State
60d52b2731SSweta Potthuri    Run Keyword If  '${host_power_state}' == 'On' and '${host_state}' == 'Enabled'
61298e8048Sshrsuman123    ...  Verify VMI Network Interface Details  ${ip}  Static  ${gateway}  ${netmask}  ${interface}
62d52b2731SSweta Potthuri
63d52b2731SSweta PotthuriVerify VMI Network Interface Details
64d52b2731SSweta Potthuri    [Documentation]  Verify VMI network interface details.
65d52b2731SSweta Potthuri    [Arguments]  ${ip}  ${origin}  ${gateway}  ${netmask}
66a035578fSshrsuman123    ...  ${interface}=${ethernet_interface}  ${valid_status_code}=${HTTP_OK}
67d52b2731SSweta Potthuri
68d52b2731SSweta Potthuri    # Description of argument(s):
69d52b2731SSweta Potthuri    # ip                 VMI IPv4 address.
70d52b2731SSweta Potthuri    # origin             Origin of IPv4 address eg. Static or DHCP.
71d52b2731SSweta Potthuri    # gateway            Gateway for VMI IP.
72d52b2731SSweta Potthuri    # netmask            Subnetmask for VMI IP.
73298e8048Sshrsuman123    # interface          VMI interface (eg. eth0 or eth1).
74d52b2731SSweta Potthuri    # valid_status_code  Expected valid status code from GET request. Default is HTTP_OK.
75d52b2731SSweta Potthuri
76298e8048Sshrsuman123    ${vmi_ip}=  Get VMI Network Interface Details  ${interface}  ${valid_status_code}
77d52b2731SSweta Potthuri    Should Be Equal As Strings  ${origin}  ${vmi_ip["IPv4_AddressOrigin"]}
78d52b2731SSweta Potthuri    Should Be Equal As Strings  ${gateway}  ${vmi_ip["IPv4_Gateway"]}
79d52b2731SSweta Potthuri    Should Be Equal As Strings  ${netmask}  ${vmi_ip["IPv4_SubnetMask"]}
80d52b2731SSweta Potthuri    Should Be Equal As Strings  ${ip}  ${vmi_ip["IPv4_Address"]}
81d52b2731SSweta Potthuri
82d52b2731SSweta PotthuriDelete VMI IPv4 Address
83d52b2731SSweta Potthuri    [Documentation]  Delete VMI IPv4 address.
84d52b2731SSweta Potthuri    [Arguments]  ${delete_param}=IPv4StaticAddresses  ${valid_status_code}=${HTTP_ACCEPTED}
85a035578fSshrsuman123    ...  ${interface}=${ethernet_interface}
86d52b2731SSweta Potthuri
87d52b2731SSweta Potthuri    # Description of argument(s):
88d52b2731SSweta Potthuri    # delete_param       Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses.
89d52b2731SSweta Potthuri    #                    Default is IPv4StaticAddresses.
90d52b2731SSweta Potthuri    # valid_status_code  Expected valid status code from PATCH request. Default is HTTP_OK.
91298e8048Sshrsuman123    # interface          VMI interface (eg. eth0 or eth1).
92d52b2731SSweta Potthuri
93d52b2731SSweta Potthuri    ${data}=  Set Variable  {"${delete_param}": [${Null}]}
94d52b2731SSweta Potthuri    ${resp}=  Redfish.Patch
95298e8048Sshrsuman123    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
96d52b2731SSweta Potthuri    ...  body=${data}  valid_status_codes=[${valid_status_code}]
97d52b2731SSweta Potthuri
98d52b2731SSweta Potthuri    Return From Keyword If  ${valid_status_code} != ${HTTP_ACCEPTED}
99a3759b36Sshrsuman123
100a3759b36Sshrsuman123    # Wait few seconds for configuration to get effective.
101a3759b36Sshrsuman123    Sleep  ${wait_time}
102298e8048Sshrsuman123    ${vmi_ip}=  Get VMI Network Interface Details  ${interface}
10380ef5ca0SMegha GN    ${default}=  Set Variable  0.0.0.0
10480ef5ca0SMegha GN    Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
105d52b2731SSweta Potthuri
106d52b2731SSweta PotthuriSet VMI IPv4 Origin
107d52b2731SSweta Potthuri    [Documentation]  Set VMI IPv4 origin.
108d52b2731SSweta Potthuri    [Arguments]  ${dhcp_enabled}=${False}  ${valid_status_code}=${HTTP_ACCEPTED}
109a035578fSshrsuman123    ...  ${interface}=${ethernet_interface}
110d52b2731SSweta Potthuri
111d52b2731SSweta Potthuri    # Description of argument(s):
112d52b2731SSweta Potthuri    # dhcp_enabled       True if user wants to enable DHCP. Default is Static, hence value is set to False.
113d52b2731SSweta Potthuri    # valid_status_code  Expected valid status code from PATCH request. Default is HTTP_OK.
114298e8048Sshrsuman123    # interface          VMI interface (eg. eth0 or eth1).
115d52b2731SSweta Potthuri
116d52b2731SSweta Potthuri    ${data}=  Set Variable If  ${dhcp_enabled} == ${False}  ${DISABLE_DHCP}  ${ENABLE_DHCP}
117d52b2731SSweta Potthuri    ${resp}=  Redfish.Patch
118298e8048Sshrsuman123    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
119d52b2731SSweta Potthuri    ...  body=${data}  valid_status_codes=[${valid_status_code}]
120d52b2731SSweta Potthuri
121d52b2731SSweta Potthuri    Sleep  ${wait_time}
122d52b2731SSweta Potthuri    Return From Keyword If  ${valid_status_code} != ${HTTP_ACCEPTED}
123d52b2731SSweta Potthuri    ${resp}=  Redfish.Get
124298e8048Sshrsuman123    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
125d52b2731SSweta Potthuri    Should Be Equal  ${resp.dict["DHCPv4"]["DHCPEnabled"]}  ${dhcp_enabled}
126d52b2731SSweta Potthuri
127a9cf2d86SMegha G N
128d52b2731SSweta PotthuriGet VMI Network Interface Details
129d52b2731SSweta Potthuri    [Documentation]  Get VMI network interface details.
130a035578fSshrsuman123    [Arguments]  ${interface}=${ethernet_interface}  ${valid_status_code}=${HTTP_OK}
131d52b2731SSweta Potthuri
132d52b2731SSweta Potthuri    # Description of argument(s):
133298e8048Sshrsuman123    # interface          VMI interface (eg. eth0 or eth1).
134d52b2731SSweta Potthuri    # valid_status_code  Expected valid status code from GET request.
135d52b2731SSweta Potthuri
136d52b2731SSweta Potthuri    # Note: It returns a dictionary of VMI ethernet interface parameters.
137d52b2731SSweta Potthuri
138d52b2731SSweta Potthuri    ${resp}=  Redfish.Get
139298e8048Sshrsuman123    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
140d52b2731SSweta Potthuri    ...  valid_status_codes=[${valid_status_code}]
141d52b2731SSweta Potthuri
142d52b2731SSweta Potthuri    ${ip_resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
143d52b2731SSweta Potthuri
144d52b2731SSweta Potthuri    ${ip_exists}=  Set Variable If  ${ip_resp["IPv4Addresses"]} == @{empty}  ${False}  ${True}
145d52b2731SSweta Potthuri    ${static_exists}=  Set Variable If  ${ip_resp["IPv4StaticAddresses"]} == @{empty}  ${False}  ${True}
146d52b2731SSweta Potthuri
147d52b2731SSweta Potthuri    ${vmi_ip}=  Run Keyword If   ${ip_exists} == ${True}
148d52b2731SSweta Potthuri    ...  Create Dictionary  DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}}  Id=${ip_resp["Id"]}
149d52b2731SSweta Potthuri    ...  Description=${ip_resp["Description"]}  IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]}
150d52b2731SSweta Potthuri    ...  IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]}  Name=${ip_resp["Name"]}
151d52b2731SSweta Potthuri    ...  IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]}
152d52b2731SSweta Potthuri    ...  InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}}
153d52b2731SSweta Potthuri    ...  IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]}
154d52b2731SSweta Potthuri    ...  IPv4StaticAddresses=${${static_exists}}
155d52b2731SSweta Potthuri    ...  ELSE
156d52b2731SSweta Potthuri    ...  Create Dictionary  DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}}  Id=${ip_resp["Id"]}
157d52b2731SSweta Potthuri    ...  Description=${ip_resp["Description"]}  IPv4StaticAddresses=${ip_resp["IPv4StaticAddresses"]}
158d52b2731SSweta Potthuri    ...  IPv4_Address=${ip_resp["IPv4Addresses"]}  Name=${ip_resp["Name"]}
159d52b2731SSweta Potthuri    ...  InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}}
160d52b2731SSweta Potthuri
161409df05dSGeorge Keishing    RETURN  &{vmi_ip}
162d52b2731SSweta Potthuri
163298e8048Sshrsuman123
164298e8048Sshrsuman123Get VMI Interfaces
165298e8048Sshrsuman123    [Documentation]  Get VMI network interface.
166298e8048Sshrsuman123    [Arguments]  ${valid_status_code}=${HTTP_OK}
167298e8048Sshrsuman123
168298e8048Sshrsuman123    # Description of argument(s):
169298e8048Sshrsuman123    # valid_status_code  Expected valid status code from GET request.
170298e8048Sshrsuman123    #                    By default set to ${HTTP_OK}.
171298e8048Sshrsuman123
172298e8048Sshrsuman123    ${resp}=  Redfish.Get  /redfish/v1/Systems/hypervisor/EthernetInterfaces
173298e8048Sshrsuman123    ...  valid_status_codes=[${valid_status_code}]
174298e8048Sshrsuman123
175298e8048Sshrsuman123    ${resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
176298e8048Sshrsuman123    ${interfaces_uri}=  Set Variable  ${resp["Members"]}
177298e8048Sshrsuman123    ${interface_list}=  Create List
178298e8048Sshrsuman123    ${number_of_interfaces}=  Get Length  ${interfaces_uri}
179298e8048Sshrsuman123    FOR  ${interface}  IN RANGE  ${number_of_interfaces}
180298e8048Sshrsuman123        ${_}  ${interface_value}=  Split String From Right  ${interfaces_uri[${interface}]}[@odata.id]  /  1
181298e8048Sshrsuman123        Append To List  ${interface_list}  ${interface_value}
182298e8048Sshrsuman123    END
183298e8048Sshrsuman123
184409df05dSGeorge Keishing   RETURN  @{interface_list}
185298e8048Sshrsuman123
186298e8048Sshrsuman123
187d52b2731SSweta PotthuriVerify VMI EthernetInterfaces
188d52b2731SSweta Potthuri    [Documentation]  Verify VMI ethernet interfaces.
189d52b2731SSweta Potthuri    [Arguments]  ${valid_status_code}=${HTTP_OK}
190d52b2731SSweta Potthuri
191d52b2731SSweta Potthuri    # Description of argument(s):
192d52b2731SSweta Potthuri    # valid_status_code  Expected valid status code from GET request.
193d52b2731SSweta Potthuri
194d52b2731SSweta Potthuri    ${resp}=  Redfish.Get  /redfish/v1/Systems/hypervisor/EthernetInterfaces
195d52b2731SSweta Potthuri    ...  valid_status_codes=[${valid_status_code}]
196d52b2731SSweta Potthuri
197d52b2731SSweta Potthuri    ${resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
198d52b2731SSweta Potthuri    ${interfaces}=  Set Variable  ${resp["Members"]}
199d52b2731SSweta Potthuri
200d52b2731SSweta Potthuri    ${number_of_interfaces}=  Get Length  ${interfaces}
201d52b2731SSweta Potthuri    FOR  ${i}  IN RANGE  ${number_of_interfaces}
202d52b2731SSweta Potthuri        Should Be Equal As Strings  ${interfaces[${i}]}[@odata.id]
203d52b2731SSweta Potthuri        ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth${i}
204d52b2731SSweta Potthuri    END
205d52b2731SSweta Potthuri    Should Be Equal  ${resp["Members@odata.count"]}  ${number_of_interfaces}
2067ba02f31Sshrsuman123
2077ba02f31Sshrsuman123Get And Set Static VMI IP
2087ba02f31Sshrsuman123    [Documentation]  Get a suitable VMI IP and set it.
2097ba02f31Sshrsuman123    [Arguments]   ${host}=${OPENBMC_HOST}  ${network_active_channel}=${CHANNEL_NUMBER}
2107ba02f31Sshrsuman123    ...  ${interface}=eth0  ${valid_status_code}=${HTTP_ACCEPTED}
2117ba02f31Sshrsuman123
2127ba02f31Sshrsuman123    # Description of argument(s):
2137ba02f31Sshrsuman123    # host                    BMC host name or IP address.
2147ba02f31Sshrsuman123    # network_active_channel  Ethernet channel number (e.g.1 or 2).
2157ba02f31Sshrsuman123    # interface               VMI interface (eg. eth0 or eth1).
2167ba02f31Sshrsuman123    # valid_status_code       Expected valid status code from PATCH request. Default is HTTP_ACCEPTED.
2177ba02f31Sshrsuman123
2187ba02f31Sshrsuman123    ${vmi_ip}=  Get First Non Pingable IP From Subnet  ${host}
2197ba02f31Sshrsuman123    ${bmc_ip_data}=  Get Network Configuration  ${network_active_channel}
2207ba02f31Sshrsuman123
2217ba02f31Sshrsuman123    Set Static IPv4 Address To VMI And Verify  ${vmi_ip}  ${bmc_ip_data[0]['Gateway']}
2227ba02f31Sshrsuman123    ...  ${bmc_ip_data[0]['SubnetMask']}  ${valid_status_code}  ${interface}
2237ba02f31Sshrsuman123
224409df05dSGeorge Keishing    RETURN   ${vmi_ip}  ${bmc_ip_data}
225a2148339SMegha G N
226a2148339SMegha G N
227a2148339SMegha G NSet VMI SLAACv6 Origin
228a2148339SMegha G N    [Documentation]  Set VMI SLAACv6 origin.
229a2148339SMegha G N    [Arguments]  ${slaac_enabled}=${False}  ${valid_status_code}=${HTTP_ACCEPTED}
230a2148339SMegha G N    ...  ${interface}=${ethernet_interface}
231a2148339SMegha G N
232a2148339SMegha G N    # Description of argument(s):
233a2148339SMegha G N    # slaacv6_enabled    True if user wants to enable SLAACv6. Default is Static, hence value is set to False.
234a2148339SMegha G N    # valid_status_code  Expected valid status code from PATCH request. Default is HTTP_OK.
235a2148339SMegha G N    # interface          VMI interface (eg. eth0 or eth1).
236a2148339SMegha G N
237a2148339SMegha G N    ${data}=  Set Variable If  ${slaac_enabled} == ${False}  ${DISABLE_SLAAC}  ${ENABLE_SLAAC}
238a2148339SMegha G N    ${resp}=  Redfish.Patch
239a2148339SMegha G N    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
240a2148339SMegha G N    ...  body=${data}  valid_status_codes=[${valid_status_code}]
241a2148339SMegha G N
242a2148339SMegha G N    Sleep  ${wait_time}
243a2148339SMegha G N    Return From Keyword If  ${valid_status_code} != ${HTTP_ACCEPTED}
244a2148339SMegha G N    ${resp}=  Redfish.Get
245a2148339SMegha G N    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
246a2148339SMegha G N    Should Be Equal  ${resp.dict["StatelessAddressAutoConfig"]["IPv6AutoConfigEnabled"]}  ${slaac_enabled}
247a2148339SMegha G N
248a2148339SMegha G N
249a2148339SMegha G NVerify VMI IPv6 Address
250a2148339SMegha G N    [Documentation]  Verify VMI IPv6 address configurations.
251a2148339SMegha G N    [Arguments]  ${ipv6_origin}  ${interface}=${ethernet_interface}
252a2148339SMegha G N
253a2148339SMegha G N    # Description of argument(s):
254a2148339SMegha G N    # ipv6_origin     Origin of IPv6 address eg. Static or DHCPv6 or SLAAC.
255a2148339SMegha G N    # interface       VMI interface (eg. eth0 or eth1).
256a2148339SMegha G N
257a2148339SMegha G N    ${resp}=  Redfish.Get  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
258a2148339SMegha G N
259a2148339SMegha G N    @{vmi_ipv6_configurations}=  Get From Dictionary  ${resp.dict}  IPv6Addresses
260a2148339SMegha G N    ${vmi_ipv6_config}=  Get From List  ${vmi_ipv6_configurations}  0
261a2148339SMegha G N    Should Not Be Empty  ${vmi_ipv6_config["Address"]}
262a2148339SMegha G N    Should Be Equal As Strings   ${vmi_ipv6_config["AddressOrigin"]}  ${ipv6_origin}
263a2148339SMegha G N    RETURN  &{vmi_ipv6_config}
264a2148339SMegha G N
265a2148339SMegha G N
266a2148339SMegha G NSet VMI DHCPv6 Property
267a2148339SMegha G N    [Documentation]  Set VMI DHCPv6 attribute.
268a2148339SMegha G N    [Arguments]  ${dhcpv6_operatingmode}=${Disabled}  ${valid_status_code}=${HTTP_ACCEPTED}
269a2148339SMegha G N    ...  ${interface}=${ethernet_interface}
270a2148339SMegha G N
271a2148339SMegha G N    # Description of argument(s):
272a2148339SMegha G N    # dhcpv6_operatingmode    Enabled if user wants to enable DHCPv6.
273a2148339SMegha G N    # ...                     Default is Static, hence value is set to Disabled.
274a2148339SMegha G N    # valid_status_code       Expected valid status code from PATCH request. Default is HTTP_OK.
275a2148339SMegha G N    # interface               VMI interface (eg. eth0 or eth1).
276a2148339SMegha G N
277a2148339SMegha G N    ${data}=  Set Variable If  '${dhcpv6_operatingmode}' == 'Disabled'  ${DISABLE_DHCPv6}  ${ENABLE_DHCPv6}
278a2148339SMegha G N    ${resp}=  Redfish.Patch
279a2148339SMegha G N    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
280a2148339SMegha G N    ...  body=${data}  valid_status_codes=[${valid_status_code}]
281a2148339SMegha G N
282a2148339SMegha G N    Sleep  ${wait_time}
283a2148339SMegha G N    Return From Keyword If  ${valid_status_code} != ${HTTP_ACCEPTED}
284a2148339SMegha G N    ${resp}=  Redfish.Get
285a2148339SMegha G N    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
286a2148339SMegha G N    Should Be Equal  ${resp.dict["DHCPv6"]["OperatingMode"]}  ${dhcpv6_operatingmode}
287a2148339SMegha G N
288a2148339SMegha G N
289a2148339SMegha G NSet Static VMI IPv6 Address
290a2148339SMegha G N    [Documentation]  Add static VMI IPv6 address.
291a2148339SMegha G N    [Arguments]  ${vmi_ipv6_addr}  ${prefix_len}  ${valid_status_codes}=${HTTP_ACCEPTED}
292a2148339SMegha G N    ...  ${interface}=${ethernet_interface}
293a2148339SMegha G N
294a2148339SMegha G N    # Description of argument(s):
295a2148339SMegha G N    # vmi_ipv6_addr       VMI IPv6 address to be added.
296a2148339SMegha G N    # prefix_len          Prefix length for the VMI IPv6 to be added.
297a2148339SMegha G N    # valid_status_codes  Expected valid status code from PATCH request.
298a2148339SMegha G N    # interface           VMI interface (eg. eth0 or eth1).
299a2148339SMegha G N
300a2148339SMegha G N    ${prefix_length}=  Convert To Integer  ${prefix_len}
301a2148339SMegha G N    ${empty_dict}=  Create Dictionary
302a2148339SMegha G N    ${vmi_ipv6_data}=  Create Dictionary  Address=${vmi_ipv6_addr}
303a2148339SMegha G N    ...  PrefixLength=${prefix_length}
304a2148339SMegha G N
305a2148339SMegha G N    ${patch_list}=  Create List
306a2148339SMegha G N
307a2148339SMegha G N    Append To List  ${patch_list}  ${vmi_ipv6_data}
308a2148339SMegha G N    ${data}=  Create Dictionary  IPv6StaticAddresses=${patch_list}
309a2148339SMegha G N
310a2148339SMegha G N    ${active_channel_config}=  Get Active Channel Config
311a2148339SMegha G N    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
312a2148339SMegha G N
313a2148339SMegha G N    Redfish.patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
314a2148339SMegha G N    ...  body=&{data}  valid_status_codes=[${valid_status_codes}]
315a2148339SMegha G N
3161361edf0SMegha G N    Sleep  5s
317a2148339SMegha G N
318a2148339SMegha G NSet VMI IPv6 Static Default Gateway
319a2148339SMegha G N    [Documentation]  Set VMI IPv6 static default gateway address.
320a2148339SMegha G N    [Arguments]  ${vmi_staticipv6_gateway}  ${valid_status_codes}=${HTTP_ACCEPTED}
321a2148339SMegha G N    ...  ${interface}=${ethernet_interface}
322a2148339SMegha G N
323a2148339SMegha G N    # Description of argument(s):
324a2148339SMegha G N    # vmi_staticipv6_gateway   VMI static IPv6 default gateway address.
325a2148339SMegha G N    # valid_status_codes       Expected valid status code from PATCH request.
326a2148339SMegha G N    # interface                VMI interface (eg. eth0 or eth1).
327a2148339SMegha G N
328a2148339SMegha G N    ${patch_list}=  Create List  ${vmi_staticipv6_gateway}
329a2148339SMegha G N    ${data}=  Create Dictionary  IPv6StaticDefaultGateways=${patch_list}
330a2148339SMegha G N
331a2148339SMegha G N    Redfish.patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
332a2148339SMegha G N    ...  body=&{data}  valid_status_codes=[${valid_status_codes}]
333a2148339SMegha G N
334a2148339SMegha G N
335a2148339SMegha G NDelete VMI IPv6 Static Address
336a2148339SMegha G N    [Documentation]  Delete VMI IPv6 static address.
337a2148339SMegha G N    [Arguments]  ${valid_status_codes}=${HTTP_ACCEPTED}
338a2148339SMegha G N    ...  ${interface}=${ethernet_interface}
339a2148339SMegha G N
340a2148339SMegha G N    # Description of argument(s):
341a2148339SMegha G N    # valid_status_codes       Expected valid status code from PATCH request.
342a2148339SMegha G N    # interface                VMI interface (eg. eth0 or eth1).
343a2148339SMegha G N
344a2148339SMegha G N    ${data}=  Set Variable  {"IPv6StaticAddresses": [${Null}]}
345a2148339SMegha G N    Redfish.Patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
346a2148339SMegha G N    ...  body=${data}  valid_status_codes=[${valid_status_codes}]
347a2148339SMegha G N
348a2148339SMegha G N    Sleep  5s
349