blob: 197cf05a783f63b173d3938cc41ea0015309715a [file] [log] [blame]
Vijay06a169d2020-04-23 09:28:24 -05001*** Settings ***
2
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -05003Documentation VMI static/dynamic IP config tests.
Vijay06a169d2020-04-23 09:28:24 -05004
5Resource ../../lib/resource.robot
6Resource ../../lib/bmc_redfish_resource.robot
7Resource ../../lib/openbmc_ffdc.robot
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -05008Resource ../../lib/bmc_redfish_utils.robot
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -05009Library ../../lib/bmc_network_utils.py
Vijay06a169d2020-04-23 09:28:24 -050010
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -050011Suite Setup Suite Setup Execution
Vijay06a169d2020-04-23 09:28:24 -050012Test Teardown FFDC On Test Case Fail
13Suite Teardown Redfish.Logout
14
15*** Variables ***
16
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -050017# users User Name password
18@{ADMIN} admin_user TestPwd123
19@{OPERATOR} operator_user TestPwd123
20@{ReadOnly} readonly_user TestPwd123
21@{NoAccess} noaccess_user TestPwd123
22&{USERS} Administrator=${ADMIN} Operator=${OPERATOR} ReadOnly=${ReadOnly}
23... NoAccess=${NoAccess}
24
Prashanth Katti1ce68212020-11-13 00:39:03 -060025${test_ipv4} 10.6.6.6
26${test_gateway} 10.6.6.1
shrsuman123c1d3fe32020-09-08 05:04:07 -050027${test_netmask} 255.255.252.0
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -050028
Vijay06a169d2020-04-23 09:28:24 -050029&{DHCP_ENABLED} DHCPEnabled=${${True}}
30&{DHCP_DISABLED} DHCPEnabled=${${False}}
31
32&{ENABLE_DHCP} DHCPv4=&{DHCP_ENABLED}
33&{DISABLE_DHCP} DHCPv4=&{DHCP_DISABLED}
Prashanth Katti1ce68212020-11-13 00:39:03 -060034${wait_time} 10s
Vijay06a169d2020-04-23 09:28:24 -050035
36
37*** Test Cases ***
38
39Verify All VMI EthernetInterfaces
40 [Documentation] Verify all VMI ethernet interfaces.
41 [Tags] Verify_All_VMI_EthernetINterfaces
42
43 Verify VMI EthernetInterfaces
44
45
46Verify Existing VMI Network Interface Details
47 [Documentation] Verify existing VMI network interface details.
48 [Tags] Verify_VMI_Network_Interface_Details
49
50 ${vmi_ip}= Get VMI Network Interface Details
51 ${origin}= Set Variable If ${vmi_ip["DHCPv4"]} == ${False} Static DHCP
52
53 Should Not Be Equal ${vmi_ip["DHCPv4"]} ${vmi_ip["IPv4StaticAddresses"]}
54 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]}
55 Should Be Equal As Strings ${vmi_ip["Id"]} intf0
George Keishingb3ea0952020-07-01 05:03:56 -050056 Should Be Equal As Strings ${vmi_ip["Description"]}
57 ... Ethernet Interface for Virtual Management Interface
58 Should Be Equal As Strings ${vmi_ip["Name"]} Virtual Management Interface
Vijay06a169d2020-04-23 09:28:24 -050059 Should Be True ${vmi_ip["InterfaceEnabled"]}
60
61
62Delete Existing Static VMI IP Address
63 [Documentation] Delete existing static VMI IP address.
64 [Tags] Delete_Existing_Static_VMI_IP_Address
65
66 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
67 Run Keyword If ${curr_origin} == ${True} Set VMI IPv4 Origin ${False} ${HTTP_ACCEPTED}
68
69 Delete VMI IPv4 Address IPv4StaticAddresses valid_status_code=${HTTP_ACCEPTED}
70 ${default}= Set Variable 0.0.0.0
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -050071 Verify VMI Network Interface Details ${default} Static ${default} ${default}
Vijay06a169d2020-04-23 09:28:24 -050072
73
74Verify User Cannot Delete ReadOnly Property IPv4Addresses
75 [Documentation] Verify user cannot delete readonly property IPv4Addresses.
76 [Tags] Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses
77
78 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
79 Run Keyword If ${curr_origin} == ${False} Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
80 Delete VMI IPv4 Address IPv4Addresses valid_status_code=${HTTP_BAD_REQUEST}
81
82
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -050083Assign Valid And Invalid Static IPv4 Address To VMI
Vijay06a169d2020-04-23 09:28:24 -050084 [Documentation] Assign static IPv4 address to VMI.
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -050085 [Tags] Assign_Valid_And_Invalid_Static_IPv4_Address_To_VMI
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -060086 [Template] Set Static IPv4 Address To VMI And Verify
87 [Teardown] Run keywords Delete VMI IPv4 Address AND Test Teardown Execution
Vijay06a169d2020-04-23 09:28:24 -050088
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -050089 # ip gateway netmask valid_status_code
90 10.5.20.30 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED}
91 a.3.118.94 0.0.0.0 255.255.252.0 ${HTTP_BAD_REQUEST}
92
Vijay06a169d2020-04-23 09:28:24 -050093
shrsuman123e37b0cc2020-09-02 00:33:42 -050094Add Multiple IP Addreses On VMI Interface And Verify
95 [Documentation] Add multiple IP addreses on VMI interface and verify.
96 [Tags] Add_Multiple_IP_Addreses_On_VMI_Interface_And_Verify
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -060097 [Teardown] Run keywords Delete VMI IPv4 Address AND Test Teardown Execution
shrsuman123e37b0cc2020-09-02 00:33:42 -050098
99 ${ip1}= Create dictionary Address=10.5.5.10 SubnetMask=255.255.252.0 Gateway=0.0.0.0
100 ${ip2}= Create dictionary Address=10.5.5.11 SubnetMask=255.255.252.0 Gateway=0.0.0.0
101 ${ip3}= Create dictionary Address=10.5.5.12 SubnetMask=255.255.252.0 Gateway=0.0.0.0
102 ${ips}= Create List ${ip1} ${ip2} ${ip3}
103
shrsuman123e37b0cc2020-09-02 00:33:42 -0500104 Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
105 ... body={'IPv4StaticAddresses':${ips}} valid_status_codes=[${HTTP_ACCEPTED}]
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500106 Verify VMI Network Interface Details ${ip1["Address"]} Static ${ip1["Gateway"]} ${ip1["SubnetMask"]}
shrsuman123e37b0cc2020-09-02 00:33:42 -0500107
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500108
shrsuman123e37b0cc2020-09-02 00:33:42 -0500109Modify IP Addresses On VMI Interface And Verify
110 [Documentation] Modify IP addresses on VMI interface and verify.
111 [Tags] Modify_IP_Addresses_On_VMI_Interface_And_Verify
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600112 [Template] Set Static IPv4 Address To VMI And Verify
113 [Teardown] Run keywords Delete VMI IPv4 Address AND Test Teardown Execution
shrsuman123e37b0cc2020-09-02 00:33:42 -0500114
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500115 # ip gateway netmask valid_status_code
116 10.5.5.10 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED}
117 10.5.5.11 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED}
Vijay06a169d2020-04-23 09:28:24 -0500118
119Switch Between IP Origins On VMI And Verify Details
120 [Documentation] Switch between IP origins on VMI and verify details.
121 [Tags] Switch_Between_IP_Origins_On_VMI_And_Verify_Details
122
123 Switch VMI IPv4 Origin And Verify Details
124 Switch VMI IPv4 Origin And Verify Details
125
126
127Verify Persistency Of VMI IPv4 Details After Host Reboot
128 [Documentation] Verify persistency of VMI IPv4 details after host reboot.
129 [Tags] Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot
130
131 # Verifying persistency of dynamic address.
132 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
133 ${default}= Set Variable 0.0.0.0
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500134 Verify VMI Network Interface Details ${default} DHCP ${default} ${default}
Vijay06a169d2020-04-23 09:28:24 -0500135
136 # Verifying persistency of static address.
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600137 Switch VMI IPv4 Origin And Verify Details
138 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask}
Vijay06a169d2020-04-23 09:28:24 -0500139
140
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500141Delete VMI Static IP Address And Verify
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500142 [Documentation] Delete VMI static IP address and verify.
143 [Tags] Delete_VMI_Static_IP_Address_And_Verify
144 [Teardown] Test Teardown Execution
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500145
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600146 Set Static IPv4 Address To VMI And Verify ${test_ipv4} ${test_gateway} ${test_netmask}
147 Delete VMI IPv4 Address
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500148 ${resp}= Redfish.Get
149 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
150 Should Be Empty ${resp.dict["IPv4Addresses"]}
151
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500152
shrsuman123c1d3fe32020-09-08 05:04:07 -0500153Verify Successful VMI IP Static Configuration On HOST Boot After Session Delete
154 [Documentation] Verify VMI IP static Configuration On HOST Boot After session deleted.
155 [Tags] Verify_Successful_VMI_IP_Static_Configuration_On_HOST_Boot_After_Session_Delete
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500156 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses AND Test Teardown Execution
shrsuman123c1d3fe32020-09-08 05:04:07 -0500157
158 Set Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
159
160 ${session_info}= Get Redfish Session Info
161 Redfish.Delete ${session_info["location"]}
162
163 # Create a new Redfish session
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500164 Redfish Power Off
165 Redfish Power On
shrsuman123c1d3fe32020-09-08 05:04:07 -0500166
167 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask}
168
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500169
shrsuman123c1d3fe32020-09-08 05:04:07 -0500170Verify Persistency Of VMI DHCP IP Configuration After Multiple HOST Reboots
171 [Documentation] Verify Persistency Of VMI DHCP IP configuration After Multiple HOST Reboots
172 [Tags] Verify_Persistency_Of_VMI_DHCP_IP_Configuration_After_Multiple_HOST_Reboots
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500173 [Teardown] Test Teardown Execution
shrsuman123c1d3fe32020-09-08 05:04:07 -0500174
175 ${LOOP_COUNT}= Set Variable ${3}
176 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
177 Run Keywords Redfish Power Off AND Redfish Power On
178 ${vmi_ip_config}= Get VMI Network Interface Details
179 # Verifying persistency of dynamic address after multiple reboots.
180 Repeat Keyword ${LOOP_COUNT} times
181 ... Verify VMI Network Interface Details ${vmi_ip_config["IPv4_Address"]} DHCP ${vmi_ip_config["IPv4_Gateway"]}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500182 ... ${vmi_ip_config["IPv4_SubnetMask"]}
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 [Teardown] Test Teardown Execution
189
190 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
191 Set VMI IPv4 Origin ${True}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500192 ${vmi_network_conf}= Get VMI Network Interface Details
193 Should Not Be Equal As Strings ${test_ipv4} ${vmi_network_conf["IPv4_Address"]}
194
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500195
shrsuman123e37b0cc2020-09-02 00:33:42 -0500196Verify VMI Static IP Configuration Persist On BMC Reset Before Host Boot
197 [Documentation] Verify VMI static IP configuration persist on BMC reset.
198 [Tags] Verify_VMI_Static_IP_Configuration_Persist_On_BMC_Reset_Before_Host_Boot
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600199 [Teardown] Run keywords Delete VMI IPv4 Address AND FFDC On Test Case Fail
shrsuman123e37b0cc2020-09-02 00:33:42 -0500200
201 Set Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500202 OBMC Reboot (off)
203 Redfish Power On
shrsuman123e37b0cc2020-09-02 00:33:42 -0500204 # Verifying the VMI static configuration
205 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask}
206
207
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500208Verify To Configure VMI Static IP Address With Different User Roles
209 [Documentation] Verify to configure vmi static ip address with different user roles.
210 [Tags] Verify_To_Configure_VMI_Static_IP_Address_With_Different_User_Roles
211 [Setup] Create Users With Different Roles users=${USERS} force=${True}
212 [Template] Config VMI Static IP Address Using Different Users
213 [Teardown] Delete BMC Users Using Redfish
214
215 # username password ip_address gateway nemask valid_status_code
216 admin_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_ACCEPTED}
217 operator_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
218 readonly_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
219 noaccess_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
220
221
222Verify To Delete VMI Static IP Address With Different User Roles
223 [Documentation] Verify to delete vmi static IP address with different user roles.
224 [Tags] Verify_To_Delete_VMI_Static_IP_Address_With_Different_User_Roles
225 [Setup] Create Users With Different Roles users=${USERS} force=${True}
226 [Template] Delete VMI Static IP Address Using Different Users
227 [Teardown] Delete BMC Users Using Redfish
228
229 # username password valid_status_code
230 admin_user TestPwd123 ${HTTP_ACCEPTED}
231 operator_user TestPwd123 ${HTTP_FORBIDDEN}
232 readonly_user TestPwd123 ${HTTP_FORBIDDEN}
233 noaccess_user TestPwd123 ${HTTP_FORBIDDEN}
234
235
236Verify To Update VMI Static IP Address With Different User Roles
237 [Documentation] Verify to update vmi static IP address with different user roles.
238 [Tags] Verify_To_Update_VMI_Static_IP_Address_With_Different_User_Roles_And_Verify
239 [Setup] Create Users With Different Roles users=${USERS} force=${True}
240 [Template] Config VMI Static IP Address Using Different Users
241 [Teardown] Delete BMC Users Using Redfish
242
243 # username password ip_address gateway nemask valid_status_code
244 admin_user TestPwd123 10.5.10.20 0.0.0.0 255.255.0.0 ${HTTP_ACCEPTED}
245 operator_user TestPwd123 10.5.10.30 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
246 readonly_user TestPwd123 10.5.20.40 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
247 noaccess_user TestPwd123 10.5.30.50 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
248
249
250Verify To Read VMI Network Configuration With Different User Roles
251 [Documentation] Verify to read vmi network configuration with different user roles.
252 [Tags] Verify_To_Read_VMI_Network_Configuration_Via_Different_User_Roles
253 [Setup] Create Users With Different Roles users=${USERS} force=${True}
254 [Template] Read VMI Static IP Address Using Different Users
255 [Teardown] Delete BMC Users Using Redfish
256
257 # username password valid_status_code
258 admin_user TestPwd123 ${HTTP_OK}
259 operator_user TestPwd123 ${HTTP_OK}
260 readonly_user TestPwd123 ${HTTP_OK}
261 noaccess_user TestPwd123 ${HTTP_FORBIDDEN}
262
shrsuman123b361d412020-09-30 06:17:23 -0500263Enable DHCP On VMI Network Via Different Users Roles And Verify
264 [Documentation] Enable DHCP On VMI Network Via Different Users Roles And Verify.
265 [Tags] Enable_DHCP_On_VMI_Network_Via_Different_Users_Roles_And_Verify
266 [Setup] Create Users With Different Roles users=${USERS} force=${True}
267 [Template] Update User Role And Set VMI IPv4 Origin
268 [Teardown] Delete BMC Users Using Redfish
269
270 # username password dhcp_enabled valid_status_code
271 admin_user TestPwd123 ${True} ${HTTP_ACCEPTED}
272 operator_user TestPwd123 ${True} ${HTTP_FORBIDDEN}
273 readonly_user TestPwd123 ${True} ${HTTP_FORBIDDEN}
274 noaccess_user TestPwd123 ${True} ${HTTP_FORBIDDEN}
275
276Disable DHCP On VMI Network Via Different Users Roles And Verify
277 [Documentation] Disable DHCP On VMI Network Via Different Users Roles And Verify.
278 [Tags] Disable_DHCP_On_VMI_Network_Via_Different_Users_Roles_And_Verify
279 [Setup] Create Users With Different Roles users=${USERS} force=${True}
280 [Template] Update User Role And Set VMI IPv4 Origin
281 [Teardown] Delete BMC Users Using Redfish
282
283 # username password dhcp_enabled valid_status_code
284 admin_user TestPwd123 ${False} ${HTTP_ACCEPTED}
285 operator_user TestPwd123 ${False} ${HTTP_FORBIDDEN}
286 readonly_user TestPwd123 ${False} ${HTTP_FORBIDDEN}
287 noaccess_user TestPwd123 ${False} ${HTTP_FORBIDDEN}
288
shrsuman123e37b0cc2020-09-02 00:33:42 -0500289
Anves Kumar rayankula55b939e2020-08-12 04:19:01 -0500290Enable And Disable DHCP And Verify
291 [Documentation] verify enable DHCP and disable DHCP.
292 [Tags] Enabled_And_Disabled_DHCP_Verify
293
294 Set VMI IPv4 Origin ${True}
295 ${default}= Set Variable 0.0.0.0
296 Verify VMI Network Interface Details ${default} DHCP ${default} ${default}
297 Set VMI IPv4 Origin ${False}
298 Verify VMI Network Interface Details ${default} Static ${default} ${default}
299
300
301Multiple Times Enable And Disable DHCP And Verify
302 [Documentation] Enable and Disable DHCP in a loop and verify VMI gets an IP address from DHCP
303 ... each time when DHCP is enabled
304 [Tags] Multiple_Times_Enable_And_Disable_DHCP_And_Verify
305
306 ${default}= Set Variable 0.0.0.0
307 FOR ${i} IN RANGE ${2}
308 Set VMI IPv4 Origin ${True}
309 Verify VMI Network Interface Details ${default} DHCP ${default} ${default}
310 Set VMI IPv4 Origin ${False}
311 Verify VMI Network Interface Details ${default} Static ${default} ${default}
312 END
313
314
Vijay06a169d2020-04-23 09:28:24 -0500315*** Keywords ***
316
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500317Suite Setup Execution
318 [Documentation] Do test setup execution task.
319
320 Redfish.Login
321 Redfish Power On
322 ${active_channel_config}= Get Active Channel Config
323 Set Suite Variable ${active_channel_config}
324 ${resp}= Redfish.Get
325 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
326 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
327 ${length}= Get Length ${ip_resp["IPv4StaticAddresses"]}
328 ${vmi_network_conf}= Run Keyword If ${length} != ${0} Get VMI Network Interface Details
329 Set Suite Variable ${vmi_network_conf}
330
331
332Test Teardown Execution
333 [Documentation] Do test teardown execution task.
334
335 FFDC On Test Case Fail
336 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
337 Run Keyword If ${curr_mode} == ${True} Set VMI IPv4 Origin ${False}
338 Run Keyword If ${vmi_network_conf} != ${None}
339 ... Verify Assigning Static IPv4 Address To VMI ${vmi_network_conf["IPv4_Address"]}
340 ... ${vmi_network_conf["IPv4_Gateway"]} ${vmi_network_conf["IPv4_SubnetMask"]}
341
342
Vijay06a169d2020-04-23 09:28:24 -0500343Get VMI Network Interface Details
344 [Documentation] Get VMI network interface details.
345 [Arguments] ${valid_status_code}=${HTTP_OK}
346
347 # Description of argument(s):
348 # valid_status_code Expected valid status code from GET request.
349
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500350 # Note: It returns a dictionary of VMI eth0 parameters.
Vijay06a169d2020-04-23 09:28:24 -0500351
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500352 ${active_channel_config}= Get Active Channel Config
353 ${resp}= Redfish.Get
354 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Vijay06a169d2020-04-23 09:28:24 -0500355 ... valid_status_codes=[${valid_status_code}]
356
357 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
358
359 ${static_exists}= Run Keyword And Ignore Error
360 ... Set Variable ${ip_resp["IPv4StaticAddresses"][0]["Address"]}
361 ${static_exists}= Set Variable If '${static_exists[0]}' == 'PASS' ${True} ${False}
362
363 ${vmi_ip}= Create Dictionary DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}} Id=${ip_resp["Id"]}
364 ... Description=${ip_resp["Description"]} IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]}
365 ... IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]} Name=${ip_resp["Name"]}
Sushil Singh810234d2020-05-13 12:12:03 -0500366 ... IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]}
367 ... InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}}
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500368 ... IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]}
Vijay06a169d2020-04-23 09:28:24 -0500369 ... IPv4StaticAddresses=${${static_exists}}
370
371 [Return] &{vmi_ip}
372
373
374Get Immediate Child Parameter From VMI Network Interface
375 [Documentation] Get immediate child parameter from VMI network interface.
376 [Arguments] ${parameter} ${valid_status_code}=${HTTP_OK}
377
378 # Description of argument(s):
379 # parameter parameter for which value is required. Ex: DHCPEnabled, MACAddress etc.
380 # valid_status_code Expected valid status code from GET request.
381
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500382 ${active_channel_config}= Get Active Channel Config
383 ${resp}= Redfish.Get
384 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Vijay06a169d2020-04-23 09:28:24 -0500385 ... valid_status_codes=[${valid_status_code}]
386
387 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
388 ${value}= Set Variable If '${parameter}' != 'DHCPEnabled' ${ip_resp["${parameter}"]}
389 ... ${ip_resp["DHCPv4"]["${parameter}"]}
390
391 [Return] ${value}
392
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600393
Vijay06a169d2020-04-23 09:28:24 -0500394Verify VMI EthernetInterfaces
395 [Documentation] Verify VMI ethernet interfaces.
396 [Arguments] ${valid_status_code}=${HTTP_OK}
397
398 # Description of argument(s):
399 # valid_status_code Expected valid status code from GET request.
400
401 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces
402 ... valid_status_codes=[${valid_status_code}]
403
404 ${resp}= Evaluate json.loads('''${resp.text}''') json
405 ${interfaces}= Set Variable ${resp["Members"]}
406
407 Should Be Equal As Strings ${interfaces[0]}[@odata.id]
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500408 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0
Vijay06a169d2020-04-23 09:28:24 -0500409 Should Be Equal As Strings ${interfaces[1]}[@odata.id]
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500410 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth1
Vijay06a169d2020-04-23 09:28:24 -0500411
412 Should Be Equal ${resp["Members@odata.count"]} ${2}
413
414
415Verify VMI Network Interface Details
416 [Documentation] Verify VMI network interface details.
417 [Arguments] ${ip} ${origin} ${gateway} ${netmask}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500418 ... ${valid_status_code}=${HTTP_OK}
Vijay06a169d2020-04-23 09:28:24 -0500419
420 # Description of argument(s):
421 # ip VMI IPv4 address.
422 # origin Origin of IPv4 address eg. Static or DHCP.
423 # gateway Gateway for VMI IP.
424 # netmask Subnetmask for VMI IP.
425 # valid_status_code Expected valid status code from GET request. Default is HTTP_OK.
Vijay06a169d2020-04-23 09:28:24 -0500426
Vijay06a169d2020-04-23 09:28:24 -0500427 ${vmi_ip}= Get VMI Network Interface Details ${valid_status_code}
428 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]}
429 Should Be Equal As Strings ${gateway} ${vmi_ip["IPv4_Gateway"]}
430 Should Be Equal As Strings ${netmask} ${vmi_ip["IPv4_SubnetMask"]}
Vijay06a169d2020-04-23 09:28:24 -0500431 Should Be Equal As Strings ${ip} ${vmi_ip["IPv4_Address"]}
432
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600433
434Set Static IPv4 Address To VMI And Verify
Vijay06a169d2020-04-23 09:28:24 -0500435 [Documentation] Set static IPv4 address to VMI.
436 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED}
437
438 # Description of argument(s):
439 # ip VMI IPv4 address.
440 # gateway Gateway for VMI IP.
441 # netmask Subnetmask for VMI IP.
442 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED.
443
444 ${data}= Set Variable
445 ... {"IPv4StaticAddresses": [{"Address": "${ip}","SubnetMask": "${netmask}","Gateway": "${gateway}"}]}
446
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500447 ${active_channel_config}= Get Active Channel Config
448 ${resp}= Redfish.Patch
449 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
450 ... body=${data} valid_status_codes=[${valid_status_code}]
Prashanth Katti1ce68212020-11-13 00:39:03 -0600451
452 # Wait few seconds for new configuration to get populated on runtime.
453 Sleep ${wait_time}
Vijay06a169d2020-04-23 09:28:24 -0500454
Vijay06a169d2020-04-23 09:28:24 -0500455 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500456 Verify VMI Network Interface Details ${ip} Static ${gateway} ${netmask}
Vijay06a169d2020-04-23 09:28:24 -0500457
458
459Delete VMI IPv4 Address
460 [Documentation] Delete VMI IPv4 address.
461 [Arguments] ${delete_param}=IPv4StaticAddresses ${valid_status_code}=${HTTP_ACCEPTED}
462
463 # Description of argument(s):
464 # delete_param Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses.
465 # Default is IPv4StaticAddresses.
466 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
467
468 ${data}= Set Variable {"${delete_param}": [${Null}]}
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500469 ${active_channel_config}= Get Active Channel Config
470 ${resp}= Redfish.Patch
471 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
472 ... body=${data} valid_status_codes=[${valid_status_code}]
Vijay06a169d2020-04-23 09:28:24 -0500473
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600474 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED}
475 ${resp}= Redfish.Get
476 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
477 Should Be Empty ${resp.dict["IPv4StaticAddresses"]}
478
Vijay06a169d2020-04-23 09:28:24 -0500479
480Set VMI IPv4 Origin
481 [Documentation] Set VMI IPv4 origin.
482 [Arguments] ${dhcp_enabled}=${False} ${valid_status_code}=${HTTP_ACCEPTED}
483
484 # Description of argument(s):
485 # dhcp_enabled True if user wants to enable DHCP. Default is Static, hence value is set to False.
486 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
487
488 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500489 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 body=${data}
Vijay06a169d2020-04-23 09:28:24 -0500490 ... valid_status_codes=[${valid_status_code}]
shrsuman123b361d412020-09-30 06:17:23 -0500491 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED}
492 ${resp}= Redfish.Get
493 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
494 Should Be Equal ${resp.dict["DHCPv4"]["DHCPEnabled"]} ${dhcp_enabled}
Vijay06a169d2020-04-23 09:28:24 -0500495
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600496 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED}
497 ${resp}= Redfish.Get
498 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
499 Should Be Equal ${resp.dict["DHCPv4"]["DHCPEnabled"]} ${dhcp_enabled}
500
Vijay06a169d2020-04-23 09:28:24 -0500501
502Switch VMI IPv4 Origin And Verify Details
503 [Documentation] Switch VMI IPv4 origin and verify details.
Vijay06a169d2020-04-23 09:28:24 -0500504
505 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
506 ${dhcp_enabled}= Set Variable If ${curr_mode} == ${False} ${True} ${False}
507
508 ${default}= Set Variable 0.0.0.0
509 ${origin}= Set Variable If ${curr_mode} == ${False} DHCP Static
510 Set VMI IPv4 Origin ${dhcp_enabled} ${HTTP_ACCEPTED}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500511 Verify VMI Network Interface Details ${default} ${origin} ${default} ${default}
Vijay06a169d2020-04-23 09:28:24 -0500512
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500513
514Delete VMI Static IP Address Using Different Users
515 [Documentation] Update user role and delete vmi static IP address.
516 [Arguments] ${username} ${password} ${valid_status_code}
517 [Teardown] Run Keywords Redfish.Login AND
518 ... Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway}
519 ... ${test_netmask} ${HTTP_ACCEPTED} AND Redfish.Logout
520
521 # Description of argument(s):
522 # username The host username.
523 # password The host password.
524 # valid_status_code The expected valid status code.
525
526 Redfish.Login ${username} ${password}
527 Delete VMI IPv4 Address delete_param=IPv4StaticAddresses valid_status_code=${valid_status_code}
528 Redfish.Logout
529
530
531Config VMI Static IP Address Using Different Users
532 [Documentation] Update user role and update vmi static ip address.
533 [Arguments] ${username} ${password} ${ip} ${gateway} ${netmask}
534 ... ${valid_status_code}
535
536 # Description of argument(s):
537 # username The host username.
538 # password The host password.
539 # ip IP address to be added (e.g. "10.7.7.7").
540 # subnet_mask Subnet mask for the IP to be added
541 # (e.g. "255.255.0.0").
542 # gateway Gateway for the IP to be added (e.g. "10.7.7.1").
543 # valid_status_code The expected valid status code.
544
545 Redfish.Login ${username} ${password}
Anves Kumar rayankula1b64d942020-11-17 02:44:02 -0600546 Set Static IPv4 Address To VMI And Verify ${ip} ${gateway} ${netmask} ${valid_status_code}
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500547 Redfish.Logout
548
549
550Read VMI Static IP Address Using Different Users
551 [Documentation] Update user role and read vmi static ip address.
552 [Arguments] ${username} ${password} ${valid_status_code}
553
554 # Description of argument(s):
555 # username The host username.
556 # password The host password.
557 # valid_status_code The expected valid status code.
558
559 Redfish.Login ${username} ${password}
560 Redfish.Get
561 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
562 ... valid_status_codes=[${valid_status_code}]
563 Redfish.Logout
564
565
566Delete BMC Users Using Redfish
567 [Documentation] Delete BMC users via redfish.
568
569 Redfish.Login
570 Delete BMC Users Via Redfish users=${USERS}
shrsuman123b361d412020-09-30 06:17:23 -0500571
572Update User Role And Set VMI IPv4 Origin
573 [Documentation] Update User Role And Set VMI IPv4 Origin.
574 [Arguments] ${username} ${password} ${dhcp_enabled} ${valid_status_code}
575
576 # Description of argument(s):
577 # username The host username.
578 # password The host password.
579 # dhcp_enabled Indicates whether dhcp should be enabled
580 # (${True}, ${False}).
581 # valid_status_code The expected valid status code.
582
583 Redfish.Login ${username} ${password}
584 Set VMI IPv4 Origin ${dhcp_enabled} ${valid_status_code}
585 Redfish.Logout