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