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