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