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