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