xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_vmi.robot (revision cb646ccafa43295a4057c2be1e4049c4e5fa6eb2)
1*** Settings ***
2
3Documentation    VMI static/dynamic IP config tests.
4
5Resource         ../../lib/resource.robot
6Resource         ../../lib/bmc_redfish_resource.robot
7Resource         ../../lib/openbmc_ffdc.robot
8Resource         ../../lib/bmc_redfish_utils.robot
9Library          ../../lib/bmc_network_utils.py
10
11Suite Setup       Suite Setup Execution
12Test Teardown     FFDC On Test Case Fail
13Suite Teardown    Redfish.Logout
14
15*** Variables ***
16
17# users           User Name               password
18@{ADMIN}          admin_user              TestPwd123
19@{OPERATOR}       operator_user           TestPwd123
20@{ReadOnly}       readonly_user           TestPwd123
21@{NoAccess}       noaccess_user           TestPwd123
22&{USERS}          Administrator=${ADMIN}  Operator=${OPERATOR}  ReadOnly=${ReadOnly}
23...               NoAccess=${NoAccess}
24
25${test_ipv4}              10.6.6.6
26${test_gateway}           10.6.6.1
27${test_netmask}           255.255.252.0
28
29&{DHCP_ENABLED}           DHCPEnabled=${${True}}
30&{DHCP_DISABLED}          DHCPEnabled=${${False}}
31
32&{ENABLE_DHCP}            DHCPv4=&{DHCP_ENABLED}
33&{DISABLE_DHCP}           DHCPv4=&{DHCP_DISABLED}
34${wait_time}              10s
35
36
37*** Test Cases ***
38
39Verify All VMI EthernetInterfaces
40    [Documentation]  Verify all VMI ethernet interfaces.
41    [Tags]  Verify_All_VMI_EthernetINterfaces
42
43    Verify VMI EthernetInterfaces
44
45
46Verify Existing VMI Network Interface Details
47    [Documentation]  Verify existing VMI network interface details.
48    [Tags]  Verify_VMI_Network_Interface_Details
49
50    ${vmi_ip}=  Get VMI Network Interface Details
51    ${origin}=  Set Variable If  ${vmi_ip["DHCPv4"]} == ${False}  Static  DHCP
52
53    Should Not Be Equal  ${vmi_ip["DHCPv4"]}  ${vmi_ip["IPv4StaticAddresses"]}
54    Should Be Equal As Strings  ${origin}  ${vmi_ip["IPv4_AddressOrigin"]}
55    Should Be Equal As Strings  ${vmi_ip["Id"]}  intf0
56    Should Be Equal As Strings  ${vmi_ip["Description"]}
57    ...  Ethernet Interface for Virtual Management Interface
58    Should Be Equal As Strings  ${vmi_ip["Name"]}  Virtual Management Interface
59    Should Be True  ${vmi_ip["InterfaceEnabled"]}
60
61
62Delete Existing Static VMI IP Address
63    [Documentation]  Delete existing static VMI IP address.
64    [Tags]  Delete_Existing_Static_VMI_IP_Address
65
66    ${curr_origin}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
67    Run Keyword If  ${curr_origin} == ${True}  Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}
68
69    Delete VMI IPv4 Address  IPv4StaticAddresses  valid_status_code=${HTTP_ACCEPTED}
70    ${default}=  Set Variable  0.0.0.0
71    Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
72
73
74Verify User Cannot Delete ReadOnly Property IPv4Addresses
75    [Documentation]  Verify user cannot delete readonly property IPv4Addresses.
76    [Tags]  Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses
77
78    ${curr_origin}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
79    Run Keyword If  ${curr_origin} == ${False}  Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
80    Delete VMI IPv4 Address  IPv4Addresses  valid_status_code=${HTTP_BAD_REQUEST}
81
82
83Assign Valid And Invalid Static IPv4 Address To VMI
84    [Documentation]  Assign static IPv4 address to VMI.
85    [Tags]  Assign_Valid_And_Invalid_Static_IPv4_Address_To_VMI
86    [Template]  Verify Assigning Static IPv4 Address To VMI
87    [Teardown]   Run keywords  Delete VMI IPv4 Address  IPv4Addresses
88    ...  AND  Test Teardown Execution
89
90    # ip          gateway     netmask           valid_status_code
91    10.5.20.30    0.0.0.0     255.255.252.0    ${HTTP_ACCEPTED}
92    a.3.118.94    0.0.0.0     255.255.252.0    ${HTTP_BAD_REQUEST}
93
94
95Add Multiple IP Addreses On VMI Interface And Verify
96    [Documentation]  Add multiple IP addreses on VMI interface and verify.
97    [Tags]  Add_Multiple_IP_Addreses_On_VMI_Interface_And_Verify
98    [Teardown]   Run keywords  Delete VMI IPv4 Address  IPv4Addresses
99    ...  AND  Test Teardown Execution
100
101    ${ip1}=  Create dictionary  Address=10.5.5.10  SubnetMask=255.255.252.0  Gateway=0.0.0.0
102    ${ip2}=  Create dictionary  Address=10.5.5.11  SubnetMask=255.255.252.0  Gateway=0.0.0.0
103    ${ip3}=  Create dictionary  Address=10.5.5.12  SubnetMask=255.255.252.0  Gateway=0.0.0.0
104    ${ips}=  Create List  ${ip1}  ${ip2}  ${ip3}
105
106    ${active_channel_config}=  Get Active Channel Config
107    Redfish.Patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
108    ...  body={'IPv4StaticAddresses':${ips}}  valid_status_codes=[${HTTP_ACCEPTED}]
109    Verify VMI Network Interface Details   ${ip1["Address"]}  Static  ${ip1["Gateway"]}  ${ip1["SubnetMask"]}
110
111
112Modify IP Addresses On VMI Interface And Verify
113    [Documentation]  Modify IP addresses on VMI interface and verify.
114    [Tags]  Modify_IP_Addresses_On_VMI_Interface_And_Verify
115    [Template]  Verify Assigning Static IPv4 Address To VMI
116    [Teardown]   Run keywords  Delete VMI IPv4 Address  IPv4Addresses
117    ...  AND  Test Teardown Execution
118
119    # ip        gateway       netmask        valid_status_code
120    10.5.5.10   0.0.0.0     255.255.252.0    ${HTTP_ACCEPTED}
121    10.5.5.11   0.0.0.0     255.255.252.0    ${HTTP_ACCEPTED}
122
123Switch Between IP Origins On VMI And Verify Details
124    [Documentation]  Switch between IP origins on VMI and verify details.
125    [Tags]  Switch_Between_IP_Origins_On_VMI_And_Verify_Details
126
127    Switch VMI IPv4 Origin And Verify Details
128    Switch VMI IPv4 Origin And Verify Details
129
130
131Verify Persistency Of VMI IPv4 Details After Host Reboot
132    [Documentation]  Verify persistency of VMI IPv4 details after host reboot.
133    [Tags]  Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot
134
135    # Verifying persistency of dynamic address.
136    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
137    ${default}=  Set Variable  0.0.0.0
138    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
139    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
140
141    # Verifying persistency of static address.
142    Switch VMI IPv4 Origin And Verify Details  ${True}
143    Verify Assigning Static IPv4 Address To VMI  ${test_ipv4}  ${test_gateway}  ${test_netmask}
144    Verify VMI Network Interface Details  ${test_ipv4}  ${test_gateway}  ${test_netmask}
145
146
147Delete VMI Static IP Address And Verify
148    [Documentation]  Delete VMI static IP address and verify.
149    [Tags]  Delete_VMI_Static_IP_Address_And_Verify
150    [Teardown]  Test Teardown Execution
151
152    Verify Assigning Static IPv4 Address To VMI  ${test_ipv4}  ${test_gateway}  ${test_netmask}
153    Delete VMI IPv4 Address  IPv4Addresses  ${HTTP_ACCEPTED}
154    ${active_channel_config}=  Get Active Channel Config
155    ${resp}=  Redfish.Get
156    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
157    Should Be Empty  ${resp.dict["IPv4Addresses"]}
158
159
160Verify Successful VMI IP Static Configuration On HOST Boot After Session Delete
161    [Documentation]  Verify VMI IP static Configuration On HOST Boot After session deleted.
162    [Tags]  Verify_Successful_VMI_IP_Static_Configuration_On_HOST_Boot_After_Session_Delete
163    [Teardown]  Run keywords  Delete VMI IPv4 Address  IPv4Addresses  AND  Test Teardown Execution
164
165    Set Static IPv4 Address To VMI  ${test_ipv4}  ${test_gateway}  ${test_netmask}
166
167    ${session_info}=  Get Redfish Session Info
168    Redfish.Delete  ${session_info["location"]}
169
170    # Create a new Redfish session
171    Redfish Power Off
172    Redfish Power On
173
174    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
175
176
177Verify Persistency Of VMI DHCP IP Configuration After Multiple HOST Reboots
178    [Documentation]  Verify Persistency Of VMI DHCP IP configuration After Multiple HOST Reboots
179    [Tags]  Verify_Persistency_Of_VMI_DHCP_IP_Configuration_After_Multiple_HOST_Reboots
180    [Teardown]  Test Teardown Execution
181
182    ${LOOP_COUNT}=  Set Variable  ${3}
183    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
184    Run Keywords  Redfish Power Off  AND  Redfish Power On
185    ${vmi_ip_config}=  Get VMI Network Interface Details
186    # Verifying persistency of dynamic address after multiple reboots.
187    Repeat Keyword  ${LOOP_COUNT} times
188    ...  Verify VMI Network Interface Details  ${vmi_ip_config["IPv4_Address"]}  DHCP  ${vmi_ip_config["IPv4_Gateway"]}
189    ...  ${vmi_ip_config["IPv4_SubnetMask"]}
190
191
192Enable DHCP When Static IP Configured And Verify Static IP
193    [Documentation]  Enable DHCP when static ip configured and verify static ip
194    [Tags]  Enable_DHCP_when_Static_IP_Configured_And_Verify_Static_IP
195    [Teardown]  Test Teardown Execution
196
197    Verify Assigning Static IPv4 Address To VMI  ${test_ipv4}  ${test_gateway}  ${test_netmask}
198    Set VMI IPv4 Origin  ${True}
199    Redfish Power Off
200    Redfish Power On
201    ${vmi_network_conf}=  Get VMI Network Interface Details
202    Should Not Be Equal As Strings  ${test_ipv4}  ${vmi_network_conf["IPv4_Address"]}
203
204
205Verify VMI Static IP Configuration Persist On BMC Reset Before Host Boot
206    [Documentation]  Verify VMI static IP configuration persist on BMC reset.
207    [Tags]   Verify_VMI_Static_IP_Configuration_Persist_On_BMC_Reset_Before_Host_Boot
208    [Teardown]  Run keywords  Delete VMI IPv4 Address  IPv4Addresses  AND  FFDC On Test Case Fail
209
210    Set Static IPv4 Address To VMI  ${test_ipv4}  ${test_gateway}  ${test_netmask}
211    OBMC Reboot (off)
212    Redfish Power On
213    # Verifying the VMI static configuration
214    Verify VMI Network Interface Details  ${test_ipv4}  Static   ${test_gateway}  ${test_netmask}
215
216
217Verify To Configure VMI Static IP Address With Different User Roles
218    [Documentation]  Verify to configure vmi static ip address with different user roles.
219    [Tags]  Verify_To_Configure_VMI_Static_IP_Address_With_Different_User_Roles
220    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
221    [Template]  Config VMI Static IP Address Using Different Users
222    [Teardown]  Delete BMC Users Using Redfish
223
224    # username     password    ip_address    gateway          nemask           valid_status_code
225    admin_user     TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_ACCEPTED}
226    operator_user  TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_FORBIDDEN}
227    readonly_user  TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_FORBIDDEN}
228    noaccess_user  TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_FORBIDDEN}
229
230
231Verify To Delete VMI Static IP Address With Different User Roles
232    [Documentation]  Verify to delete vmi static IP address with different user roles.
233    [Tags]  Verify_To_Delete_VMI_Static_IP_Address_With_Different_User_Roles
234    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
235    [Template]  Delete VMI Static IP Address Using Different Users
236    [Teardown]  Delete BMC Users Using Redfish
237
238    # username     password     valid_status_code
239    admin_user     TestPwd123   ${HTTP_ACCEPTED}
240    operator_user  TestPwd123   ${HTTP_FORBIDDEN}
241    readonly_user  TestPwd123   ${HTTP_FORBIDDEN}
242    noaccess_user  TestPwd123   ${HTTP_FORBIDDEN}
243
244
245Verify To Update VMI Static IP Address With Different User Roles
246    [Documentation]  Verify to update vmi static IP address with different user roles.
247    [Tags]  Verify_To_Update_VMI_Static_IP_Address_With_Different_User_Roles_And_Verify
248    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
249    [Template]  Config VMI Static IP Address Using Different Users
250    [Teardown]  Delete BMC Users Using Redfish
251
252    # username     password     ip_address  gateway  nemask       valid_status_code
253    admin_user     TestPwd123   10.5.10.20  0.0.0.0  255.255.0.0  ${HTTP_ACCEPTED}
254    operator_user  TestPwd123   10.5.10.30  0.0.0.0  255.255.0.0  ${HTTP_FORBIDDEN}
255    readonly_user  TestPwd123   10.5.20.40  0.0.0.0  255.255.0.0  ${HTTP_FORBIDDEN}
256    noaccess_user  TestPwd123   10.5.30.50  0.0.0.0  255.255.0.0  ${HTTP_FORBIDDEN}
257
258
259Verify To Read VMI Network Configuration With Different User Roles
260    [Documentation]  Verify to read vmi network configuration with different user roles.
261    [Tags]  Verify_To_Read_VMI_Network_Configuration_Via_Different_User_Roles
262    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
263    [Template]  Read VMI Static IP Address Using Different Users
264    [Teardown]  Delete BMC Users Using Redfish
265
266    # username     password     valid_status_code
267    admin_user     TestPwd123   ${HTTP_OK}
268    operator_user  TestPwd123   ${HTTP_OK}
269    readonly_user  TestPwd123   ${HTTP_OK}
270    noaccess_user  TestPwd123   ${HTTP_FORBIDDEN}
271
272
273*** Keywords ***
274
275Suite Setup Execution
276    [Documentation]  Do test setup execution task.
277
278    Redfish.Login
279    Redfish Power On
280    ${active_channel_config}=  Get Active Channel Config
281    Set Suite Variable   ${active_channel_config}
282    ${resp}=  Redfish.Get
283    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
284    ${ip_resp}=  Evaluate  json.loads('''${resp.text}''')  json
285    ${length}=  Get Length  ${ip_resp["IPv4StaticAddresses"]}
286    ${vmi_network_conf}=  Run Keyword If  ${length} != ${0}  Get VMI Network Interface Details
287    Set Suite Variable  ${vmi_network_conf}
288
289
290Test Teardown Execution
291    [Documentation]  Do test teardown execution task.
292
293    FFDC On Test Case Fail
294    ${curr_mode}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
295    Run Keyword If  ${curr_mode} == ${True}  Set VMI IPv4 Origin  ${False}
296    Run Keyword If  ${vmi_network_conf} != ${None}
297    ...  Verify Assigning Static IPv4 Address To VMI  ${vmi_network_conf["IPv4_Address"]}
298    ...  ${vmi_network_conf["IPv4_Gateway"]}  ${vmi_network_conf["IPv4_SubnetMask"]}
299
300
301Get VMI Network Interface Details
302    [Documentation]  Get VMI network interface details.
303    [Arguments]  ${valid_status_code}=${HTTP_OK}
304
305    # Description of argument(s):
306    # valid_status_code  Expected valid status code from GET request.
307
308    # Note: It returns a dictionary of VMI eth0 parameters.
309
310    ${active_channel_config}=  Get Active Channel Config
311    ${resp}=  Redfish.Get
312    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
313    ...  valid_status_codes=[${valid_status_code}]
314
315    ${ip_resp}=  Evaluate  json.loads('''${resp.text}''')  json
316
317    ${static_exists}=  Run Keyword And Ignore Error
318    ...  Set Variable  ${ip_resp["IPv4StaticAddresses"][0]["Address"]}
319    ${static_exists}=  Set Variable If  '${static_exists[0]}' == 'PASS'  ${True}  ${False}
320
321    ${vmi_ip}=  Create Dictionary  DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}}  Id=${ip_resp["Id"]}
322    ...  Description=${ip_resp["Description"]}  IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]}
323    ...  IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]}  Name=${ip_resp["Name"]}
324    ...  IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]}
325    ...  InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}}
326    ...  IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]}
327    ...  IPv4StaticAddresses=${${static_exists}}
328
329    [Return]  &{vmi_ip}
330
331
332Get Immediate Child Parameter From VMI Network Interface
333    [Documentation]  Get immediate child parameter from VMI network interface.
334    [Arguments]  ${parameter}  ${valid_status_code}=${HTTP_OK}
335
336    # Description of argument(s):
337    # parameter          parameter for which value is required. Ex: DHCPEnabled, MACAddress etc.
338    # valid_status_code  Expected valid status code from GET request.
339
340    ${active_channel_config}=  Get Active Channel Config
341    ${resp}=  Redfish.Get
342    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
343    ...  valid_status_codes=[${valid_status_code}]
344
345    ${ip_resp}=  Evaluate  json.loads('''${resp.text}''')  json
346    ${value}=  Set Variable If  '${parameter}' != 'DHCPEnabled'   ${ip_resp["${parameter}"]}
347    ...  ${ip_resp["DHCPv4"]["${parameter}"]}
348
349    [Return]  ${value}
350
351Verify VMI EthernetInterfaces
352    [Documentation]  Verify VMI ethernet interfaces.
353    [Arguments]  ${valid_status_code}=${HTTP_OK}
354
355    # Description of argument(s):
356    # valid_status_code  Expected valid status code from GET request.
357
358    ${resp}=  Redfish.Get  /redfish/v1/Systems/hypervisor/EthernetInterfaces
359    ...  valid_status_codes=[${valid_status_code}]
360
361    ${resp}=  Evaluate  json.loads('''${resp.text}''')  json
362    ${interfaces}=  Set Variable  ${resp["Members"]}
363
364    Should Be Equal As Strings  ${interfaces[0]}[@odata.id]
365    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0
366    Should Be Equal As Strings  ${interfaces[1]}[@odata.id]
367    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth1
368
369    Should Be Equal  ${resp["Members@odata.count"]}  ${2}
370
371
372Verify VMI Network Interface Details
373    [Documentation]  Verify VMI network interface details.
374    [Arguments]  ${ip}  ${origin}  ${gateway}  ${netmask}
375    ...  ${valid_status_code}=${HTTP_OK}
376
377    # Description of argument(s):
378    # ip                 VMI IPv4 address.
379    # origin             Origin of IPv4 address eg. Static or DHCP.
380    # gateway            Gateway for VMI IP.
381    # netmask            Subnetmask for VMI IP.
382    # valid_status_code  Expected valid status code from GET request. Default is HTTP_OK.
383
384    ${vmi_ip}=  Get VMI Network Interface Details  ${valid_status_code}
385    Should Be Equal As Strings  ${origin}  ${vmi_ip["IPv4_AddressOrigin"]}
386    Should Be Equal As Strings  ${gateway}  ${vmi_ip["IPv4_Gateway"]}
387    Should Be Equal As Strings  ${netmask}  ${vmi_ip["IPv4_SubnetMask"]}
388    Should Be Equal As Strings  ${ip}  ${vmi_ip["IPv4_Address"]}
389
390Set Static IPv4 Address To VMI
391    [Documentation]  Set static IPv4 address to VMI.
392    [Arguments]  ${ip}  ${gateway}  ${netmask}  ${valid_status_code}=${HTTP_ACCEPTED}
393
394    # Description of argument(s):
395    # ip                 VMI IPv4 address.
396    # gateway            Gateway for VMI IP.
397    # netmask            Subnetmask for VMI IP.
398    # valid_status_code  Expected valid status code from GET request. Default is HTTP_ACCEPTED.
399
400    ${data}=  Set Variable
401    ...  {"IPv4StaticAddresses": [{"Address": "${ip}","SubnetMask": "${netmask}","Gateway": "${gateway}"}]}
402
403    ${active_channel_config}=  Get Active Channel Config
404    ${resp}=  Redfish.Patch
405    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
406    ...  body=${data}  valid_status_codes=[${valid_status_code}]
407
408    # Wait few seconds for new configuration to get populated on runtime.
409    Sleep  ${wait_time}
410    Log To Console  ${resp.text}
411
412
413Verify Assigning Static IPv4 Address To VMI
414    [Documentation]    Verify assigning static IPv4 address to VMI.
415    [Arguments]  ${ip}  ${gateway}  ${netmask}  ${valid_status_code}=${HTTP_ACCEPTED}
416
417    # Description of argument(s):
418    # ip                 VMI IPv4 address.
419    # gateway            Gateway for VMI IP.
420    # netmask            Subnetmask for VMI IP.
421    # valid_status_code  Expected valid status code from GET request. Default is HTTP_ACCEPTED.
422
423
424    Set Static IPv4 Address To VMI  ${ip}  ${gateway}  ${netmask}  valid_status_code=${valid_status_code}
425    Return From Keyword If  ${valid_status_code} != ${HTTP_ACCEPTED}
426
427    Verify VMI Network Interface Details  ${ip}  Static  ${gateway}  ${netmask}
428
429
430Delete VMI IPv4 Address
431    [Documentation]  Delete VMI IPv4 address.
432    [Arguments]  ${delete_param}=IPv4StaticAddresses  ${valid_status_code}=${HTTP_ACCEPTED}
433
434    # Description of argument(s):
435    # delete_param       Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses.
436    #                    Default is IPv4StaticAddresses.
437    # valid_status_code  Expected valid status code from PATCH request. Default is HTTP_OK.
438
439    ${data}=  Set Variable  {"${delete_param}": [${Null}]}
440    ${active_channel_config}=  Get Active Channel Config
441    ${resp}=  Redfish.Patch
442    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
443    ...  body=${data}  valid_status_codes=[${valid_status_code}]
444
445
446Set VMI IPv4 Origin
447    [Documentation]  Set VMI IPv4 origin.
448    [Arguments]  ${dhcp_enabled}=${False}  ${valid_status_code}=${HTTP_ACCEPTED}
449
450    # Description of argument(s):
451    # dhcp_enabled       True if user wants to enable DHCP. Default is Static, hence value is set to False.
452    # valid_status_code  Expected valid status code from PATCH request. Default is HTTP_OK.
453
454    ${data}=  Set Variable If  ${dhcp_enabled} == ${False}  ${DISABLE_DHCP}  ${ENABLE_DHCP}
455    ${resp}=  Redfish.Patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0  body=${data}
456    ...  valid_status_codes=[${valid_status_code}]
457
458
459Switch VMI IPv4 Origin And Verify Details
460    [Documentation]  Switch VMI IPv4 origin and verify details.
461    [Arguments]  ${host_reboot}=${False}
462
463    # Description of argument(s):
464    # host_reboot        Reboot HOST if True.
465
466    ${curr_mode}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
467    ${dhcp_enabled}=  Set Variable If  ${curr_mode} == ${False}  ${True}  ${False}
468
469    ${default}=  Set Variable  0.0.0.0
470    ${origin}=  Set Variable If  ${curr_mode} == ${False}  DHCP  Static
471    Set VMI IPv4 Origin  ${dhcp_enabled}  ${HTTP_ACCEPTED}
472    Verify VMI Network Interface Details  ${default}  ${origin}  ${default}  ${default}
473
474    [Return]  ${origin}
475
476
477Delete VMI Static IP Address Using Different Users
478    [Documentation]  Update user role and delete vmi static IP address.
479    [Arguments]  ${username}  ${password}  ${valid_status_code}
480    [Teardown]  Run Keywords  Redfish.Login  AND
481    ...  Verify Assigning Static IPv4 Address To VMI  ${test_ipv4}  ${test_gateway}
482    ...  ${test_netmask}  ${HTTP_ACCEPTED}  AND  Redfish.Logout
483
484    # Description of argument(s):
485    # username            The host username.
486    # password            The host password.
487    # valid_status_code   The expected valid status code.
488
489    Redfish.Login  ${username}  ${password}
490    Delete VMI IPv4 Address  delete_param=IPv4StaticAddresses  valid_status_code=${valid_status_code}
491    Redfish.Logout
492
493
494Config VMI Static IP Address Using Different Users
495   [Documentation]  Update user role and update vmi static ip address.
496   [Arguments]  ${username}  ${password}  ${ip}  ${gateway}  ${netmask}
497   ...  ${valid_status_code}
498
499    # Description of argument(s):
500    # username            The host username.
501    # password            The host password.
502    # ip                  IP address to be added (e.g. "10.7.7.7").
503    # subnet_mask         Subnet mask for the IP to be added
504    #                     (e.g. "255.255.0.0").
505    # gateway             Gateway for the IP to be added (e.g. "10.7.7.1").
506    # valid_status_code   The expected valid status code.
507
508    Redfish.Login  ${username}  ${password}
509    Verify Assigning Static IPv4 Address To VMI  ${ip}  ${gateway}  ${netmask}  ${valid_status_code}
510    Redfish.Logout
511
512
513Read VMI Static IP Address Using Different Users
514   [Documentation]  Update user role and read vmi static ip address.
515   [Arguments]  ${username}  ${password}  ${valid_status_code}
516
517    # Description of argument(s):
518    # username            The host username.
519    # password            The host password.
520    # valid_status_code   The expected valid status code.
521
522    Redfish.Login  ${username}  ${password}
523    Redfish.Get
524    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
525    ...  valid_status_codes=[${valid_status_code}]
526    Redfish.Logout
527
528
529Delete BMC Users Using Redfish
530   [Documentation]  Delete BMC users via redfish.
531
532   Redfish.Login
533   Delete BMC Users Via Redfish  users=${USERS}
534