xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_vmi.robot (revision 063805fe3dc88ee801ce2d5eeb66032f252e33c0)
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&{SLAAC_ENABLED}          IPv6AutoConfigEnabled=${True}
32&{SLAAC_DISABLED}         IPv6AutoConfigEnabled=${False}
33
34&{ENABLE_SLAAC}           StatelessAddressAutoConfig=&{SLAAC_ENABLED}
35&{DISABLE_SLAAC}          StatelessAddressAutoConfig=&{SLAAC_DISABLED}
36
37&{DHCPv6_ENABLED}         OperatingMode=Enabled
38&{DHCPv6_DISABLED}        OperatingMode=Disabled
39
40&{ENABLE_DHCPv6}          DHCPv6=&{DHCPv6_ENABLED}
41&{DISABLE_DHCPv6}         DHCPv6=&{DHCPv6_DISABLED}
42
43${default}                0.0.0.0
44${default_ipv6addr}       ::
45${prefix_length}          ${64}
46
47
48*** Test Cases ***
49
50Verify All VMI EthernetInterfaces
51    [Documentation]  Verify all VMI ethernet interfaces.
52    [Tags]  Verify_All_VMI_EthernetInterfaces
53
54    Verify VMI EthernetInterfaces
55
56
57Verify Existing VMI Network Interface Details
58    [Documentation]  Verify existing VMI network interface details.
59    [Tags]  Verify_Existing_VMI_Network_Interface_Details
60
61    ${vmi_ip}=  Get VMI Network Interface Details
62    ${origin}=  Set Variable If  ${vmi_ip["DHCPv4"]} == ${False}  Static  DHCP
63    Should Not Be Equal  ${vmi_ip["DHCPv4"]}  ${vmi_ip["IPv4StaticAddresses"]}
64    Should Be Equal As Strings  ${vmi_ip["Id"]}  ${ethernet_interface}
65    Should Be Equal As Strings  ${vmi_ip["Description"]}
66    ...  Hypervisor's Virtual Management Ethernet Interface
67    Should Be Equal As Strings  ${vmi_ip["Name"]}  Hypervisor Ethernet Interface
68    Run Keyword If   ${vmi_ip["IPv4StaticAddresses"]} != @{empty}
69    ...  Verify VMI Network Interface Details  ${vmi_ip["IPv4_Address"]}
70    ...  ${origin}  ${vmi_ip["IPv4_Gateway"]}  ${vmi_ip["IPv4_SubnetMask"]}
71
72
73Delete Existing Static VMI IP Address
74    [Documentation]  Delete existing static VMI IP address.
75    [Tags]  Delete_Existing_Static_VMI_IP_Address
76
77    ${curr_origin}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
78    Run Keyword If  ${curr_origin} == ${True}  Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}
79
80    Delete VMI IPv4 Address
81
82
83Verify User Cannot Delete ReadOnly Property IPv4Addresses
84    [Documentation]  Verify user cannot delete readonly property IPv4Addresses.
85    [Tags]  Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses
86
87    ${curr_origin}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
88    Run Keyword If  ${curr_origin} == ${True}  Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}
89    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
90    Delete VMI IPv4 Address  IPv4Addresses  valid_status_code=${HTTP_FORBIDDEN}
91
92
93Assign Valid And Invalid Static IPv4 Address To VMI
94    [Documentation]  Assign static IPv4 address to VMI.
95    [Tags]  Assign_Valid_And_Invalid_Static_IPv4_Address_To_VMI
96    [Template]  Set Static IPv4 Address To VMI And Verify
97    [Teardown]   Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
98
99    # ip          gateway     netmask           valid_status_code
100    10.5.20.30    10.5.20.1     255.255.252.0    ${HTTP_ACCEPTED}
101    a.3.118.94    10.5.20.1     255.255.252.0    ${HTTP_BAD_REQUEST}
102    10.5.20       10.5.20.1     255.255.252.0    ${HTTP_BAD_REQUEST}
103    10.5.20.-5    10.5.20.1     255.255.252.0    ${HTTP_BAD_REQUEST}
104
105
106Add Multiple IP Addresses On VMI Interface And Verify
107    [Documentation]  Add multiple IP addresses on VMI interface and verify.
108    [Tags]  Add_Multiple_IP_Addresses_On_VMI_Interface_And_Verify
109    [Teardown]   Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
110
111    ${ip1}=  Create dictionary  Address=10.5.5.10  SubnetMask=255.255.252.0  Gateway=10.5.5.1
112    ${ip2}=  Create dictionary  Address=10.5.5.11  SubnetMask=255.255.252.0  Gateway=10.5.5.1
113    ${ip3}=  Create dictionary  Address=10.5.5.12  SubnetMask=255.255.252.0  Gateway=10.5.5.1
114    ${ips}=  Create List  ${ip1}  ${ip2}  ${ip3}
115
116    Redfish.Patch  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
117    ...  body={'IPv4StaticAddresses':${ips}}  valid_status_codes=[${HTTP_BAD_REQUEST}]
118
119
120Modify IP Addresses On VMI Interface And Verify
121    [Documentation]  Modify IP addresses on VMI interface and verify.
122    [Tags]  Modify_IP_Addresses_On_VMI_Interface_And_Verify
123    [Template]  Set Static IPv4 Address To VMI And Verify
124    [Teardown]   Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
125
126    # ip        gateway       netmask        valid_status_code
127    10.5.5.10   10.5.5.1     255.255.252.0    ${HTTP_ACCEPTED}
128    10.5.5.11   10.5.5.1     255.255.252.0    ${HTTP_ACCEPTED}
129
130
131Switch Between IP Origins On VMI And Verify Details
132    [Documentation]  Switch between IP origins on VMI and verify details.
133    [Tags]  Switch_Between_IP_Origins_On_VMI_And_Verify_Details
134
135    Switch VMI IPv4 Origin And Verify Details
136    Switch VMI IPv4 Origin And Verify Details
137
138
139Verify Persistency Of VMI IPv4 Details After Host Reboot
140    [Documentation]  Verify persistency of VMI IPv4 details after host reboot.
141    [Tags]  Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot
142
143    # Verifying persistency of dynamic address.
144    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
145    Redfish Power Off  stack_mode=skip
146    Redfish Power On
147    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
148
149    # Verifying persistency of static address.
150    Switch VMI IPv4 Origin And Verify Details
151    Redfish Power Off  stack_mode=skip
152    Redfish Power On
153    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
154
155
156Delete VMI Static IP Address And Verify
157    [Documentation]  Delete VMI static IP address and verify.
158    [Tags]  Delete_VMI_Static_IP_Address_And_Verify
159    [Teardown]  Test Teardown Execution
160
161    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
162    Delete VMI IPv4 Address
163
164
165Verify Successful VMI IP Static Configuration On HOST Boot After Session Delete
166    [Documentation]  Verify VMI IP static Configuration On HOST Boot After session deleted.
167    [Tags]  Verify_Successful_VMI_IP_Static_Configuration_On_HOST_Boot_After_Session_Delete
168    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  Test Teardown Execution
169
170    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
171
172    ${session_info}=  Get Redfish Session Info
173    Redfish.Delete  ${session_info["location"]}
174
175    # Create a new Redfish session
176    Redfish.Login
177    Redfish Power Off
178    Redfish Power On
179
180    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
181
182
183Verify Persistency Of VMI DHCP IP Configuration After Multiple HOST Reboots
184    [Documentation]  Verify Persistency Of VMI DHCP IP configuration After Multiple HOST Reboots
185    [Tags]  Verify_Persistency_Of_VMI_DHCP_IP_Configuration_After_Multiple_HOST_Reboots
186    [Teardown]  Test Teardown Execution
187
188    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
189    ${vmi_ip_config}=  Get VMI Network Interface Details
190    # Verifying persistency of dynamic address after multiple reboots.
191    FOR  ${i}  IN RANGE  ${2}
192        Redfish Power Off
193        Redfish Power On
194        Verify VMI Network Interface Details  ${vmi_ip_config["IPv4_Address"]}
195        ...  DHCP  ${vmi_ip_config["IPv4_Gateway"]}  ${vmi_ip_config["IPv4_SubnetMask"]}
196    END
197
198
199Enable DHCP When Static IP Configured And Verify Static IP
200    [Documentation]  Enable DHCP when static ip configured and verify static ip
201    [Tags]  Enable_DHCP_When_Static_IP_Configured_And_Verify_Static_IP
202    [Setup]  Redfish Power On
203    [Teardown]  Test Teardown Execution
204
205    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
206    Set VMI IPv4 Origin  ${True}
207    ${vmi_network_conf}=  Get VMI Network Interface Details
208    Should Not Be Equal As Strings  ${test_ipv4}  ${vmi_network_conf["IPv4_Address"]}
209
210
211Verify VMI Static IP Configuration Persist On BMC Reset Before Host Boot
212    [Documentation]  Verify VMI static IP configuration persist on BMC reset.
213    [Tags]   Verify_VMI_Static_IP_Configuration_Persist_On_BMC_Reset_Before_Host_Boot
214    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  FFDC On Test Case Fail
215
216    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
217    Redfish OBMC Reboot (off)  stack_mode=skip
218    Redfish Power On
219    # Verifying the VMI static configuration
220    Verify VMI Network Interface Details  ${test_ipv4}  Static   ${test_gateway}  ${test_netmask}
221
222
223Add Static IP When Host Poweroff And Verify On Poweron
224    [Documentation]  Add Static IP When Host Poweroff And Verify on power on
225    [Tags]   Add_Static_IP_When_Host_Poweroff_And_Verify_On_Poweron
226    [Setup]  Redfish Power Off
227    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  FFDC On Test Case Fail
228
229    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
230    Redfish Power On
231    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
232
233
234Add VMI Static IP When Host Poweroff And Verify Static IP On BMC Reset
235    [Documentation]  Add Static IP When Host Poweroff And Verify Static IP On BMC Reset.
236    [Tags]  Add_VMI_Static_IP_When_Host_Poweroff_And_Verify_Static_IP_On_BMC_Reset
237    [Setup]  Redfish Power Off
238    [Teardown]  Run keywords  Delete VMI IPv4 Address  AND  FFDC On Test Case Fail
239
240    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
241    Redfish OBMC Reboot (off)  stack_mode=skip
242    Redfish Power On
243    Verify VMI Network Interface Details  ${test_ipv4}  Static  ${test_gateway}  ${test_netmask}
244
245
246Enable DHCP When No Static IP Configured And Verify DHCP IP
247    [Documentation]  Enable DHCP when no static ip configured and verify dhcp ip
248    [Tags]  Enable_DHCP_When_No_Static_IP_Configured_And_Verify_DHCP_IP
249    [Setup]  Run Keyword And Ignore Error  Delete VMI IPv4 Address
250    [Teardown]  Test Teardown Execution
251
252    ${curr_origin}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
253    Run Keyword If  ${curr_origin} == ${False}  Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}
254    ${vmi_ip_config}=  Get VMI Network Interface Details
255    Verify VMI Network Interface Details  ${vmi_ip_config["IPv4_Address"]}
256    ...  DHCP  ${vmi_ip_config["IPv4_Gateway"]}  ${vmi_ip_config["IPv4_SubnetMask"]}
257
258
259Verify User Cannot Delete VMI DHCP IP Address
260    [Documentation]  Verify user cannot delete VMI DHCP IP Address
261    [Tags]  Verify_User_Cannot_Delete_VMI_DHCP_IP_Address
262    [Setup]  Set VMI IPv4 Origin  ${True}
263    [Teardown]  Test Teardown Execution
264
265    Delete VMI IPv4 Address  IPv4Addresses  valid_status_code=${HTTP_FORBIDDEN}
266    ${resp}=  Redfish.Get
267    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
268    Should Not Be Empty  ${resp.dict["IPv4Addresses"]}
269
270
271Enable DHCP When Static IP Configured DHCP Server Unavailable And Verify IP
272    [Documentation]  Enable DHCP When Static IP Configured And DHCP Server Unavailable And Verify No IP.
273    [Tags]  Enable_DHCP_When_Static_IP_Configured_DHCP_Server_Unavailable_And_Verify_IP
274    [Teardown]  Test Teardown Execution
275
276    Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}  ${test_netmask}
277    Set VMI IPv4 Origin  ${True}
278    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
279
280
281Verify To Configure VMI Static IP Address With Different User Roles
282    [Documentation]  Verify to configure vmi static ip address with different user roles.
283    [Tags]  Verify_To_Configure_VMI_Static_IP_Address_With_Different_User_Roles
284    [Setup]  Run Keywords  Delete BMC Users Using Redfish
285    ...  AND  Create Users With Different Roles  users=${USERS}  force=${True}
286    [Template]  Config VMI Static IP Address Using Different Users
287    [Teardown]  Delete BMC Users Using Redfish
288
289    # username     password    ip_address    gateway          nemask           valid_status_code
290    admin_user     TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_ACCEPTED}
291    readonly_user  TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_FORBIDDEN}
292
293
294Verify To Configure VMI Static IP Address With Operator User Role
295    [Documentation]  Verify to configure vmi static ip address with operator user role.
296    [Tags]  Verify_To_Configure_VMI_Static_IP_Address_With_Operator_User_Role
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          nemask           valid_status_code
302    operator_user  TestPwd123  ${test_ipv4}  ${test_gateway}  ${test_netmask}  ${HTTP_FORBIDDEN}
303
304
305Verify To Delete VMI Static IP Address With Different User Roles
306    [Documentation]  Verify to delete vmi static IP address with different user roles.
307    [Tags]  Verify_To_Delete_VMI_Static_IP_Address_With_Different_User_Roles
308    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
309    [Template]  Delete VMI Static IP Address Using Different Users
310    [Teardown]  Delete BMC Users Using Redfish
311
312    # username     password     valid_status_code
313    admin_user     TestPwd123   ${HTTP_ACCEPTED}
314    readonly_user  TestPwd123   ${HTTP_FORBIDDEN}
315
316
317Verify To Delete VMI Static IP Address With Operator User Role
318    [Documentation]  Verify to delete vmi static IP address with operator user role.
319    [Tags]  Verify_To_Delete_VMI_Static_IP_Address_With_Operator_User_Role
320    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
321    [Template]  Delete VMI Static IP Address Using Different Users
322    [Teardown]  Delete BMC Users Using Redfish
323
324    # username     password     valid_status_code
325    operator_user     TestPwd123   ${HTTP_FORBIDDEN}
326
327
328Verify To Update VMI Static IP Address With Different User Roles
329    [Documentation]  Verify to update vmi static IP address with different user roles.
330    [Tags]  Verify_To_Update_VMI_Static_IP_Address_With_Different_User_Roles
331    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
332    [Template]  Config VMI Static IP Address Using Different Users
333    [Teardown]  Delete BMC Users Using Redfish
334
335    # username     password     ip_address  gateway    netmask       valid_status_code
336    admin_user     TestPwd123   10.5.10.20  10.5.10.1  255.255.0.0  ${HTTP_ACCEPTED}
337    readonly_user  TestPwd123   10.5.20.40  10.5.20.1  255.255.0.0  ${HTTP_FORBIDDEN}
338
339
340Verify To Update VMI Static IP Address With Operator User Role
341    [Documentation]  Verify to update vmi static IP address with operator user role.
342    [Tags]  Verify_To_Update_VMI_Static_IP_Address_With_Operator_User_Role
343    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
344    [Template]  Config VMI Static IP Address Using Different Users
345    [Teardown]  Delete BMC Users Using Redfish
346
347    # username     password     ip_address  gateway    netmask       valid_status_code
348    operator_user  TestPwd123   10.5.10.30  10.5.10.1  255.255.0.0  ${HTTP_FORBIDDEN}
349
350
351Verify To Read VMI Network Configuration With Different User Roles
352    [Documentation]  Verify to read vmi network configuration with different user roles.
353    [Tags]  Verify_To_Read_VMI_Network_Configuration_With_Different_User_Roles
354    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
355    [Template]  Read VMI Static IP Address Using Different Users
356    [Teardown]  Delete BMC Users Using Redfish
357
358    # username     password     valid_status_code
359    admin_user     TestPwd123   ${HTTP_OK}
360    readonly_user  TestPwd123   ${HTTP_OK}
361
362
363Verify To Read VMI Network Configuration With Operator User Role
364    [Documentation]  Verify to read vmi network configuration with operator user role.
365    [Tags]  Verify_To_Read_VMI_Network_Configuration_With_Operator_User_Role
366    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
367    [Template]  Read VMI Static IP Address Using Different Users
368    [Teardown]  Delete BMC Users Using Redfish
369
370    # username     password     valid_status_code
371    operator_user  TestPwd123   ${HTTP_FORBIDDEN}
372
373
374Enable DHCP On VMI Network Via Different Users Roles And Verify
375    [Documentation]  Enable DHCP On VMI Network Via Different Users Roles And Verify.
376    [Tags]  Enable_DHCP_On_VMI_Network_Via_Different_Users_Roles_And_Verify
377    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
378    [Template]  Update User Role And Set VMI IPv4 Origin
379    [Teardown]  Delete BMC Users Using Redfish
380
381    # username     password     dhcp_enabled   valid_status_code
382    admin_user     TestPwd123   ${True}        ${HTTP_ACCEPTED}
383    readonly_user  TestPwd123   ${True}        ${HTTP_FORBIDDEN}
384
385
386Enable DHCP On VMI Network Via Operator User Role And Verify
387    [Documentation]  Enable DHCP On VMI Network Via Operator User Role And Verify.
388    [Tags]  Enable_DHCP_On_VMI_Network_Via_Operator_User_Role_And_Verify
389    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
390    [Template]  Update User Role And Set VMI IPv4 Origin
391    [Teardown]  Delete BMC Users Using Redfish
392
393    # username     password     dhcp_enabled   valid_status_code
394    operator_user  TestPwd123   ${True}        ${HTTP_FORBIDDEN}
395
396
397Disable DHCP On VMI Network Via Different Users Roles And Verify
398    [Documentation]  Disable DHCP On VMI Network Via Different Users Roles And Verify.
399    [Tags]  Disable_DHCP_On_VMI_Network_Via_Different_Users_Roles_And_Verify
400    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
401    [Template]  Update User Role And Set VMI IPv4 Origin
402    [Teardown]  Delete BMC Users Using Redfish
403
404    # username     password     dhcp_enabled    valid_status_code
405    admin_user     TestPwd123   ${False}        ${HTTP_ACCEPTED}
406    readonly_user  TestPwd123   ${False}        ${HTTP_FORBIDDEN}
407
408
409Disable DHCP On VMI Network Via Operator User Role And Verify
410    [Documentation]  Disable DHCP On VMI Network Via Operator User Role And Verify.
411    [Tags]  Disable_DHCP_On_VMI_Network_Via_Operator_User_Role_And_Verify
412    [Setup]  Create Users With Different Roles  users=${USERS}  force=${True}
413    [Template]  Update User Role And Set VMI IPv4 Origin
414    [Teardown]  Delete BMC Users Using Redfish
415
416    # username     password     dhcp_enabled    valid_status_code
417    operator_user  TestPwd123   ${False}        ${HTTP_FORBIDDEN}
418
419
420Enable And Disable DHCP And Verify
421    [Documentation]  verify enable DHCP and disable DHCP.
422    [Tags]  Enable_And_Disable_DHCP_And_Verify
423
424    Set VMI IPv4 Origin  ${True}
425    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
426    Set VMI IPv4 Origin  ${False}
427    Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
428
429
430Multiple Times Enable And Disable DHCP And Verify
431    [Documentation]  Enable and Disable DHCP in a loop and verify VMI gets an IP address from DHCP
432    ...  each time when DHCP is enabled
433    [Tags]  Multiple_Times_Enable_And_Disable_DHCP_And_Verify
434
435    FOR  ${i}  IN RANGE  ${2}
436      Set VMI IPv4 Origin  ${True}
437      Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
438      Set VMI IPv4 Origin  ${False}
439      Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
440    END
441
442
443Assign Static IPv4 Address With Invalid Netmask To VMI
444    [Documentation]  Assign static IPv4 address with invalid netmask and expect error.
445    [Tags]  Assign_Static_IPv4_Address_With_Invalid_Netmask_To_VMI
446    [Template]  Set Static IPv4 Address To VMI And Verify
447
448    # ip          gateway          netmask         valid_status_code
449    ${test_ipv4}  ${test_gateway}  255.256.255.0   ${HTTP_BAD_REQUEST}
450    ${test_ipv4}  ${test_gateway}  ff.ff.ff.ff     ${HTTP_BAD_REQUEST}
451    ${test_ipv4}  ${test_gateway}  255.255.253.0   ${HTTP_BAD_REQUEST}
452
453
454Assign Static IPv4 Address With Invalid Gateway To VMI
455    [Documentation]  Add static IPv4 address with invalid gateway and expect error.
456    [Tags]  Assign_Static_IPv4_Address_With_Invalid_Gateway_To_VMI
457    [Template]  Set Static IPv4 Address To VMI And Verify
458
459    # ip          gateway          netmask           valid_status_code
460    ${test_ipv4}  @@@.%%.44.11     ${test_netmask}   ${HTTP_BAD_REQUEST}
461    ${test_ipv4}  0xa.0xb.0xc.0xd  ${test_netmask}   ${HTTP_BAD_REQUEST}
462    ${test_ipv4}  10.3.36          ${test_netmask}   ${HTTP_BAD_REQUEST}
463    ${test_ipv4}  10.3.36.-10      ${test_netmask}   ${HTTP_BAD_REQUEST}
464
465
466Enable DHCP When Host Is Off And Verify After Poweron
467    [Documentation]  Enable DHCP when host is off and
468    ...  check whether it is enabled after poweron.
469    [Tags]  Enable_DHCP_When_Host_Is_Off_And_Verify_After_Poweron
470    [Setup]  Redfish Power Off  stack_mode=skip
471
472    Set VMI IPv4 Origin  ${True}
473    Redfish Power On  stack_mode=skip
474    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
475
476
477Disable DHCP When Host Is Off And Verify New State Reflects After Power On
478    [Documentation]  Disable DHCP when host is off and
479    ...  get network info and verify that VMI origin is static.
480    [Tags]  Disable_DHCP_When_Host_Is_Off_And_Verify_New_State_Reflects_After_Power_On
481    [Setup]  Redfish Power Off  stack_mode=skip
482
483    Set VMI IPv4 Origin  ${False}
484    Redfish Power On  stack_mode=skip
485    Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
486
487
488Enable VMI Stateless Address AutoConfig And Verify
489    [Documentation]  Enable VMI SLAACv6 and verify an origin.
490    [Tags]  Enable_VMI_Stateless_Address_AutoConfig_And_Verify
491
492    Set VMI SLAACv6 Origin    ${True}
493
494    # Check origin is set to slaac and address are getting displayed.
495    Verify VMI IPv6 Address  SLAAC
496
497
498Disable VMI Stateless Address AutoConfig And Verify
499    [Documentation]  Disable VMI SLAACv6 and verify an origin.
500    [Tags]  Disable_VMI_Stateless_Address_AutoConfig_And_Verify
501    [Setup]  Set VMI SLAACv6 Origin    ${True}
502
503    Set VMI SLAACv6 Origin    ${False}
504
505    # Check origin is set to static and slaacv6 address are getting erased.
506    Verify VMI IPv6 Address  Static
507
508
509Enable VMI SLAAC And Check Persistency On BMC Reboot
510    [Documentation]  Enable VMI SLAACv6 and verify its persistency
511    ...  on BMC reboot and this works on the setup where router
512    ...  advertise network prefix.
513    [Tags]  Enable_VMI_SLAAC_And_Check_Persistency_On_BMC_Reboot
514
515    Set VMI SLAACv6 Origin    ${True}
516
517    # Reboot BMC and verify persistency.
518    OBMC Reboot (off)
519    Redfish Power On
520    Wait For Host Boot Progress To Reach Required State
521
522    # Check origin is set to slaac and address are getting displayed.
523    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  SLAAC
524    Should Not Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
525
526
527Disable VMI SLAAC And Check Persistency On BMC Reboot
528    [Documentation]  Disable VMI SLAACv6 and verify its persistency
529    ...  on BMC reboot.
530    [Tags]  Disable_VMI_SLAAC_And_Check_Persistency_On_BMC_Reboot
531
532    Set VMI SLAACv6 Origin    ${False}
533
534    # Reboot BMC and verify persistency.
535    OBMC Reboot (off)
536    Redfish Power On
537    Wait For Host Boot Progress To Reach Required State
538
539    # Check if origin is set to static and SLAAC address are getting erased.
540    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
541    Should Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
542
543
544Disable VMI DHCPv4 When SLAAC Is Enabled And Verify
545    [Documentation]  Disable VMI DHCPv4 parameter when SLAACv6 is enabled
546    ...  and check whether the IPv4 address origin is set to static and
547    ...  DHCPv4 address is getting erased.
548    [Tags]  Disable_VMI_DHCPv4_When_SLAAC_Is_Enabled_And_Verify
549    [Setup]  Set VMI IPv4 Origin  ${True}
550
551    # Set IPv6 origin to SLAAC.
552    Set VMI SLAACv6 Origin    ${True}
553    Verify VMI IPv6 Address  SLAAC
554
555    # Disable VMI DHCPv4 and check IPv4 address origin is set to static.
556    Set VMI IPv4 Origin  ${False}
557    Verify VMI Network Interface Details  ${default}  Static  ${default}  ${default}
558
559
560Enable VMI SLAAC When DHCPv6 Is Enabled And Verify
561    [Documentation]  Enable VMI SLAACv6 when VMI DHCPv6 is enabled and
562    ...  check IPv6 gets Slaac address and this works on the setup
563    ...  where router advertise network prefix.
564    [Tags]  Enable_VMI_SLAAC_When_DHCPv6_Is_Enabled_And_Verify
565
566    Set VMI DHCPv6 Property  Enabled
567
568    # Enable SLAAC and check whether IPv6 origin is set to SLAAC.
569    Set VMI SLAACv6 Origin    ${True}
570
571    # Check if origin is set to slaac and address are getting displayed.
572    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  SLAAC
573    Should Not Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
574    Should Be Equal  ${vmi_ipv6addr["PrefixLength"]}  ${prefix_length}
575
576
577Disable VMI DHCPv6 Property And Verify
578    [Documentation]  Disable VMI DHCPv6 property and verify IPv6 address
579    ...              origin is set to static and DHCPv6 address is erased.
580    [Tags]  Disable_VMI_DHCPv6_Property_And_Verify
581    [Setup]  Set VMI DHCPv6 Property  Enabled
582
583    Set VMI DHCPv6 Property  Disabled
584
585    # Verify IPv6 address origin is set to static and DHCPv6 address is erased.
586    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
587    Should Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
588
589
590Enable VMI SLAAC When DHCPv4 Is Enabled And Verify
591    [Documentation]  On VMI enable SLAAC when DHCPv4 is enabled and verify DHCPv4 settings are intact
592    ...  and IPv6 origin is set to SLAAC & it gets assigned with SLAAC IPv6 address and this
593    ...  works on the setup where router advertise network prefix.
594    [Tags]  Enable_VMI_SLAAC_When_DHCPv4_Is_Enabled_And_Verify
595    [Setup]  Set VMI IPv4 Origin  ${True}
596
597    # Enable Autoconfig address and check whether IPv6 address origin is set to SLAAC.
598    Set VMI SLAACv6 Origin  ${True}
599    Verify VMI IPv6 Address  SLAAC
600
601    # Check there is no impact on IPv4 settings, IPv4 address origin should be DHCP.
602    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
603
604
605Disable VMI DHCPv6 Property And Check Persistency On BMC Reboot
606    [Documentation]  Disable VMI DHCPv6 property and verify its persistency on
607    ...  BMC reboot.
608    [Tags]  Disable_VMI_DHCPv6_Property_And_Check_Persistency_On_BMC_Reboot
609    [Setup]  Set VMI DHCPv6 Property  Enabled
610
611    Set VMI DHCPv6 Property  Disabled
612
613    # Reboot BMC and verify persistency.
614    OBMC Reboot (off)
615
616    # Verify IPv6 address origin is set to Static and DHCPv6 address is erased.
617    ${vmi_ipv6addr}=  Verify VMI IPv6 Address  Static
618    Should Be Equal  ${vmi_ipv6addr["Address"]}  ${default_ipv6addr}
619
620
621*** Keywords ***
622
623Suite Setup Execution
624    [Documentation]  Do test setup execution task.
625
626    Redfish.Login
627
628    Redfish Power Off
629    Set BIOS Attribute  pvm_hmc_managed  Enabled
630    Set BIOS Attribute  pvm_stop_at_standby  Disabled
631
632    Redfish Power On
633    Wait For Host Boot Progress To Reach Required State
634
635    ${active_channel_config}=  Get Active Channel Config
636    Set Suite Variable   ${active_channel_config}
637    Set Suite Variable  ${ethernet_interface}  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
638    ${resp}=  Redfish.Get
639    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
640    ${ip_resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
641    ${length}=  Get Length  ${ip_resp["IPv4StaticAddresses"]}
642    ${vmi_network_conf}=  Run Keyword If  ${length} != ${0}  Get VMI Network Interface Details
643    Set Suite Variable  ${vmi_network_conf}
644
645
646Test Teardown Execution
647    [Documentation]  Do test teardown execution task.
648
649    FFDC On Test Case Fail
650    ${curr_mode}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
651    Run Keyword If  ${curr_mode} == ${True}  Set VMI IPv4 Origin  ${False}
652    Run Keyword If  '${vmi_network_conf["IPv4_Address"]}' != '${default}'
653    ...  Set Static IPv4 Address To VMI And Verify  ${vmi_network_conf["IPv4_Address"]}
654    ...  ${vmi_network_conf["IPv4_Gateway"]}  ${vmi_network_conf["IPv4_SubnetMask"]}
655
656
657Get Immediate Child Parameter From VMI Network Interface
658    [Documentation]  Get immediate child parameter from VMI network interface.
659    [Arguments]  ${parameter}  ${valid_status_code}=${HTTP_OK}
660
661    # Description of argument(s):
662    # parameter          parameter for which value is required. Ex: DHCPEnabled, MACAddress etc.
663    # valid_status_code  Expected valid status code from GET request.
664
665    ${resp}=  Redfish.Get
666    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
667    ...  valid_status_codes=[${valid_status_code}]
668
669    ${ip_resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
670    ${value}=  Set Variable If  '${parameter}' != 'DHCPEnabled'   ${ip_resp["${parameter}"]}
671    ...  ${ip_resp["DHCPv4"]["${parameter}"]}
672
673    RETURN  ${value}
674
675
676Switch VMI IPv4 Origin And Verify Details
677    [Documentation]  Switch VMI IPv4 origin and verify details.
678
679    ${dhcp_mode_before}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
680    ${dhcp_enabled}=  Set Variable If  ${dhcp_mode_before} == ${False}  ${True}  ${False}
681
682    ${origin}=  Set Variable If  ${dhcp_mode_before} == ${False}  DHCP  Static
683    Set VMI IPv4 Origin  ${dhcp_enabled}  ${HTTP_ACCEPTED}
684
685    ${dhcp_mode_after}=  Get Immediate Child Parameter From VMI Network Interface  DHCPEnabled
686    Should Not Be Equal  ${dhcp_mode_before}  ${dhcp_mode_after}
687
688    Run Keyword If  ${dhcp_mode_after} == ${True}
689    ...  Verify VMI Network Interface Details  ${default}  ${origin}  ${default}  ${default}
690
691
692Delete VMI Static IP Address Using Different Users
693    [Documentation]  Update user role and delete vmi static IP address.
694    [Arguments]  ${username}  ${password}  ${valid_status_code}
695    [Teardown]  Run Keywords  Redfish.Login  AND
696    ...  Set Static IPv4 Address To VMI And Verify  ${test_ipv4}  ${test_gateway}
697    ...  ${test_netmask}  ${HTTP_ACCEPTED}  AND  Redfish.Logout
698
699    # Description of argument(s):
700    # username            The host username.
701    # password            The host password.
702    # valid_status_code   The expected valid status code.
703
704    # TODO: operator_user role is not yet supported.
705    Skip If  '${username}' == 'operator_user'
706    Redfish.Login  ${username}  ${password}
707    Delete VMI IPv4 Address  delete_param=IPv4StaticAddresses  valid_status_code=${valid_status_code}
708
709
710Config VMI Static IP Address Using Different Users
711   [Documentation]  Update user role and update vmi static ip address.
712   [Arguments]  ${username}  ${password}  ${ip}  ${gateway}  ${netmask}
713   ...  ${valid_status_code}
714
715    # Description of argument(s):
716    # username            The host username.
717    # password            The host password.
718    # ip                  IP address to be added (e.g. "10.7.7.7").
719    # subnet_mask         Subnet mask for the IP to be added
720    #                     (e.g. "255.255.0.0").
721    # gateway             Gateway for the IP to be added (e.g. "10.7.7.1").
722    # valid_status_code   The expected valid status code.
723
724    # TODO: operator_user role is not yet supported.
725    Skip If  '${username}' == 'operator_user'
726    Redfish.Login  ${username}  ${password}
727    Set Static IPv4 Address To VMI And Verify  ${ip}  ${gateway}  ${netmask}  ${valid_status_code}
728
729
730Read VMI Static IP Address Using Different Users
731   [Documentation]  Update user role and read vmi static ip address.
732   [Arguments]  ${username}  ${password}  ${valid_status_code}
733
734    # Description of argument(s):
735    # username            The host username.
736    # password            The host password.
737    # valid_status_code   The expected valid status code.
738
739    # TODO: operator_user role is not yet supported.
740    Skip If  '${username}' == 'operator_user'
741    Redfish.Login  ${username}  ${password}
742    Redfish.Get
743    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${ethernet_interface}
744    ...  valid_status_codes=[${valid_status_code}]
745
746
747Delete BMC Users Using Redfish
748   [Documentation]  Delete BMC users via redfish.
749
750   Redfish.Login
751   Delete BMC Users Via Redfish  users=${USERS}
752
753
754Update User Role And Set VMI IPv4 Origin
755    [Documentation]  Update User Role And Set VMI IPv4 Origin.
756    [Arguments]  ${username}  ${password}  ${dhcp_enabled}  ${valid_status_code}
757
758    # Description of argument(s):
759    # username            The host username.
760    # password            The host password.
761    # dhcp_enabled        Indicates whether dhcp should be enabled
762    #                     (${True}, ${False}).
763    # valid_status_code   The expected valid status code.
764
765    # TODO: operator_user role is not yet supported.
766    Skip If  '${username}' == 'operator_user'
767    Redfish.Login  ${username}  ${password}
768    Set VMI IPv4 Origin  ${dhcp_enabled}  ${valid_status_code}
769
770
771Suite Teardown Execution
772    [Documentation]  Do suite teardown execution task.
773
774    Run Keyword If  ${vmi_network_conf} != ${None}
775    ...  Set Static IPv4 Address To VMI And Verify  ${vmi_network_conf["IPv4_Address"]}
776    ...  ${vmi_network_conf["IPv4_Gateway"]}  ${vmi_network_conf["IPv4_SubnetMask"]}
777    Delete All Redfish Sessions
778    Redfish.Logout
779
780
781Set VMI SLAACv6 Origin
782    [Documentation]  Set VMI SLAACv6 origin.
783    [Arguments]  ${slaac_enabled}=${False}  ${valid_status_code}=${HTTP_ACCEPTED}
784    ...  ${interface}=${ethernet_interface}
785
786    # Description of argument(s):
787    # slaacv6_enabled    True if user wants to enable SLAACv6. Default is Static, hence value is set to False.
788    # valid_status_code  Expected valid status code from PATCH request. Default is HTTP_OK.
789    # interface          VMI interface (eg. eth0 or eth1).
790
791    ${data}=  Set Variable If  ${slaac_enabled} == ${False}  ${DISABLE_SLAAC}  ${ENABLE_SLAAC}
792    ${resp}=  Redfish.Patch
793    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
794    ...  body=${data}  valid_status_codes=[${valid_status_code}]
795
796    Sleep  ${wait_time}
797    Return From Keyword If  ${valid_status_code} != ${HTTP_ACCEPTED}
798    ${resp}=  Redfish.Get
799    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
800    Should Be Equal  ${resp.dict["StatelessAddressAutoConfig"]["IPv6AutoConfigEnabled"]}  ${slaac_enabled}
801
802
803Verify VMI IPv6 Address
804    [Documentation]  Verify VMI IPv6 address configurations.
805    [Arguments]  ${ipv6_origin}  ${interface}=${ethernet_interface}
806
807    # Description of argument(s):
808    # ipv6_origin     Origin of IPv6 address eg. Static or DHCPv6 or SLAAC.
809    # interface       VMI interface (eg. eth0 or eth1).
810
811    ${resp}=  Redfish.Get  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
812
813    @{vmi_ipv6_configurations}=  Get From Dictionary  ${resp.dict}  IPv6Addresses
814    ${vmi_ipv6_config}=  Get From List  ${vmi_ipv6_configurations}  0
815    Should Not Be Empty  ${vmi_ipv6_config["Address"]}
816    Should Be Equal As Strings   ${vmi_ipv6_config["AddressOrigin"]}  ${ipv6_origin}
817    RETURN  &{vmi_ipv6_config}
818
819
820Set VMI DHCPv6 Property
821    [Documentation]  Set VMI DHCPv6 attribute.
822    [Arguments]  ${dhcpv6_operatingmode}=${Disabled}  ${valid_status_code}=${HTTP_ACCEPTED}
823    ...  ${interface}=${ethernet_interface}
824
825    # Description of argument(s):
826    # dhcpv6_operatingmode    Enabled if user wants to enable DHCPv6.
827    # ...                     Default is Static, hence value is set to Disabled.
828    # valid_status_code       Expected valid status code from PATCH request. Default is HTTP_OK.
829    # interface               VMI interface (eg. eth0 or eth1).
830
831    ${data}=  Set Variable If  '${dhcpv6_operatingmode}' == 'Disabled'  ${DISABLE_DHCPv6}  ${ENABLE_DHCPv6}
832    ${resp}=  Redfish.Patch
833    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
834    ...  body=${data}  valid_status_codes=[${valid_status_code}]
835
836    Sleep  ${wait_time}
837    Return From Keyword If  ${valid_status_code} != ${HTTP_ACCEPTED}
838    ${resp}=  Redfish.Get
839    ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
840    Should Be Equal  ${resp.dict["DHCPv6"]["OperatingMode"]}  ${dhcpv6_operatingmode}
841