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