xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_vmi.robot (revision 617b874b3269e4dc0fa669db45eae0eb9f58bc9e)
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    Run Keyword And Ignore Error  Suite Teardown Execution
10
11Test Tags         Vmi
12
13*** Variables ***
14
15# users           User Name               password
16@{ADMIN}          admin_user              TestPwd123
17@{OPERATOR}       operator_user           TestPwd123
18@{ReadOnly}       readonly_user           TestPwd123
19&{USERS}          Administrator=${ADMIN}  ReadOnly=${ReadOnly}
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
31${default}                      0.0.0.0
32${default_ipv6addr}             ::
33${prefix_length}                ${64}
34${test_vmi_ipv6addr}            2001:db8:1111:2222:10:5:5:6
35${test_vmi_ipv6gateway}         2001:db8:1111:2222::1
36${ipv4_hexword_addr}            10.5.5.6:1A:1B:1C:1D:1E:1F
37${multicast_ipv6addr}           FF00
38${loopback_ipv6addr}            ::1
39${compressed_ipv4}              ::10.6.6.5
40${shortform_stand_ipv4}         0:0:0:0:0:0:10.5.5.6
41${standard_ipv4rep}             0000:0000:0000:0000:0000:0000:10.5.5.6
42${ipv4_mapped_ipv6aadr}         00::FFFF:10.5.5.6
43${compressed_1hextet_ipv6aadr}  2001:DB8::1234:8:800:200c:417A
44
45
46*** Test Cases ***
47
48Verify All VMI EthernetInterfaces
49    [Documentation]  Verify all VMI ethernet interfaces.
50    [Tags]  Verify_All_VMI_EthernetInterfaces
51
52    Verify VMI EthernetInterfaces
53
54
55Verify Existing VMI Network Interface Details
56    [Documentation]  Verify existing VMI network interface details.
57    [Tags]  Verify_Existing_VMI_Network_Interface_Details
58
59    ${vmi_ip}=  Get VMI Network Interface Details
60    ${origin}=  Set Variable If  ${vmi_ip["DHCPv4"]} == ${False}  Static  DHCP
61    Should Not Be Equal  ${vmi_ip["DHCPv4"]}  ${vmi_ip["IPv4StaticAddresses"]}
62    Should Be Equal As Strings  ${vmi_ip["Id"]}  ${ethernet_interface}
63    Should Be Equal As Strings  ${vmi_ip["Description"]}
64    ...  Hypervisor's Virtual Management Ethernet Interface
65    Should Be Equal As Strings  ${vmi_ip["Name"]}  Hypervisor Ethernet Interface
66    IF   ${vmi_ip["IPv4StaticAddresses"]} != @{empty}
67         Verify VMI Network Interface Details  ${vmi_ip["IPv4_Address"]}
68         ...  ${origin}  ${vmi_ip["IPv4_Gateway"]}  ${vmi_ip["IPv4_SubnetMask"]}
69    END
70
71
72Delete Existing Static VMI IP Address
73    [Documentation]  Delete existing static VMI IP address.
74    [Tags]  Delete_Existing_Static_VMI_IP_Address
75
76    ${curr_origin}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
77    IF  ${curr_origin} == ${True}
78        Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}
79    END
80
81    Delete VMI IPv4 Address
82
83
84Verify User Cannot Delete ReadOnly Property IPv4Addresses
85    [Documentation]  Verify user cannot delete readonly property IPv4Addresses.
86    [Tags]  Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses
87
88    ${curr_origin}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
89    IF  ${curr_origin} == ${True}
90        Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}
91    END
92    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
93    Delete VMI IPv4 Address  IPv4Addresses  valid_status_code=${HTTP_FORBIDDEN}
94
95
96Assign Valid And Invalid Static IPv4 Address To VMI
97    [Documentation]  Assign static IPv4 address to VMI.
98    [Tags]  Assign_Valid_And_Invalid_Static_IPv4_Address_To_VMI
99    [Template]  Set Static IPv4 Address To VMI And Verify
100    [Teardown]   Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
101
102    # ip          gateway     netmask           valid_status_code
103    10.5.20.30    10.5.20.1     255.255.252.0    ${HTTP_ACCEPTED}
104    a.3.118.94    10.5.20.1     255.255.252.0    ${HTTP_BAD_REQUEST}
105    10.5.20       10.5.20.1     255.255.252.0    ${HTTP_BAD_REQUEST}
106    10.5.20.-5    10.5.20.1     255.255.252.0    ${HTTP_BAD_REQUEST}
107
108
109Add Multiple IP Addresses On VMI Interface And Verify
110    [Documentation]  Add multiple IP addresses on VMI interface and verify.
111    [Tags]  Add_Multiple_IP_Addresses_On_VMI_Interface_And_Verify
112    [Teardown]   Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
113
114    ${ip1}=  Create dictionary  Address=10.5.5.10  SubnetMask=255.255.252.0  Gateway=10.5.5.1
115    ${ip2}=  Create dictionary  Address=10.5.5.11  SubnetMask=255.255.252.0  Gateway=10.5.5.1
116    ${ip3}=  Create dictionary  Address=10.5.5.12  SubnetMask=255.255.252.0  Gateway=10.5.5.1
117    ${ips}=  Create List  ${ip1}  ${ip2}  ${ip3}
118
119    Redfish.Patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
120    ...  body={'IPv4StaticAddresses':${ips}}  valid_status_codes=[${HTTP_BAD_REQUEST}]
121
122
123Modify IP Addresses On VMI Interface And Verify
124    [Documentation]  Modify IP addresses on VMI interface and verify.
125    [Tags]  Modify_IP_Addresses_On_VMI_Interface_And_Verify
126    [Template]  Set Static IPv4 Address To VMI And Verify
127    [Teardown]   Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
128
129    # ip        gateway       netmask        valid_status_code
130    10.5.5.10   10.5.5.1     255.255.252.0    ${HTTP_ACCEPTED}
131    10.5.5.11   10.5.5.1     255.255.252.0    ${HTTP_ACCEPTED}
132
133
134Switch Between IP Origins On VMI And Verify Details
135    [Documentation]  Switch between IP origins on VMI and verify details.
136    [Tags]  Switch_Between_IP_Origins_On_VMI_And_Verify_Details
137
138    Switch VMI IPv4 Origin And Verify Details
139    Switch VMI IPv4 Origin And Verify Details
140
141
142Verify Persistency Of VMI IPv4 Details After Host Reboot
143    [Documentation]  Verify persistency of VMI IPv4 details after host reboot.
144    [Tags]  Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot
145
146    # Verifying persistency of dynamic address.
147    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
148    Redfish Power Off  stack_mode=skip
149    Redfish Power On
150    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
151
152    # Verifying persistency of static address.
153    Switch VMI IPv4 Origin And Verify Details
154    Redfish Power Off  stack_mode=skip
155    Redfish Power On
156    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
157
158
159Delete VMI Static IP Address And Verify
160    [Documentation]  Delete VMI static IP address and verify.
161    [Tags]  Delete_VMI_Static_IP_Address_And_Verify
162    [Teardown]  Test Teardown Execution
163
164    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
165    Delete VMI IPv4 Address
166
167
168Verify Successful VMI IP Static Configuration On HOST Boot After Session Delete
169    [Documentation]  Verify VMI IP static Configuration On HOST Boot After session deleted.
170    [Tags]  Verify_Successful_VMI_IP_Static_Configuration_On_HOST_Boot_After_Session_Delete
171    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
172
173    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
174
175    ${session_info}=  Get Redfish Session Info
176    Redfish.Delete  ${session_info["location"]}
177
178    # Create a new Redfish session
179    Redfish.Login
180    Redfish Power Off
181    Redfish Power On
182
183    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
184
185
186Verify Persistency Of VMI DHCP IP Configuration After Multiple HOST Reboots
187    [Documentation]  Verify Persistency Of VMI DHCP IP configuration After Multiple HOST Reboots
188    [Tags]  Verify_Persistency_Of_VMI_DHCP_IP_Configuration_After_Multiple_HOST_Reboots
189    [Teardown]  Test Teardown Execution
190
191    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
192    ${vmi_ip_config}=  Get VMI Network Interface Details
193    # Verifying persistency of dynamic address after multiple reboots.
194    FOR  ${i}  IN RANGE  ${2}
195        Redfish Power Off
196        Redfish Power On
197        Verify VMI Network Interface Details  ${vmi_ip_config["IPv4_Address"]}
198        ...  DHCP  ${vmi_ip_config["IPv4_Gateway"]}  ${vmi_ip_config["IPv4_SubnetMask"]}
199    END
200
201
202Enable DHCP When Static IP Configured And Verify Static IP
203    [Documentation]  Enable DHCP when static ip configured and verify static ip
204    [Tags]  Enable_DHCP_When_Static_IP_Configured_And_Verify_Static_IP
205    [Setup]  Redfish Power On
206    [Teardown]  Test Teardown Execution
207
208    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
209    Set VMI IPv4 Origin  ${True}
210    ${vmi_network_conf}=  Get VMI Network Interface Details
211    Should Not Be Equal As Strings  ${test_ipv4}  ${vmi_network_conf["IPv4_Address"]}
212
213
214Verify VMI Static IP Configuration Persist On BMC Reset Before Host Boot
215    [Documentation]  Verify VMI static IP configuration persist on BMC reset.
216    [Tags]   Verify_VMI_Static_IP_Configuration_Persist_On_BMC_Reset_Before_Host_Boot
217    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  FFDC On Test Case Fail
218
219    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
220    Redfish OBMC Reboot (off)  stack_mode=skip
221    Redfish Power On
222    # Verifying the VMI static configuration
223    Verify VMI Network Interface Details  ${test_ipv4}  Static   ${test_gateway}  ${test_netmask}
224
225
226Add Static IP When Host Poweroff And Verify On Poweron
227    [Documentation]  Add Static IP When Host Poweroff And Verify on power on
228    [Tags]   Add_Static_IP_When_Host_Poweroff_And_Verify_On_Poweron
229    [Setup]  Redfish Power Off
230    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  FFDC On Test Case Fail
231
232    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
233    Redfish Power On
234    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
235
236
237Add VMI Static IP When Host Poweroff And Verify Static IP On BMC Reset
238    [Documentation]  Add Static IP When Host Poweroff And Verify Static IP On BMC Reset.
239    [Tags]  Add_VMI_Static_IP_When_Host_Poweroff_And_Verify_Static_IP_On_BMC_Reset
240    [Setup]  Redfish Power Off
241    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  FFDC On Test Case Fail
242
243    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
244    Redfish OBMC Reboot (off)  stack_mode=skip
245    Redfish Power On
246    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
247
248
249Enable DHCP When No Static IP Configured And Verify DHCP IP
250    [Documentation]  Enable DHCP when no static ip configured and verify dhcp ip
251    [Tags]  Enable_DHCP_When_No_Static_IP_Configured_And_Verify_DHCP_IP
252    [Setup]  Run Keyword And Ignore Error  Delete VMI IPv4 Address
253    [Teardown]  Test Teardown Execution
254
255    ${curr_origin}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
256    IF  ${curr_origin} == ${False}
257        Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
258    END
259    ${vmi_ip_config}=  Get VMI Network Interface Details
260    Verify VMI Network Interface Details  ${vmi_ip_config["IPv4_Address"]}
261    ...  DHCP  ${vmi_ip_config["IPv4_Gateway"]}  ${vmi_ip_config["IPv4_SubnetMask"]}
262
263
264Verify User Cannot Delete VMI DHCP IP Address
265    [Documentation]  Verify user cannot delete VMI DHCP IP Address
266    [Tags]  Verify_User_Cannot_Delete_VMI_DHCP_IP_Address
267    [Setup]  Set VMI IPv4 Origin  ${True}
268    [Teardown]  Test Teardown Execution
269
270    Delete VMI IPv4 Address  IPv4Addresses  valid_status_code=${HTTP_FORBIDDEN}
271    ${resp}=  Redfish.Get
272    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
273    Should Not Be Empty  ${resp.dict["IPv4Addresses"]}
274
275
276Enable DHCP When Static IP Configured DHCP Server Unavailable And Verify IP
277    [Documentation]  Enable DHCP When Static IP Configured And DHCP Server Unavailable And Verify No IP.
278    [Tags]  Enable_DHCP_When_Static_IP_Configured_DHCP_Server_Unavailable_And_Verify_IP
279    [Teardown]  Test Teardown Execution
280
281    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
282    Set VMI IPv4 Origin  ${True}
283    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
284
285
286Verify To Configure VMI Static IP Address With Different User Roles
287    [Documentation]  Verify to configure vmi static ip address with different user roles.
288    [Tags]  Verify_To_Configure_VMI_Static_IP_Address_With_Different_User_Roles
289    [Setup]  Run Keywords  Delete BMC Users Using Redfish
290    ...  AND  Create Users With Different Roles  users=${USERS}  force=${True}
291    [Template]  Config VMI Static IP Address Using Different Users
292    [Teardown]  Delete BMC Users Using Redfish
293
294    # username     password    ip_address    gateway          nemask           valid_status_code
295    admin_user     TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_ACCEPTED}
296    readonly_user  TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_FORBIDDEN}
297
298
299Verify To Configure VMI Static IP Address With Operator User Role
300    [Documentation]  Verify to configure vmi static ip address with operator user role.
301    [Tags]  Verify_To_Configure_VMI_Static_IP_Address_With_Operator_User_Role
302    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
303    [Template]  Config VMI Static IP Address Using Different Users
304    [Teardown]  Delete BMC Users Using Redfish
305
306    # username     password    ip_address    gateway          nemask           valid_status_code
307    operator_user  TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_FORBIDDEN}
308
309
310Verify To Delete VMI Static IP Address With Different User Roles
311    [Documentation]  Verify to delete vmi static IP address with different user roles.
312    [Tags]  Verify_To_Delete_VMI_Static_IP_Address_With_Different_User_Roles
313    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
314    [Template]  Delete VMI Static IP Address Using Different Users
315    [Teardown]  Delete BMC Users Using Redfish
316
317    # username     password     valid_status_code
318    admin_user     TestPwd123   ${HTTP_ACCEPTED}
319    readonly_user  TestPwd123   ${HTTP_FORBIDDEN}
320
321
322Verify To Delete VMI Static IP Address With Operator User Role
323    [Documentation]  Verify to delete vmi static IP address with operator user role.
324    [Tags]  Verify_To_Delete_VMI_Static_IP_Address_With_Operator_User_Role
325    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
326    [Template]  Delete VMI Static IP Address Using Different Users
327    [Teardown]  Delete BMC Users Using Redfish
328
329    # username     password     valid_status_code
330    operator_user     TestPwd123   ${HTTP_FORBIDDEN}
331
332
333Verify To Update VMI Static IP Address With Different User Roles
334    [Documentation]  Verify to update vmi static IP address with different user roles.
335    [Tags]  Verify_To_Update_VMI_Static_IP_Address_With_Different_User_Roles
336    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
337    [Template]  Config VMI Static IP Address Using Different Users
338    [Teardown]  Delete BMC Users Using Redfish
339
340    # username     password     ip_address  gateway    netmask       valid_status_code
341    admin_user     TestPwd123   10.5.10.20  10.5.10.1  255.255.0.0  ${HTTP_ACCEPTED}
342    readonly_user  TestPwd123   10.5.20.40  10.5.20.1  255.255.0.0  ${HTTP_FORBIDDEN}
343
344
345Verify To Update VMI Static IP Address With Operator User Role
346    [Documentation]  Verify to update vmi static IP address with operator user role.
347    [Tags]  Verify_To_Update_VMI_Static_IP_Address_With_Operator_User_Role
348    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
349    [Template]  Config VMI Static IP Address Using Different Users
350    [Teardown]  Delete BMC Users Using Redfish
351
352    # username     password     ip_address  gateway    netmask       valid_status_code
353    operator_user  TestPwd123   10.5.10.30  10.5.10.1  255.255.0.0  ${HTTP_FORBIDDEN}
354
355
356Verify To Read VMI Network Configuration With Different User Roles
357    [Documentation]  Verify to read vmi network configuration with different user roles.
358    [Tags]  Verify_To_Read_VMI_Network_Configuration_With_Different_User_Roles
359    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
360    [Template]  Read VMI Static IP Address Using Different Users
361    [Teardown]  Delete BMC Users Using Redfish
362
363    # username     password     valid_status_code
364    admin_user     TestPwd123   ${HTTP_OK}
365    readonly_user  TestPwd123   ${HTTP_OK}
366
367
368Verify To Read VMI Network Configuration With Operator User Role
369    [Documentation]  Verify to read vmi network configuration with operator user role.
370    [Tags]  Verify_To_Read_VMI_Network_Configuration_With_Operator_User_Role
371    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
372    [Template]  Read VMI Static IP Address Using Different Users
373    [Teardown]  Delete BMC Users Using Redfish
374
375    # username     password     valid_status_code
376    operator_user  TestPwd123   ${HTTP_FORBIDDEN}
377
378
379Enable DHCP On VMI Network Via Different Users Roles And Verify
380    [Documentation]  Enable DHCP On VMI Network Via Different Users Roles And Verify.
381    [Tags]  Enable_DHCP_On_VMI_Network_Via_Different_Users_Roles_And_Verify
382    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
383    [Template]  Update User Role And Set VMI IPv4 Origin
384    [Teardown]  Delete BMC Users Using Redfish
385
386    # username     password     dhcp_enabled   valid_status_code
387    admin_user     TestPwd123   ${True}        ${HTTP_ACCEPTED}
388    readonly_user  TestPwd123   ${True}        ${HTTP_FORBIDDEN}
389
390
391Enable DHCP On VMI Network Via Operator User Role And Verify
392    [Documentation]  Enable DHCP On VMI Network Via Operator User Role And Verify.
393    [Tags]  Enable_DHCP_On_VMI_Network_Via_Operator_User_Role_And_Verify
394    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
395    [Template]  Update User Role And Set VMI IPv4 Origin
396    [Teardown]  Delete BMC Users Using Redfish
397
398    # username     password     dhcp_enabled   valid_status_code
399    operator_user  TestPwd123   ${True}        ${HTTP_FORBIDDEN}
400
401
402Disable DHCP On VMI Network Via Different Users Roles And Verify
403    [Documentation]  Disable DHCP On VMI Network Via Different Users Roles And Verify.
404    [Tags]  Disable_DHCP_On_VMI_Network_Via_Different_Users_Roles_And_Verify
405    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
406    [Template]  Update User Role And Set VMI IPv4 Origin
407    [Teardown]  Delete BMC Users Using Redfish
408
409    # username     password     dhcp_enabled    valid_status_code
410    admin_user     TestPwd123   ${False}        ${HTTP_ACCEPTED}
411    readonly_user  TestPwd123   ${False}        ${HTTP_FORBIDDEN}
412
413
414Disable DHCP On VMI Network Via Operator User Role And Verify
415    [Documentation]  Disable DHCP On VMI Network Via Operator User Role And Verify.
416    [Tags]  Disable_DHCP_On_VMI_Network_Via_Operator_User_Role_And_Verify
417    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
418    [Template]  Update User Role And Set VMI IPv4 Origin
419    [Teardown]  Delete BMC Users Using Redfish
420
421    # username     password     dhcp_enabled    valid_status_code
422    operator_user  TestPwd123   ${False}        ${HTTP_FORBIDDEN}
423
424
425Enable And Disable DHCP And Verify
426    [Documentation]  verify enable DHCP and disable DHCP.
427    [Tags]  Enable_And_Disable_DHCP_And_Verify
428
429    Set VMI IPv4 Origin  ${True}
430    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
431    Set VMI IPv4 Origin  ${False}
432    Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
433
434
435Multiple Times Enable And Disable DHCP And Verify
436    [Documentation]  Enable and Disable DHCP in a loop and verify VMI gets an IP address from DHCP
437    ...  each time when DHCP is enabled
438    [Tags]  Multiple_Times_Enable_And_Disable_DHCP_And_Verify
439
440    FOR  ${i}  IN RANGE  ${2}
441      Set VMI IPv4 Origin  ${True}
442      Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
443      Set VMI IPv4 Origin  ${False}
444      Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
445    END
446
447
448Assign Static IPv4 Address With Invalid Netmask To VMI
449    [Documentation]  Assign static IPv4 address with invalid netmask and expect error.
450    [Tags]  Assign_Static_IPv4_Address_With_Invalid_Netmask_To_VMI
451    [Template]  Set Static IPv4 Address To VMI And Verify
452
453    # ip          gateway          netmask         valid_status_code
454    ${test_ipv4}  ${test_gateway}  255.256.255.0   ${HTTP_BAD_REQUEST}
455    ${test_ipv4}  ${test_gateway}  ff.ff.ff.ff     ${HTTP_BAD_REQUEST}
456    ${test_ipv4}  ${test_gateway}  255.255.253.0   ${HTTP_BAD_REQUEST}
457
458
459Assign Static IPv4 Address With Invalid Gateway To VMI
460    [Documentation]  Add static IPv4 address with invalid gateway and expect error.
461    [Tags]  Assign_Static_IPv4_Address_With_Invalid_Gateway_To_VMI
462    [Template]  Set Static IPv4 Address To VMI And Verify
463
464    # ip          gateway          netmask           valid_status_code
465    ${test_ipv4}  @@@.%%.44.11     ${test_netmask}   ${HTTP_BAD_REQUEST}
466    ${test_ipv4}  0xa.0xb.0xc.0xd  ${test_netmask}   ${HTTP_BAD_REQUEST}
467    ${test_ipv4}  10.3.36          ${test_netmask}   ${HTTP_BAD_REQUEST}
468    ${test_ipv4}  10.3.36.-10      ${test_netmask}   ${HTTP_BAD_REQUEST}
469
470
471Enable DHCP When Host Is Off And Verify After Poweron
472    [Documentation]  Enable DHCP when host is off and
473    ...  check whether it is enabled after poweron.
474    [Tags]  Enable_DHCP_When_Host_Is_Off_And_Verify_After_Poweron
475    [Setup]  Redfish Power Off  stack_mode=skip
476
477    Set VMI IPv4 Origin  ${True}
478    Redfish Power On  stack_mode=skip
479    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
480
481
482Disable DHCP When Host Is Off And Verify New State Reflects After Power On
483    [Documentation]  Disable DHCP when host is off and
484    ...  get network info and verify that VMI origin is static.
485    [Tags]  Disable_DHCP_When_Host_Is_Off_And_Verify_New_State_Reflects_After_Power_On
486    [Setup]  Redfish Power Off  stack_mode=skip
487
488    Set VMI IPv4 Origin  ${False}
489    Redfish Power On  stack_mode=skip
490    Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
491
492
493Enable VMI Stateless Address AutoConfig And Verify
494    [Documentation]  Enable VMI SLAACv6 and verify an origin.
495    [Tags]  Enable_VMI_Stateless_Address_AutoConfig_And_Verify
496
497    Set VMI SLAACv6 Origin    ${True}
498
499    # Check origin is set to slaac and address are getting displayed.
500    Verify VMI IPv6 Address  SLAAC
501
502
503Disable VMI Stateless Address AutoConfig And Verify
504    [Documentation]  Disable VMI SLAACv6 and verify an origin.
505    [Tags]  Disable_VMI_Stateless_Address_AutoConfig_And_Verify
506    [Setup]  Set VMI SLAACv6 Origin    ${True}
507
508    Set VMI SLAACv6 Origin    ${False}
509
510    # Check origin is set to static and slaacv6 address are getting erased.
511    Verify VMI IPv6 Address  Static
512
513
514Enable VMI SLAAC And Check Persistency On BMC Reboot
515    [Documentation]  Enable VMI SLAACv6 and verify its persistency
516    ...  on BMC reboot and this works on the setup where router
517    ...  advertises network prefix.
518    [Tags]  Enable_VMI_SLAAC_And_Check_Persistency_On_BMC_Reboot
519
520    Set VMI SLAACv6 Origin    ${True}
521
522    # Reboot BMC and verify persistency.
523    OBMC Reboot (off)
524    Redfish Power On
525    Wait For Host Boot Progress To Reach Required State
526    Sleep  5s
527
528    # Check origin is set to slaac and address are getting displayed.
529    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  SLAAC
530    Should Not Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
531
532
533Disable VMI SLAAC And Check Persistency On BMC Reboot
534    [Documentation]  Disable VMI SLAACv6 and verify its persistency
535    ...  on BMC reboot.
536    [Tags]  Disable_VMI_SLAAC_And_Check_Persistency_On_BMC_Reboot
537
538    Set VMI SLAACv6 Origin    ${False}
539
540    # Reboot BMC and verify persistency.
541    OBMC Reboot (off)
542    Redfish Power On
543    Wait For Host Boot Progress To Reach Required State
544
545    # Check if origin is set to static and SLAAC address are getting erased.
546    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
547    Should Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
548
549
550Disable VMI DHCPv4 When SLAAC Is Enabled And Verify
551    [Documentation]  Disable VMI DHCPv4 parameter when SLAACv6 is enabled
552    ...  and check whether the IPv4 address origin is set to static and
553    ...  DHCPv4 address is getting erased.
554    [Tags]  Disable_VMI_DHCPv4_When_SLAAC_Is_Enabled_And_Verify
555    [Setup]  Set VMI IPv4 Origin  ${True}
556
557    # Set IPv6 origin to SLAAC.
558    Set VMI SLAACv6 Origin    ${True}
559    Verify VMI IPv6 Address  SLAAC
560
561    # Disable VMI DHCPv4 and check IPv4 address origin is set to static.
562    Set VMI IPv4 Origin  ${False}
563    Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
564
565
566Enable VMI SLAAC When DHCPv6 Is Enabled And Verify
567    [Documentation]  Enable VMI SLAACv6 when VMI DHCPv6 is enabled and
568    ...  check IPv6 gets Slaac address and this works on the setup
569    ...  where router advertise network prefix.
570    [Tags]  Enable_VMI_SLAAC_When_DHCPv6_Is_Enabled_And_Verify
571
572    Set VMI DHCPv6 Property  Enabled
573
574    # Enable SLAAC and check whether IPv6 origin is set to SLAAC.
575    Set VMI SLAACv6 Origin    ${True}
576
577    # Check if origin is set to slaac and address are getting displayed.
578    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  SLAAC
579    Should Not Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
580    Should Be Equal  ${vmi_ipv6addr["PrefixLength"]}  ${prefix_length}
581
582
583Disable VMI DHCPv6 Property And Verify
584    [Documentation]  Disable VMI DHCPv6 property and verify IPv6 address
585    ...              origin is set to static and DHCPv6 address is erased.
586    [Tags]  Disable_VMI_DHCPv6_Property_And_Verify
587    [Setup]  Set VMI DHCPv6 Property  Enabled
588
589    Set VMI DHCPv6 Property  Disabled
590
591    # Verify IPv6 address origin is set to static and DHCPv6 address is erased.
592    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
593    Should Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
594
595
596Enable VMI SLAAC When DHCPv4 Is Enabled And Verify
597    [Documentation]  On VMI enable SLAAC when DHCPv4 is enabled and verify DHCPv4 settings are intact
598    ...  and IPv6 origin is set to SLAAC & it gets assigned with SLAAC IPv6 address and this
599    ...  works on the setup where router advertise network prefix.
600    [Tags]  Enable_VMI_SLAAC_When_DHCPv4_Is_Enabled_And_Verify
601    [Setup]  Set VMI IPv4 Origin  ${True}
602
603    # Enable Autoconfig address and check whether IPv6 address origin is set to SLAAC.
604    Set VMI SLAACv6 Origin  ${True}
605    Verify VMI IPv6 Address  SLAAC
606
607    # Check there is no impact on IPv4 settings, IPv4 address origin should be DHCP.
608    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
609
610
611Disable VMI DHCPv6 Property And Check Persistency On BMC Reboot
612    [Documentation]  Disable VMI DHCPv6 property and verify its persistency on
613    ...  BMC reboot.
614    [Tags]  Disable_VMI_DHCPv6_Property_And_Check_Persistency_On_BMC_Reboot
615    [Setup]  Set VMI DHCPv6 Property  Enabled
616
617    Set VMI DHCPv6 Property  Disabled
618
619    # Reboot BMC and verify persistency.
620    OBMC Reboot (off)
621
622    # Verify IPv6 address origin is set to Static and DHCPv6 address is erased.
623    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
624    Should Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
625
626
627Enable VMI SLAAC When IPv4 Origin Is Static And Verify
628    [Documentation]  On VMI enable SLAAC when IPv4 origin is static and verify IPv4 settings are intact
629    ...  and IPv6 origin is set to SLAAC & it gets assigned with SLAAC IPv6 address and this works
630    ...  on the setup where router advertise network prefix.
631    [Tags]  Enable_VMI_SLAAC_When_IPv4_Origin_Is_Static_And_Verify
632    [Setup]  Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
633    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
634
635    # Enable Autoconfig address and check whether IPv6 address origin is set to SLAAC.
636    Set VMI SLAACv6 Origin  ${True}
637    Verify VMI IPv6 Address  SLAAC
638
639    # Check there is no impact on IPv4 settings, IPv4 address origin should be Static.
640    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
641
642
643Configure Static VMI IPv6 Address And Verify
644    [Documentation]  Add static VMI IPv6 address and check whether IPv6 origin is set to static
645    ...  and Static IPv6 address is assigned.
646    [Tags]  Configure_Static_VMI_IPv6_Address_And_Verify
647
648    Set Static VMI IPv6 Address  ${test_vmi_ipv6addr}  ${prefix_length}
649
650    # Verify IPv6 address origin is set to static and static IPv6 address is assigned.
651    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
652    Should Not Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
653    Should Be Equal  ${vmi_ipv6addr["PrefixLength"]}  ${prefix_length}
654
655
656Configure IPv6 Static Default Gateway On VMI And Verify
657    [Documentation]  Configure IPv6 static default gateway on VMI and verify.
658    [Tags]  Configure_IPv6_Static_Default_Gateway_On_VMI_And_Verify
659    [Setup]  Set Static VMI IPv6 Address  ${test_vmi_ipv6addr}  ${prefix_length}
660
661    Set VMI IPv6 Static Default Gateway  ${test_vmi_ipv6gateway}
662
663    ${resp}=  Redfish.Get
664    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
665    ${vmi_ipv6_gateways}=  Get From Dictionary  ${resp.dict}  IPv6StaticDefaultGateways
666    ${vmi_ipv6_gateway} =  Get From List  ${vmi_ipv6_gateways}  0
667    Should Be Equal  ${vmi_ipv6_gateway["Address"]}  ${test_vmi_ipv6gateway}
668
669
670Delete VMI Static IPv6 Address And Verify
671    [Documentation]  Delete VMI static IPv6 address and verify address is erased.
672    [Tags]  Delete_VMI_Static_IPv6_Address_And_Verify
673    [Setup]  Set Static VMI IPv6 Address  ${test_vmi_ipv6addr}  ${prefix_length}
674
675    # Delete VMI static IPv6 address.
676    Delete VMI IPv6 Static Address
677
678    # Verify VMI static IPv6 address is erased.
679    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
680    Should Not Be Equal  ${vmi_ipv6addr["Address"]}  ${test_vmi_ipv6addr}
681    Should Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
682
683
684Enable VMI DHCPv6 When IPv6 Origin Is Static And Verify
685    [Documentation]  Enable VMI DHCPv6 when IPv6 origin is in static and verify
686    ...  origin is set to DHCP and check if static IPv6 address is erased.
687    [Tags]  Enable_VMI_DHCPv6_When_IPv6_Origin_Is_Static_And_Verify
688
689    Set Static VMI IPv6 Address  ${test_vmi_ipv6addr}  ${prefix_length}
690    ${vmi_ipv6addr_static}=  Verify VMI IPv6 Address  Static
691
692    Sleep  5s
693
694    # Enable DHCPv6 property.
695    Set VMI DHCPv6 Property  Enabled
696
697    # Check origin is set to DHCP and static IPv6 address is erased.
698    ${vmi_dhcpv6addr}=  Verify VMI IPv6 Address  DHCPv6
699    Should Not Be Equal  ${vmi_dhcpv6addr["Address"]}  ${vmi_ipv6addr_static["Address"]}
700
701
702Configure Invalid Static IPv6 To VMI And Verify
703    [Documentation]  Configure invalid static IPv6 address to VMI and verify that address
704    ...  does not get assigned and it throws an error.
705    [Tags]  Configure_Invalid_Static_IPv6_To_VMI_And_Verify
706    [Setup]  Set Static VMI IPv6 Address  ${test_vmi_ipv6addr}  ${prefix_length}
707    [Template]  Set VMI Invalid Static IPv6 Address And Verify
708
709    # invalid_vmi_ipv6addr     invalid_prefix_length     valid_status_codes
710    ${default_ipv6addr}        128                       ${HTTP_BAD_REQUEST}
711    ${multicast_ipv6addr}      8                         ${HTTP_BAD_REQUEST}
712    ${loopback_ipv6addr}       64                        ${HTTP_BAD_REQUEST}
713    ${ipv4_hexword_addr}       64                        ${HTTP_BAD_REQUEST}
714
715
716Delete IPv6 Static Default Gateway On VMI And Verify
717    [Documentation]  Delete IPv6 static default gateway and verify address is erased.
718    [Tags]  Delete_IPv6_Static_Default_Gateway_On_VMI_And_Verify
719    [Setup]  Run Keywords  Set Static VMI IPv6 Address  ${test_vmi_ipv6addr}  ${prefix_length}
720    ...  AND  Set VMI IPv6 Static Default Gateway  ${test_vmi_ipv6gateway}
721
722    # Delete IPv6 static default gateway address.
723    Delete VMI IPv6 Static Default Gateway Address
724
725    Sleep  5s
726
727    # Verify static IPv6 default gateway address is deleted.
728    ${resp}=  Redfish.Get
729    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
730    Should Be Empty  ${resp.dict["IPv6StaticDefaultGateways"]}
731
732
733Disable VMI DHCPv6 When DHCPv4 Is Enabled And Verify
734    [Documentation]  Disable VMI DHCPv6 property when DHCPv4 is enabled and verify
735    ...  DHCPv4 settings are intact and verify IPv6 address origin is set to static.
736    [Tags]  Disable_VMI_DHCPv6_When_DHCPv4_Is_Enabled_And_Verify
737    [Setup]  Run Keywords  Set VMI DHCPv6 Property  Enabled
738    ...  AND  Set VMI IPv4 Origin  ${True}
739
740    Set VMI DHCPv6 Property  Disabled
741
742    # Verify IPv6 address origin is set to static and DHCPv6 address is erased.
743    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
744    Should Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
745
746    # Check there is no impact on IPv4 settings, IPv4 address origin should be DHCP.
747    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
748
749
750Assign Static VMI IPv6 Address And Check Persistency On BMC Reboot
751    [Documentation]  Add static VMI IPv6 address and check whether IPv6 origin is set to static
752    ...  and static IPv6 address is assigned after BMC reboot.
753    [Tags]  Assign_Static_VMI_IPv6_Address_And_Check_Persistency_On_BMC_Reboot
754
755    Set Static VMI IPv6 Address  ${test_vmi_ipv6addr}  ${prefix_length}
756
757    # Reboot BMC and verify persistency.
758    OBMC Reboot (off)
759    Redfish Power On
760    Wait For Host Boot Progress To Reach Required State
761
762    # Verify IPv6 address origin is set to static and static IPv6 address is assigned.
763    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
764    Should Not Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
765    Should Be Equal  ${vmi_ipv6addr["PrefixLength"]}  ${prefix_length}
766
767
768Enable VMI DHCPv6 When DHCPv4 Is Enabled And Verify
769    [Documentation]  Enable VMI DHCPv6 when DHCPv4 is enabled and verify
770    ...  DHCPv4 settings are intact and verify IPv6 address origin is set to DHCP.
771    [Tags]  Enable_VMI_DHCPv6_When_DHCPv4_Is_Enabled_And_Verify
772    [Setup]  Set VMI IPv4 Origin  ${True}
773
774    # Enable DHCPv6 property.
775    Set VMI DHCPv6 Property  Enabled
776
777    # Check IPv6 origin is set to DHCP.
778    Verify VMI IPv6 Address  DHCPv6
779
780    # Check there is no impact on IPv4 settings, IPv4 address origin should be DHCP.
781    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
782
783
784Assign Valid Static IPv6 Address And Verify
785    [Documentation]  Configure valid static IPv6 address to VMI and verify that address
786    ...  get assigned.
787    [Tags]  Assign_Valid_Static_IPv6_Address_And_Verify
788    [Template]  Set VMI Valid Static IPv6 Address And Verify
789
790    # valid_vmi_ipv6addr                valid_prefix_length
791    ${compressed_ipv4}                  64
792    ${shortform_stand_ipv4}             64
793    ${standard_ipv4rep}                 64
794    ${ipv4_mapped_ipv6aadr}             64
795    ${compressed_1hextet_ipv6aadr}      64
796
797
798Enable VMI DHCPv6 When IPv4 Origin Is Static And Verify
799    [Documentation]  Enable VMI DHCPv6 when IPv4 origin is static and verify
800    ...  IPv4 settings are intact and verify IPv6 address origin is set to DHCP.
801    [Tags]  Enable_VMI_DHCPv6_When_IPv4_Origin_Is_Static_And_Verify
802    [Setup]  Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
803
804    # Enable DHCPv6 property.
805    Set VMI DHCPv6 Property  Enabled
806
807    # Check IPv6 origin is set to DHCP.
808    Verify VMI IPv6 Address  DHCPv6
809
810    # Check there is no impact on IPv4 settings, IPv4 address origin should be static.
811    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
812
813
814Configures Static IPv6 When DHCPv4 Is Enabled And Verify
815    [Documentation]  Configure static IPv6 address when DHCPv4 is enabled and verify DHCPv4
816    ...  settings are intact and verify IPv6 origin is set to static and static IPv6 address is assigned.
817    [Tags]  Configures_Static_IPv6_When_DHCPv4_Is_Enabled_And_Verify
818    [Setup]  Set VMI IPv4 Origin  ${True}
819
820    Set VMI Valid Static IPv6 Address And Verify  ${test_vmi_ipv6addr}  ${prefix_length}
821
822    # Check there is no impact on IPv4 settings, IPv4 address origin should be DHCP.
823    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
824
825
826Configure Static IPv6 When IPv4 Origin Is Static And Verify
827    [Documentation]  Configure static IPv6 address when IPv4 address origin is static and verify IPv4
828    ...  settings are intact and verify IPv6 origin is set to static and static IPv6 address is assigned.
829    [Tags]  Configure_Static_IPv6_When_IPv4_Origin_Is_Static_And_Verify
830    [Setup]  Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
831    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
832
833    Set VMI Valid Static IPv6 Address And Verify  ${test_vmi_ipv6addr}  ${prefix_length}
834
835    # Check there is no impact on IPv4 settings, IPv4 address origin should be Static.
836    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
837
838
839*** Keywords ***
840
841Suite Setup Execution
842    [Documentation]  Do test setup execution task.
843
844    Redfish.Login
845
846    Redfish Power Off
847    Set BIOS Attribute  pvm_hmc_managed  Enabled
848    Set BIOS Attribute  pvm_stop_at_standby  Disabled
849
850    Redfish Power On
851    Wait For Host Boot Progress To Reach Required State
852
853    ${active_channel_config}=  Get Active Channel Config
854    Set Suite Variable   ${active_channel_config}
855    Set Suite Variable  ${ethernet_interface}  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
856    ${resp}=  Redfish.Get
857    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
858    ${ip_resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
859    ${length}=  Get Length  ${ip_resp["IPv4StaticAddresses"]}
860    ${vmi_network_conf}=  IF  ${length} != ${0}  Get VMI Network Interface Details
861    Set Suite Variable  ${vmi_network_conf}
862
863
864Test Teardown Execution
865    [Documentation]  Do test teardown execution task.
866
867    FFDC On Test Case Fail
868    ${curr_mode}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
869    IF  ${curr_mode} == ${True}
870        Set VMI IPv4 Origin  ${False}
871    END
872    IF  '${vmi_network_conf["IPv4_Address"]}' != '${default}'
873         Set Static IPv4 Address To VMI And Verify  ${vmi_network_conf["IPv4_Address"]}
874         ...  ${vmi_network_conf["IPv4_Gateway"]}  ${vmi_network_conf["IPv4_SubnetMask"]}
875    END
876
877
878Get Immediate Child Parameter From VMI Network Interface
879    [Documentation]  Get immediate child parameter from VMI network interface.
880    [Arguments]  ${parameter}  ${valid_status_code}=${HTTP_OK}
881
882    # Description of argument(s):
883    # parameter          parameter for which value is required. Ex: DHCPEnabled, MACAddress etc.
884    # valid_status_code  Expected valid status code from GET request.
885
886    ${resp}=  Redfish.Get
887    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
888    ...  valid_status_codes=[${valid_status_code}]
889
890    ${ip_resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
891    ${value}=  Set Variable If  '${parameter}' != 'DHCPEnabled'   ${ip_resp["${parameter}"]}
892    ...  ${ip_resp["DHCPv4"]["${parameter}"]}
893
894    RETURN  ${value}
895
896
897Switch VMI IPv4 Origin And Verify Details
898    [Documentation]  Switch VMI IPv4 origin and verify details.
899
900    ${dhcp_mode_before}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
901    ${dhcp_enabled}=  Set Variable If  ${dhcp_mode_before} == ${False}  ${True}  ${False}
902
903    ${origin}=  Set Variable If  ${dhcp_mode_before} == ${False}  DHCP  Static
904    Set VMI IPv4 Origin  ${dhcp_enabled}  ${HTTP_ACCEPTED}
905
906    ${dhcp_mode_after}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
907    Should Not Be Equal  ${dhcp_mode_before}  ${dhcp_mode_after}
908
909    IF  ${dhcp_mode_after} == ${True}
910        Verify VMI Network Interface Details  ${default}  ${origin}  ${default}  ${default}
911    END
912
913
914Delete VMI Static IP Address Using Different Users
915    [Documentation]  Update user role and delete vmi static IP address.
916    [Arguments]  ${username}  ${password}  ${valid_status_code}
917    [Teardown]  Run Keywords  Redfish.Login  AND
918    ...  Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}
919    ...  ${test_netmask}  ${HTTP_ACCEPTED}  AND  Redfish.Logout
920
921    # Description of argument(s):
922    # username            The host username.
923    # password            The host password.
924    # valid_status_code   The expected valid status code.
925
926    # TODO: operator_user role is not yet supported.
927    Skip If  '${username}' == 'operator_user'
928    Redfish.Login  ${username}  ${password}
929    Delete VMI IPv4 Address  delete_param=IPv4StaticAddresses  valid_status_code=${valid_status_code}
930
931
932Config VMI Static IP Address Using Different Users
933   [Documentation]  Update user role and update vmi static ip address.
934   [Arguments]  ${username}  ${password}  ${ip}  ${gateway}  ${netmask}
935   ...  ${valid_status_code}
936
937    # Description of argument(s):
938    # username            The host username.
939    # password            The host password.
940    # ip                  IP address to be added (e.g. "10.7.7.7").
941    # subnet_mask         Subnet mask for the IP to be added
942    #                     (e.g. "255.255.0.0").
943    # gateway             Gateway for the IP to be added (e.g. "10.7.7.1").
944    # valid_status_code   The expected valid status code.
945
946    # TODO: operator_user role is not yet supported.
947    Skip If  '${username}' == 'operator_user'
948    Redfish.Login  ${username}  ${password}
949    Set Static IPv4 Address To VMI And Verify  ${ip}  ${gateway}  ${netmask}  ${valid_status_code}
950
951
952Read VMI Static IP Address Using Different Users
953   [Documentation]  Update user role and read vmi static ip address.
954   [Arguments]  ${username}  ${password}  ${valid_status_code}
955
956    # Description of argument(s):
957    # username            The host username.
958    # password            The host password.
959    # valid_status_code   The expected valid status code.
960
961    # TODO: operator_user role is not yet supported.
962    Skip If  '${username}' == 'operator_user'
963    Redfish.Login  ${username}  ${password}
964    Redfish.Get
965    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
966    ...  valid_status_codes=[${valid_status_code}]
967
968
969Delete BMC Users Using Redfish
970   [Documentation]  Delete BMC users via redfish.
971
972   Redfish.Login
973   Delete BMC Users Via Redfish  users=${USERS}
974
975
976Update User Role And Set VMI IPv4 Origin
977    [Documentation]  Update User Role And Set VMI IPv4 Origin.
978    [Arguments]  ${username}  ${password}  ${dhcp_enabled}  ${valid_status_code}
979
980    # Description of argument(s):
981    # username            The host username.
982    # password            The host password.
983    # dhcp_enabled        Indicates whether dhcp should be enabled
984    #                     (${True}, ${False}).
985    # valid_status_code   The expected valid status code.
986
987    # TODO: operator_user role is not yet supported.
988    Skip If  '${username}' == 'operator_user'
989    Redfish.Login  ${username}  ${password}
990    Set VMI IPv4 Origin  ${dhcp_enabled}  ${valid_status_code}
991
992
993Suite Teardown Execution
994    [Documentation]  Do suite teardown execution task.
995
996    IF  ${vmi_network_conf} != ${None}
997        Set Static IPv4 Address To VMI And Verify  ${vmi_network_conf["IPv4_Address"]}
998    ...  ${vmi_network_conf["IPv4_Gateway"]}  ${vmi_network_conf["IPv4_SubnetMask"]}
999    END
1000
1001    Delete All Redfish Sessions
1002    Redfish.Logout
1003
1004
1005Set VMI Invalid Static IPv6 Address And Verify
1006    [Documentation]  Set VMI invalid static IPv6 address and verify it throws an error.
1007    [Arguments]  ${invalid_vmi_ipv6addr}  ${invalid_prefix_length}  ${valid_status_codes}
1008    ...  ${interface}=${ethernet_interface}
1009
1010    # Description of argument(s):
1011    # invalid_vmi_ipv6addr           VMI IPv6 address to be added.
1012    # invalid_prefix_length          Prefix length for the VMI IPv6 to be added.
1013    # valid_status_codes             Expected status code for PATCH request.
1014    # interface                      VMI interface (eg. eth0 or eth1).
1015
1016    Set Static VMI IPv6 Address  ${invalid_vmi_ipv6addr}  ${invalid_prefix_length}
1017    ...  ${valid_status_codes}
1018
1019    ${resp}=  Redfish.Get  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
1020
1021    @{vmi_ipv6_address}=  Get From Dictionary  ${resp.dict}  IPv6Addresses
1022    ${vmi_ipv6_addr}=  Get From List  ${vmi_ipv6_address}  0
1023    Should Not Be Equal  ${vmi_ipv6_addr["Address"]}  ${invalid_vmi_ipv6addr}
1024
1025
1026Delete VMI IPv6 Static Default Gateway Address
1027    [Documentation]  Delete VMI IPv6 static default gateway address.
1028    [Arguments]  ${valid_status_codes}=${HTTP_ACCEPTED}
1029    ...  ${interface}=${ethernet_interface}
1030
1031    # Description of argument(s):
1032    # valid_status_codes       Expected valid status code from PATCH request.
1033    # interface                VMI interface (eg. eth0 or eth1).
1034
1035    ${data}=  Set Variable  {"IPv6StaticDefaultGateways": [${Null}]}
1036    Redfish.Patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
1037    ...  body=${data}  valid_status_codes=[${valid_status_codes}]
1038
1039
1040Set VMI Valid Static IPv6 Address And Verify
1041    [Documentation]  Set valid static VMI IPv6 address and check whether IPv6 origin is set to static
1042    ...  and Static IPv6 address is assigned.
1043    [Arguments]  ${valid_vmi_ipv6addr}  ${valid_prefix_length}  ${valid_status_codes}=${HTTP_ACCEPTED}
1044    ...  ${interface}=${ethernet_interface}
1045
1046    # Description of argument(s):
1047    # valid_vmi_ipv6addr           VMI IPv6 address to be added.
1048    # valid_prefix_length          Prefix length for the VMI IPv6 to be added.
1049    # valid_status_codes           Expected status code for PATCH request.
1050    # interface                    VMI interface (eg. eth0 or eth1).
1051
1052    Set Static VMI IPv6 Address  ${valid_vmi_ipv6addr}  ${valid_prefix_length}
1053    ...  ${valid_status_codes}
1054
1055    ${vmi_ipv6}=  Verify VMI IPv6 Address  Static
1056    Should Be Equal  ${vmi_ipv6["Address"]}  ${valid_vmi_ipv6addr}
1057