blob: 00d95ef231587f511e2fe58ce51c783c53da2ab3 [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
shrsuman123c1d3fe32020-09-08 05:04:07 -050025${test_ipv4} 10.10.20.30
26${test_gateway} 0.0.0.0
27${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}
34
35
36*** Test Cases ***
37
38Verify All VMI EthernetInterfaces
39 [Documentation] Verify all VMI ethernet interfaces.
40 [Tags] Verify_All_VMI_EthernetINterfaces
41
42 Verify VMI EthernetInterfaces
43
44
45Verify Existing VMI Network Interface Details
46 [Documentation] Verify existing VMI network interface details.
47 [Tags] Verify_VMI_Network_Interface_Details
48
49 ${vmi_ip}= Get VMI Network Interface Details
50 ${origin}= Set Variable If ${vmi_ip["DHCPv4"]} == ${False} Static DHCP
51
52 Should Not Be Equal ${vmi_ip["DHCPv4"]} ${vmi_ip["IPv4StaticAddresses"]}
53 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]}
54 Should Be Equal As Strings ${vmi_ip["Id"]} intf0
George Keishingb3ea0952020-07-01 05:03:56 -050055 Should Be Equal As Strings ${vmi_ip["Description"]}
56 ... Ethernet Interface for Virtual Management Interface
57 Should Be Equal As Strings ${vmi_ip["Name"]} Virtual Management Interface
Vijay06a169d2020-04-23 09:28:24 -050058 Should Be True ${vmi_ip["InterfaceEnabled"]}
59
60
61Delete Existing Static VMI IP Address
62 [Documentation] Delete existing static VMI IP address.
63 [Tags] Delete_Existing_Static_VMI_IP_Address
64
65 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
66 Run Keyword If ${curr_origin} == ${True} Set VMI IPv4 Origin ${False} ${HTTP_ACCEPTED}
67
68 Delete VMI IPv4 Address IPv4StaticAddresses valid_status_code=${HTTP_ACCEPTED}
69 ${default}= Set Variable 0.0.0.0
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -050070 Verify VMI Network Interface Details ${default} Static ${default} ${default}
Vijay06a169d2020-04-23 09:28:24 -050071
72
73Verify User Cannot Delete ReadOnly Property IPv4Addresses
74 [Documentation] Verify user cannot delete readonly property IPv4Addresses.
75 [Tags] Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses
76
77 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
78 Run Keyword If ${curr_origin} == ${False} Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
79 Delete VMI IPv4 Address IPv4Addresses valid_status_code=${HTTP_BAD_REQUEST}
80
81
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -050082Assign Valid And Invalid Static IPv4 Address To VMI
Vijay06a169d2020-04-23 09:28:24 -050083 [Documentation] Assign static IPv4 address to VMI.
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -050084 [Tags] Assign_Valid_And_Invalid_Static_IPv4_Address_To_VMI
Vijay06a169d2020-04-23 09:28:24 -050085 [Template] Verify Assigning Static IPv4 Address To VMI
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -050086 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses
87 ... 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 rayankulad7deb892020-08-24 02:58:20 -050097 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses
98 ... AND Test Teardown Execution
shrsuman123e37b0cc2020-09-02 00:33:42 -050099
100 ${ip1}= Create dictionary Address=10.5.5.10 SubnetMask=255.255.252.0 Gateway=0.0.0.0
101 ${ip2}= Create dictionary Address=10.5.5.11 SubnetMask=255.255.252.0 Gateway=0.0.0.0
102 ${ip3}= Create dictionary Address=10.5.5.12 SubnetMask=255.255.252.0 Gateway=0.0.0.0
103 ${ips}= Create List ${ip1} ${ip2} ${ip3}
104
105 ${active_channel_config}= Get Active Channel Config
106 Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
107 ... body={'IPv4StaticAddresses':${ips}} valid_status_codes=[${HTTP_ACCEPTED}]
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500108 Verify VMI Network Interface Details ${ip1["Address"]} Static ${ip1["Gateway"]} ${ip1["SubnetMask"]}
shrsuman123e37b0cc2020-09-02 00:33:42 -0500109
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500110
shrsuman123e37b0cc2020-09-02 00:33:42 -0500111Modify IP Addresses On VMI Interface And Verify
112 [Documentation] Modify IP addresses on VMI interface and verify.
113 [Tags] Modify_IP_Addresses_On_VMI_Interface_And_Verify
114 [Template] Verify Assigning Static IPv4 Address To VMI
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500115 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses
116 ... AND Test Teardown Execution
shrsuman123e37b0cc2020-09-02 00:33:42 -0500117
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500118 # ip gateway netmask valid_status_code
119 10.5.5.10 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED}
120 10.5.5.11 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED}
Vijay06a169d2020-04-23 09:28:24 -0500121
122Switch Between IP Origins On VMI And Verify Details
123 [Documentation] Switch between IP origins on VMI and verify details.
124 [Tags] Switch_Between_IP_Origins_On_VMI_And_Verify_Details
125
126 Switch VMI IPv4 Origin And Verify Details
127 Switch VMI IPv4 Origin And Verify Details
128
129
130Verify Persistency Of VMI IPv4 Details After Host Reboot
131 [Documentation] Verify persistency of VMI IPv4 details after host reboot.
132 [Tags] Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot
133
134 # Verifying persistency of dynamic address.
135 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
136 ${default}= Set Variable 0.0.0.0
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500137 Verify VMI Network Interface Details ${default} DHCP ${default} ${default}
138 Verify VMI Network Interface Details ${default} DHCP ${default} ${default}
Vijay06a169d2020-04-23 09:28:24 -0500139
140 # Verifying persistency of static address.
141 Switch VMI IPv4 Origin And Verify Details ${True}
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500142 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
143 Verify VMI Network Interface Details ${test_ipv4} ${test_gateway} ${test_netmask}
Vijay06a169d2020-04-23 09:28:24 -0500144
145
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500146Delete VMI Static IP Address And Verify
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500147 [Documentation] Delete VMI static IP address and verify.
148 [Tags] Delete_VMI_Static_IP_Address_And_Verify
149 [Teardown] Test Teardown Execution
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500150
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500151 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
152 Delete VMI IPv4 Address IPv4Addresses ${HTTP_ACCEPTED}
153 ${active_channel_config}= Get Active Channel Config
154 ${resp}= Redfish.Get
155 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
156 Should Be Empty ${resp.dict["IPv4Addresses"]}
157
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500158
shrsuman123c1d3fe32020-09-08 05:04:07 -0500159Verify Successful VMI IP Static Configuration On HOST Boot After Session Delete
160 [Documentation] Verify VMI IP static Configuration On HOST Boot After session deleted.
161 [Tags] Verify_Successful_VMI_IP_Static_Configuration_On_HOST_Boot_After_Session_Delete
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500162 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses AND Test Teardown Execution
shrsuman123c1d3fe32020-09-08 05:04:07 -0500163
164 Set Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
165
166 ${session_info}= Get Redfish Session Info
167 Redfish.Delete ${session_info["location"]}
168
169 # Create a new Redfish session
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500170 Redfish Power Off
171 Redfish Power On
shrsuman123c1d3fe32020-09-08 05:04:07 -0500172
173 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask}
174
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500175
shrsuman123c1d3fe32020-09-08 05:04:07 -0500176Verify Persistency Of VMI DHCP IP Configuration After Multiple HOST Reboots
177 [Documentation] Verify Persistency Of VMI DHCP IP configuration After Multiple HOST Reboots
178 [Tags] Verify_Persistency_Of_VMI_DHCP_IP_Configuration_After_Multiple_HOST_Reboots
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500179 [Teardown] Test Teardown Execution
shrsuman123c1d3fe32020-09-08 05:04:07 -0500180
181 ${LOOP_COUNT}= Set Variable ${3}
182 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
183 Run Keywords Redfish Power Off AND Redfish Power On
184 ${vmi_ip_config}= Get VMI Network Interface Details
185 # Verifying persistency of dynamic address after multiple reboots.
186 Repeat Keyword ${LOOP_COUNT} times
187 ... Verify VMI Network Interface Details ${vmi_ip_config["IPv4_Address"]} DHCP ${vmi_ip_config["IPv4_Gateway"]}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500188 ... ${vmi_ip_config["IPv4_SubnetMask"]}
189
190
191Enable DHCP When Static IP Configured And Verify Static IP
192 [Documentation] Enable DHCP when static ip configured and verify static ip
193 [Tags] Enable_DHCP_when_Static_IP_Configured_And_Verify_Static_IP
194 [Teardown] Test Teardown Execution
195
196 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
197 Set VMI IPv4 Origin ${True}
198 Redfish Power Off
199 Redfish Power On
200 ${vmi_network_conf}= Get VMI Network Interface Details
201 Should Not Be Equal As Strings ${test_ipv4} ${vmi_network_conf["IPv4_Address"]}
202
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500203
shrsuman123e37b0cc2020-09-02 00:33:42 -0500204Verify VMI Static IP Configuration Persist On BMC Reset Before Host Boot
205 [Documentation] Verify VMI static IP configuration persist on BMC reset.
206 [Tags] Verify_VMI_Static_IP_Configuration_Persist_On_BMC_Reset_Before_Host_Boot
shrsuman1235897ea72020-09-24 00:30:15 -0500207 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses AND FFDC On Test Case Fail
shrsuman123e37b0cc2020-09-02 00:33:42 -0500208
209 Set Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500210 OBMC Reboot (off)
211 Redfish Power On
shrsuman123e37b0cc2020-09-02 00:33:42 -0500212 # Verifying the VMI static configuration
213 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask}
214
215
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500216Verify To Configure VMI Static IP Address With Different User Roles
217 [Documentation] Verify to configure vmi static ip address with different user roles.
218 [Tags] Verify_To_Configure_VMI_Static_IP_Address_With_Different_User_Roles
219 [Setup] Create Users With Different Roles users=${USERS} force=${True}
220 [Template] Config VMI Static IP Address Using Different Users
221 [Teardown] Delete BMC Users Using Redfish
222
223 # username password ip_address gateway nemask valid_status_code
224 admin_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_ACCEPTED}
225 operator_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
226 readonly_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
227 noaccess_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
228
229
230Verify To Delete VMI Static IP Address With Different User Roles
231 [Documentation] Verify to delete vmi static IP address with different user roles.
232 [Tags] Verify_To_Delete_VMI_Static_IP_Address_With_Different_User_Roles
233 [Setup] Create Users With Different Roles users=${USERS} force=${True}
234 [Template] Delete VMI Static IP Address Using Different Users
235 [Teardown] Delete BMC Users Using Redfish
236
237 # username password valid_status_code
238 admin_user TestPwd123 ${HTTP_ACCEPTED}
239 operator_user TestPwd123 ${HTTP_FORBIDDEN}
240 readonly_user TestPwd123 ${HTTP_FORBIDDEN}
241 noaccess_user TestPwd123 ${HTTP_FORBIDDEN}
242
243
244Verify To Update VMI Static IP Address With Different User Roles
245 [Documentation] Verify to update vmi static IP address with different user roles.
246 [Tags] Verify_To_Update_VMI_Static_IP_Address_With_Different_User_Roles_And_Verify
247 [Setup] Create Users With Different Roles users=${USERS} force=${True}
248 [Template] Config VMI Static IP Address Using Different Users
249 [Teardown] Delete BMC Users Using Redfish
250
251 # username password ip_address gateway nemask valid_status_code
252 admin_user TestPwd123 10.5.10.20 0.0.0.0 255.255.0.0 ${HTTP_ACCEPTED}
253 operator_user TestPwd123 10.5.10.30 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
254 readonly_user TestPwd123 10.5.20.40 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
255 noaccess_user TestPwd123 10.5.30.50 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
256
257
258Verify To Read VMI Network Configuration With Different User Roles
259 [Documentation] Verify to read vmi network configuration with different user roles.
260 [Tags] Verify_To_Read_VMI_Network_Configuration_Via_Different_User_Roles
261 [Setup] Create Users With Different Roles users=${USERS} force=${True}
262 [Template] Read VMI Static IP Address Using Different Users
263 [Teardown] Delete BMC Users Using Redfish
264
265 # username password valid_status_code
266 admin_user TestPwd123 ${HTTP_OK}
267 operator_user TestPwd123 ${HTTP_OK}
268 readonly_user TestPwd123 ${HTTP_OK}
269 noaccess_user TestPwd123 ${HTTP_FORBIDDEN}
270
shrsuman123e37b0cc2020-09-02 00:33:42 -0500271
Vijay06a169d2020-04-23 09:28:24 -0500272*** Keywords ***
273
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500274Suite Setup Execution
275 [Documentation] Do test setup execution task.
276
277 Redfish.Login
278 Redfish Power On
279 ${active_channel_config}= Get Active Channel Config
280 Set Suite Variable ${active_channel_config}
281 ${resp}= Redfish.Get
282 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
283 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
284 ${length}= Get Length ${ip_resp["IPv4StaticAddresses"]}
285 ${vmi_network_conf}= Run Keyword If ${length} != ${0} Get VMI Network Interface Details
286 Set Suite Variable ${vmi_network_conf}
287
288
289Test Teardown Execution
290 [Documentation] Do test teardown execution task.
291
292 FFDC On Test Case Fail
293 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
294 Run Keyword If ${curr_mode} == ${True} Set VMI IPv4 Origin ${False}
295 Run Keyword If ${vmi_network_conf} != ${None}
296 ... Verify Assigning Static IPv4 Address To VMI ${vmi_network_conf["IPv4_Address"]}
297 ... ${vmi_network_conf["IPv4_Gateway"]} ${vmi_network_conf["IPv4_SubnetMask"]}
298
299
Vijay06a169d2020-04-23 09:28:24 -0500300Get VMI Network Interface Details
301 [Documentation] Get VMI network interface details.
302 [Arguments] ${valid_status_code}=${HTTP_OK}
303
304 # Description of argument(s):
305 # valid_status_code Expected valid status code from GET request.
306
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500307 # Note: It returns a dictionary of VMI eth0 parameters.
Vijay06a169d2020-04-23 09:28:24 -0500308
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500309 ${active_channel_config}= Get Active Channel Config
310 ${resp}= Redfish.Get
311 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Vijay06a169d2020-04-23 09:28:24 -0500312 ... valid_status_codes=[${valid_status_code}]
313
314 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
315
316 ${static_exists}= Run Keyword And Ignore Error
317 ... Set Variable ${ip_resp["IPv4StaticAddresses"][0]["Address"]}
318 ${static_exists}= Set Variable If '${static_exists[0]}' == 'PASS' ${True} ${False}
319
320 ${vmi_ip}= Create Dictionary DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}} Id=${ip_resp["Id"]}
321 ... Description=${ip_resp["Description"]} IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]}
322 ... IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]} Name=${ip_resp["Name"]}
Sushil Singh810234d2020-05-13 12:12:03 -0500323 ... IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]}
324 ... InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}}
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500325 ... IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]}
Vijay06a169d2020-04-23 09:28:24 -0500326 ... IPv4StaticAddresses=${${static_exists}}
327
328 [Return] &{vmi_ip}
329
330
331Get Immediate Child Parameter From VMI Network Interface
332 [Documentation] Get immediate child parameter from VMI network interface.
333 [Arguments] ${parameter} ${valid_status_code}=${HTTP_OK}
334
335 # Description of argument(s):
336 # parameter parameter for which value is required. Ex: DHCPEnabled, MACAddress etc.
337 # valid_status_code Expected valid status code from GET request.
338
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500339 ${active_channel_config}= Get Active Channel Config
340 ${resp}= Redfish.Get
341 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Vijay06a169d2020-04-23 09:28:24 -0500342 ... valid_status_codes=[${valid_status_code}]
343
344 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
345 ${value}= Set Variable If '${parameter}' != 'DHCPEnabled' ${ip_resp["${parameter}"]}
346 ... ${ip_resp["DHCPv4"]["${parameter}"]}
347
348 [Return] ${value}
349
Vijay06a169d2020-04-23 09:28:24 -0500350Verify VMI EthernetInterfaces
351 [Documentation] Verify VMI ethernet interfaces.
352 [Arguments] ${valid_status_code}=${HTTP_OK}
353
354 # Description of argument(s):
355 # valid_status_code Expected valid status code from GET request.
356
357 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces
358 ... valid_status_codes=[${valid_status_code}]
359
360 ${resp}= Evaluate json.loads('''${resp.text}''') json
361 ${interfaces}= Set Variable ${resp["Members"]}
362
363 Should Be Equal As Strings ${interfaces[0]}[@odata.id]
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500364 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0
Vijay06a169d2020-04-23 09:28:24 -0500365 Should Be Equal As Strings ${interfaces[1]}[@odata.id]
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500366 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth1
Vijay06a169d2020-04-23 09:28:24 -0500367
368 Should Be Equal ${resp["Members@odata.count"]} ${2}
369
370
371Verify VMI Network Interface Details
372 [Documentation] Verify VMI network interface details.
373 [Arguments] ${ip} ${origin} ${gateway} ${netmask}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500374 ... ${valid_status_code}=${HTTP_OK}
Vijay06a169d2020-04-23 09:28:24 -0500375
376 # Description of argument(s):
377 # ip VMI IPv4 address.
378 # origin Origin of IPv4 address eg. Static or DHCP.
379 # gateway Gateway for VMI IP.
380 # netmask Subnetmask for VMI IP.
381 # valid_status_code Expected valid status code from GET request. Default is HTTP_OK.
Vijay06a169d2020-04-23 09:28:24 -0500382
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500383 Run Keywords Redfish Power Off AND Redfish Power On
Vijay06a169d2020-04-23 09:28:24 -0500384 ${vmi_ip}= Get VMI Network Interface Details ${valid_status_code}
385 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]}
386 Should Be Equal As Strings ${gateway} ${vmi_ip["IPv4_Gateway"]}
387 Should Be Equal As Strings ${netmask} ${vmi_ip["IPv4_SubnetMask"]}
Vijay06a169d2020-04-23 09:28:24 -0500388 Should Be Equal As Strings ${ip} ${vmi_ip["IPv4_Address"]}
389
Vijay06a169d2020-04-23 09:28:24 -0500390Set Static IPv4 Address To VMI
391 [Documentation] Set static IPv4 address to VMI.
392 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED}
393
394 # Description of argument(s):
395 # ip VMI IPv4 address.
396 # gateway Gateway for VMI IP.
397 # netmask Subnetmask for VMI IP.
398 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED.
399
400 ${data}= Set Variable
401 ... {"IPv4StaticAddresses": [{"Address": "${ip}","SubnetMask": "${netmask}","Gateway": "${gateway}"}]}
402
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500403 ${active_channel_config}= Get Active Channel Config
404 ${resp}= Redfish.Patch
405 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
406 ... body=${data} valid_status_codes=[${valid_status_code}]
Vijay06a169d2020-04-23 09:28:24 -0500407 Log To Console ${resp.text}
408
409
410Verify Assigning Static IPv4 Address To VMI
411 [Documentation] Verify assigning static IPv4 address to VMI.
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500412 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED}
Vijay06a169d2020-04-23 09:28:24 -0500413
414 # Description of argument(s):
415 # ip VMI IPv4 address.
416 # gateway Gateway for VMI IP.
417 # netmask Subnetmask for VMI IP.
Vijay06a169d2020-04-23 09:28:24 -0500418 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED.
419
Vijay06a169d2020-04-23 09:28:24 -0500420
421 Set Static IPv4 Address To VMI ${ip} ${gateway} ${netmask} valid_status_code=${valid_status_code}
422 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED}
423
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500424 Verify VMI Network Interface Details ${ip} Static ${gateway} ${netmask}
Vijay06a169d2020-04-23 09:28:24 -0500425
426
427Delete VMI IPv4 Address
428 [Documentation] Delete VMI IPv4 address.
429 [Arguments] ${delete_param}=IPv4StaticAddresses ${valid_status_code}=${HTTP_ACCEPTED}
430
431 # Description of argument(s):
432 # delete_param Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses.
433 # Default is IPv4StaticAddresses.
434 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
435
436 ${data}= Set Variable {"${delete_param}": [${Null}]}
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500437 ${active_channel_config}= Get Active Channel Config
438 ${resp}= Redfish.Patch
439 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
440 ... body=${data} valid_status_codes=[${valid_status_code}]
Vijay06a169d2020-04-23 09:28:24 -0500441
442
443Set VMI IPv4 Origin
444 [Documentation] Set VMI IPv4 origin.
445 [Arguments] ${dhcp_enabled}=${False} ${valid_status_code}=${HTTP_ACCEPTED}
446
447 # Description of argument(s):
448 # dhcp_enabled True if user wants to enable DHCP. Default is Static, hence value is set to False.
449 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
450
451 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500452 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 body=${data}
Vijay06a169d2020-04-23 09:28:24 -0500453 ... valid_status_codes=[${valid_status_code}]
454
455
456Switch VMI IPv4 Origin And Verify Details
457 [Documentation] Switch VMI IPv4 origin and verify details.
458 [Arguments] ${host_reboot}=${False}
459
460 # Description of argument(s):
461 # host_reboot Reboot HOST if True.
462
463 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
464 ${dhcp_enabled}= Set Variable If ${curr_mode} == ${False} ${True} ${False}
465
466 ${default}= Set Variable 0.0.0.0
467 ${origin}= Set Variable If ${curr_mode} == ${False} DHCP Static
468 Set VMI IPv4 Origin ${dhcp_enabled} ${HTTP_ACCEPTED}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500469 Verify VMI Network Interface Details ${default} ${origin} ${default} ${default}
Vijay06a169d2020-04-23 09:28:24 -0500470
471 [Return] ${origin}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500472
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500473
474Delete VMI Static IP Address Using Different Users
475 [Documentation] Update user role and delete vmi static IP address.
476 [Arguments] ${username} ${password} ${valid_status_code}
477 [Teardown] Run Keywords Redfish.Login AND
478 ... Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway}
479 ... ${test_netmask} ${HTTP_ACCEPTED} AND Redfish.Logout
480
481 # Description of argument(s):
482 # username The host username.
483 # password The host password.
484 # valid_status_code The expected valid status code.
485
486 Redfish.Login ${username} ${password}
487 Delete VMI IPv4 Address delete_param=IPv4StaticAddresses valid_status_code=${valid_status_code}
488 Redfish.Logout
489
490
491Config VMI Static IP Address Using Different Users
492 [Documentation] Update user role and update vmi static ip address.
493 [Arguments] ${username} ${password} ${ip} ${gateway} ${netmask}
494 ... ${valid_status_code}
495
496 # Description of argument(s):
497 # username The host username.
498 # password The host password.
499 # ip IP address to be added (e.g. "10.7.7.7").
500 # subnet_mask Subnet mask for the IP to be added
501 # (e.g. "255.255.0.0").
502 # gateway Gateway for the IP to be added (e.g. "10.7.7.1").
503 # valid_status_code The expected valid status code.
504
505 Redfish.Login ${username} ${password}
506 Verify Assigning Static IPv4 Address To VMI ${ip} ${gateway} ${netmask} ${valid_status_code}
507 Redfish.Logout
508
509
510Read VMI Static IP Address Using Different Users
511 [Documentation] Update user role and read vmi static ip address.
512 [Arguments] ${username} ${password} ${valid_status_code}
513
514 # Description of argument(s):
515 # username The host username.
516 # password The host password.
517 # valid_status_code The expected valid status code.
518
519 Redfish.Login ${username} ${password}
520 Redfish.Get
521 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
522 ... valid_status_codes=[${valid_status_code}]
523 Redfish.Logout
524
525
526Delete BMC Users Using Redfish
527 [Documentation] Delete BMC users via redfish.
528
529 Redfish.Login
530 Delete BMC Users Via Redfish users=${USERS}