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