blob: 172ef9296b7ac3f6ed02c41a89769a7e99f911a0 [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
Vijay06a169d2020-04-23 09:28:24 -050086 [Template] Verify Assigning Static IPv4 Address To VMI
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -050087 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses
88 ... AND Test Teardown Execution
Vijay06a169d2020-04-23 09:28:24 -050089
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -050090 # ip gateway netmask valid_status_code
91 10.5.20.30 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED}
92 a.3.118.94 0.0.0.0 255.255.252.0 ${HTTP_BAD_REQUEST}
93
Vijay06a169d2020-04-23 09:28:24 -050094
shrsuman123e37b0cc2020-09-02 00:33:42 -050095Add Multiple IP Addreses On VMI Interface And Verify
96 [Documentation] Add multiple IP addreses on VMI interface and verify.
97 [Tags] Add_Multiple_IP_Addreses_On_VMI_Interface_And_Verify
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -050098 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses
99 ... AND Test Teardown Execution
shrsuman123e37b0cc2020-09-02 00:33:42 -0500100
101 ${ip1}= Create dictionary Address=10.5.5.10 SubnetMask=255.255.252.0 Gateway=0.0.0.0
102 ${ip2}= Create dictionary Address=10.5.5.11 SubnetMask=255.255.252.0 Gateway=0.0.0.0
103 ${ip3}= Create dictionary Address=10.5.5.12 SubnetMask=255.255.252.0 Gateway=0.0.0.0
104 ${ips}= Create List ${ip1} ${ip2} ${ip3}
105
106 ${active_channel_config}= Get Active Channel Config
107 Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
108 ... body={'IPv4StaticAddresses':${ips}} valid_status_codes=[${HTTP_ACCEPTED}]
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500109 Verify VMI Network Interface Details ${ip1["Address"]} Static ${ip1["Gateway"]} ${ip1["SubnetMask"]}
shrsuman123e37b0cc2020-09-02 00:33:42 -0500110
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500111
shrsuman123e37b0cc2020-09-02 00:33:42 -0500112Modify IP Addresses On VMI Interface And Verify
113 [Documentation] Modify IP addresses on VMI interface and verify.
114 [Tags] Modify_IP_Addresses_On_VMI_Interface_And_Verify
115 [Template] Verify Assigning Static IPv4 Address To VMI
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500116 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses
117 ... AND Test Teardown Execution
shrsuman123e37b0cc2020-09-02 00:33:42 -0500118
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500119 # ip gateway netmask valid_status_code
120 10.5.5.10 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED}
121 10.5.5.11 0.0.0.0 255.255.252.0 ${HTTP_ACCEPTED}
Vijay06a169d2020-04-23 09:28:24 -0500122
123Switch Between IP Origins On VMI And Verify Details
124 [Documentation] Switch between IP origins on VMI and verify details.
125 [Tags] Switch_Between_IP_Origins_On_VMI_And_Verify_Details
126
127 Switch VMI IPv4 Origin And Verify Details
128 Switch VMI IPv4 Origin And Verify Details
129
130
131Verify Persistency Of VMI IPv4 Details After Host Reboot
132 [Documentation] Verify persistency of VMI IPv4 details after host reboot.
133 [Tags] Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot
134
135 # Verifying persistency of dynamic address.
136 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
137 ${default}= Set Variable 0.0.0.0
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500138 Verify VMI Network Interface Details ${default} DHCP ${default} ${default}
139 Verify VMI Network Interface Details ${default} DHCP ${default} ${default}
Vijay06a169d2020-04-23 09:28:24 -0500140
141 # Verifying persistency of static address.
142 Switch VMI IPv4 Origin And Verify Details ${True}
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500143 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
144 Verify VMI Network Interface Details ${test_ipv4} ${test_gateway} ${test_netmask}
Vijay06a169d2020-04-23 09:28:24 -0500145
146
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500147Delete VMI Static IP Address And Verify
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500148 [Documentation] Delete VMI static IP address and verify.
149 [Tags] Delete_VMI_Static_IP_Address_And_Verify
150 [Teardown] Test Teardown Execution
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500151
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500152 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
153 Delete VMI IPv4 Address IPv4Addresses ${HTTP_ACCEPTED}
154 ${active_channel_config}= Get Active Channel Config
155 ${resp}= Redfish.Get
156 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
157 Should Be Empty ${resp.dict["IPv4Addresses"]}
158
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500159
shrsuman123c1d3fe32020-09-08 05:04:07 -0500160Verify Successful VMI IP Static Configuration On HOST Boot After Session Delete
161 [Documentation] Verify VMI IP static Configuration On HOST Boot After session deleted.
162 [Tags] Verify_Successful_VMI_IP_Static_Configuration_On_HOST_Boot_After_Session_Delete
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500163 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses AND Test Teardown Execution
shrsuman123c1d3fe32020-09-08 05:04:07 -0500164
165 Set Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
166
167 ${session_info}= Get Redfish Session Info
168 Redfish.Delete ${session_info["location"]}
169
170 # Create a new Redfish session
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500171 Redfish Power Off
172 Redfish Power On
shrsuman123c1d3fe32020-09-08 05:04:07 -0500173
174 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask}
175
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500176
shrsuman123c1d3fe32020-09-08 05:04:07 -0500177Verify Persistency Of VMI DHCP IP Configuration After Multiple HOST Reboots
178 [Documentation] Verify Persistency Of VMI DHCP IP configuration After Multiple HOST Reboots
179 [Tags] Verify_Persistency_Of_VMI_DHCP_IP_Configuration_After_Multiple_HOST_Reboots
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500180 [Teardown] Test Teardown Execution
shrsuman123c1d3fe32020-09-08 05:04:07 -0500181
182 ${LOOP_COUNT}= Set Variable ${3}
183 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
184 Run Keywords Redfish Power Off AND Redfish Power On
185 ${vmi_ip_config}= Get VMI Network Interface Details
186 # Verifying persistency of dynamic address after multiple reboots.
187 Repeat Keyword ${LOOP_COUNT} times
188 ... Verify VMI Network Interface Details ${vmi_ip_config["IPv4_Address"]} DHCP ${vmi_ip_config["IPv4_Gateway"]}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500189 ... ${vmi_ip_config["IPv4_SubnetMask"]}
190
191
192Enable DHCP When Static IP Configured And Verify Static IP
193 [Documentation] Enable DHCP when static ip configured and verify static ip
194 [Tags] Enable_DHCP_when_Static_IP_Configured_And_Verify_Static_IP
195 [Teardown] Test Teardown Execution
196
197 Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
198 Set VMI IPv4 Origin ${True}
199 Redfish Power Off
200 Redfish Power On
201 ${vmi_network_conf}= Get VMI Network Interface Details
202 Should Not Be Equal As Strings ${test_ipv4} ${vmi_network_conf["IPv4_Address"]}
203
Anves Kumar rayankula9fa524a2020-08-18 06:40:18 -0500204
shrsuman123e37b0cc2020-09-02 00:33:42 -0500205Verify VMI Static IP Configuration Persist On BMC Reset Before Host Boot
206 [Documentation] Verify VMI static IP configuration persist on BMC reset.
207 [Tags] Verify_VMI_Static_IP_Configuration_Persist_On_BMC_Reset_Before_Host_Boot
shrsuman1235897ea72020-09-24 00:30:15 -0500208 [Teardown] Run keywords Delete VMI IPv4 Address IPv4Addresses AND FFDC On Test Case Fail
shrsuman123e37b0cc2020-09-02 00:33:42 -0500209
210 Set Static IPv4 Address To VMI ${test_ipv4} ${test_gateway} ${test_netmask}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500211 OBMC Reboot (off)
212 Redfish Power On
shrsuman123e37b0cc2020-09-02 00:33:42 -0500213 # Verifying the VMI static configuration
214 Verify VMI Network Interface Details ${test_ipv4} Static ${test_gateway} ${test_netmask}
215
216
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500217Verify To Configure VMI Static IP Address With Different User Roles
218 [Documentation] Verify to configure vmi static ip address with different user roles.
219 [Tags] Verify_To_Configure_VMI_Static_IP_Address_With_Different_User_Roles
220 [Setup] Create Users With Different Roles users=${USERS} force=${True}
221 [Template] Config VMI Static IP Address Using Different Users
222 [Teardown] Delete BMC Users Using Redfish
223
224 # username password ip_address gateway nemask valid_status_code
225 admin_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_ACCEPTED}
226 operator_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
227 readonly_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
228 noaccess_user TestPwd123 ${test_ipv4} ${test_gateway} ${test_netmask} ${HTTP_FORBIDDEN}
229
230
231Verify To Delete VMI Static IP Address With Different User Roles
232 [Documentation] Verify to delete vmi static IP address with different user roles.
233 [Tags] Verify_To_Delete_VMI_Static_IP_Address_With_Different_User_Roles
234 [Setup] Create Users With Different Roles users=${USERS} force=${True}
235 [Template] Delete VMI Static IP Address Using Different Users
236 [Teardown] Delete BMC Users Using Redfish
237
238 # username password valid_status_code
239 admin_user TestPwd123 ${HTTP_ACCEPTED}
240 operator_user TestPwd123 ${HTTP_FORBIDDEN}
241 readonly_user TestPwd123 ${HTTP_FORBIDDEN}
242 noaccess_user TestPwd123 ${HTTP_FORBIDDEN}
243
244
245Verify To Update VMI Static IP Address With Different User Roles
246 [Documentation] Verify to update vmi static IP address with different user roles.
247 [Tags] Verify_To_Update_VMI_Static_IP_Address_With_Different_User_Roles_And_Verify
248 [Setup] Create Users With Different Roles users=${USERS} force=${True}
249 [Template] Config VMI Static IP Address Using Different Users
250 [Teardown] Delete BMC Users Using Redfish
251
252 # username password ip_address gateway nemask valid_status_code
253 admin_user TestPwd123 10.5.10.20 0.0.0.0 255.255.0.0 ${HTTP_ACCEPTED}
254 operator_user TestPwd123 10.5.10.30 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
255 readonly_user TestPwd123 10.5.20.40 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
256 noaccess_user TestPwd123 10.5.30.50 0.0.0.0 255.255.0.0 ${HTTP_FORBIDDEN}
257
258
259Verify To Read VMI Network Configuration With Different User Roles
260 [Documentation] Verify to read vmi network configuration with different user roles.
261 [Tags] Verify_To_Read_VMI_Network_Configuration_Via_Different_User_Roles
262 [Setup] Create Users With Different Roles users=${USERS} force=${True}
263 [Template] Read VMI Static IP Address Using Different Users
264 [Teardown] Delete BMC Users Using Redfish
265
266 # username password valid_status_code
267 admin_user TestPwd123 ${HTTP_OK}
268 operator_user TestPwd123 ${HTTP_OK}
269 readonly_user TestPwd123 ${HTTP_OK}
270 noaccess_user TestPwd123 ${HTTP_FORBIDDEN}
271
shrsuman123e37b0cc2020-09-02 00:33:42 -0500272
Vijay06a169d2020-04-23 09:28:24 -0500273*** Keywords ***
274
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500275Suite Setup Execution
276 [Documentation] Do test setup execution task.
277
278 Redfish.Login
279 Redfish Power On
280 ${active_channel_config}= Get Active Channel Config
281 Set Suite Variable ${active_channel_config}
282 ${resp}= Redfish.Get
283 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
284 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
285 ${length}= Get Length ${ip_resp["IPv4StaticAddresses"]}
286 ${vmi_network_conf}= Run Keyword If ${length} != ${0} Get VMI Network Interface Details
287 Set Suite Variable ${vmi_network_conf}
288
289
290Test Teardown Execution
291 [Documentation] Do test teardown execution task.
292
293 FFDC On Test Case Fail
294 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
295 Run Keyword If ${curr_mode} == ${True} Set VMI IPv4 Origin ${False}
296 Run Keyword If ${vmi_network_conf} != ${None}
297 ... Verify Assigning Static IPv4 Address To VMI ${vmi_network_conf["IPv4_Address"]}
298 ... ${vmi_network_conf["IPv4_Gateway"]} ${vmi_network_conf["IPv4_SubnetMask"]}
299
300
Vijay06a169d2020-04-23 09:28:24 -0500301Get VMI Network Interface Details
302 [Documentation] Get VMI network interface details.
303 [Arguments] ${valid_status_code}=${HTTP_OK}
304
305 # Description of argument(s):
306 # valid_status_code Expected valid status code from GET request.
307
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500308 # Note: It returns a dictionary of VMI eth0 parameters.
Vijay06a169d2020-04-23 09:28:24 -0500309
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500310 ${active_channel_config}= Get Active Channel Config
311 ${resp}= Redfish.Get
312 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Vijay06a169d2020-04-23 09:28:24 -0500313 ... valid_status_codes=[${valid_status_code}]
314
315 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
316
317 ${static_exists}= Run Keyword And Ignore Error
318 ... Set Variable ${ip_resp["IPv4StaticAddresses"][0]["Address"]}
319 ${static_exists}= Set Variable If '${static_exists[0]}' == 'PASS' ${True} ${False}
320
321 ${vmi_ip}= Create Dictionary DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}} Id=${ip_resp["Id"]}
322 ... Description=${ip_resp["Description"]} IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]}
323 ... IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]} Name=${ip_resp["Name"]}
Sushil Singh810234d2020-05-13 12:12:03 -0500324 ... IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]}
325 ... InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}}
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500326 ... IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]}
Vijay06a169d2020-04-23 09:28:24 -0500327 ... IPv4StaticAddresses=${${static_exists}}
328
329 [Return] &{vmi_ip}
330
331
332Get Immediate Child Parameter From VMI Network Interface
333 [Documentation] Get immediate child parameter from VMI network interface.
334 [Arguments] ${parameter} ${valid_status_code}=${HTTP_OK}
335
336 # Description of argument(s):
337 # parameter parameter for which value is required. Ex: DHCPEnabled, MACAddress etc.
338 # valid_status_code Expected valid status code from GET request.
339
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500340 ${active_channel_config}= Get Active Channel Config
341 ${resp}= Redfish.Get
342 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Vijay06a169d2020-04-23 09:28:24 -0500343 ... valid_status_codes=[${valid_status_code}]
344
345 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
346 ${value}= Set Variable If '${parameter}' != 'DHCPEnabled' ${ip_resp["${parameter}"]}
347 ... ${ip_resp["DHCPv4"]["${parameter}"]}
348
349 [Return] ${value}
350
Vijay06a169d2020-04-23 09:28:24 -0500351Verify VMI EthernetInterfaces
352 [Documentation] Verify VMI ethernet interfaces.
353 [Arguments] ${valid_status_code}=${HTTP_OK}
354
355 # Description of argument(s):
356 # valid_status_code Expected valid status code from GET request.
357
358 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces
359 ... valid_status_codes=[${valid_status_code}]
360
361 ${resp}= Evaluate json.loads('''${resp.text}''') json
362 ${interfaces}= Set Variable ${resp["Members"]}
363
364 Should Be Equal As Strings ${interfaces[0]}[@odata.id]
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500365 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0
Vijay06a169d2020-04-23 09:28:24 -0500366 Should Be Equal As Strings ${interfaces[1]}[@odata.id]
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500367 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth1
Vijay06a169d2020-04-23 09:28:24 -0500368
369 Should Be Equal ${resp["Members@odata.count"]} ${2}
370
371
372Verify VMI Network Interface Details
373 [Documentation] Verify VMI network interface details.
374 [Arguments] ${ip} ${origin} ${gateway} ${netmask}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500375 ... ${valid_status_code}=${HTTP_OK}
Vijay06a169d2020-04-23 09:28:24 -0500376
377 # Description of argument(s):
378 # ip VMI IPv4 address.
379 # origin Origin of IPv4 address eg. Static or DHCP.
380 # gateway Gateway for VMI IP.
381 # netmask Subnetmask for VMI IP.
382 # valid_status_code Expected valid status code from GET request. Default is HTTP_OK.
Vijay06a169d2020-04-23 09:28:24 -0500383
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}]
Prashanth Katti1ce68212020-11-13 00:39:03 -0600407
408 # Wait few seconds for new configuration to get populated on runtime.
409 Sleep ${wait_time}
Vijay06a169d2020-04-23 09:28:24 -0500410 Log To Console ${resp.text}
411
412
413Verify Assigning Static IPv4 Address To VMI
414 [Documentation] Verify assigning static IPv4 address to VMI.
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500415 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED}
Vijay06a169d2020-04-23 09:28:24 -0500416
417 # Description of argument(s):
418 # ip VMI IPv4 address.
419 # gateway Gateway for VMI IP.
420 # netmask Subnetmask for VMI IP.
Vijay06a169d2020-04-23 09:28:24 -0500421 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED.
422
Vijay06a169d2020-04-23 09:28:24 -0500423
424 Set Static IPv4 Address To VMI ${ip} ${gateway} ${netmask} valid_status_code=${valid_status_code}
425 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED}
426
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500427 Verify VMI Network Interface Details ${ip} Static ${gateway} ${netmask}
Vijay06a169d2020-04-23 09:28:24 -0500428
429
430Delete VMI IPv4 Address
431 [Documentation] Delete VMI IPv4 address.
432 [Arguments] ${delete_param}=IPv4StaticAddresses ${valid_status_code}=${HTTP_ACCEPTED}
433
434 # Description of argument(s):
435 # delete_param Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses.
436 # Default is IPv4StaticAddresses.
437 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
438
439 ${data}= Set Variable {"${delete_param}": [${Null}]}
Anves Kumar rayankula358c41d2020-08-14 04:53:06 -0500440 ${active_channel_config}= Get Active Channel Config
441 ${resp}= Redfish.Patch
442 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
443 ... body=${data} valid_status_codes=[${valid_status_code}]
Vijay06a169d2020-04-23 09:28:24 -0500444
445
446Set VMI IPv4 Origin
447 [Documentation] Set VMI IPv4 origin.
448 [Arguments] ${dhcp_enabled}=${False} ${valid_status_code}=${HTTP_ACCEPTED}
449
450 # Description of argument(s):
451 # dhcp_enabled True if user wants to enable DHCP. Default is Static, hence value is set to False.
452 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
453
454 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500455 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 body=${data}
Vijay06a169d2020-04-23 09:28:24 -0500456 ... valid_status_codes=[${valid_status_code}]
457
458
459Switch VMI IPv4 Origin And Verify Details
460 [Documentation] Switch VMI IPv4 origin and verify details.
461 [Arguments] ${host_reboot}=${False}
462
463 # Description of argument(s):
464 # host_reboot Reboot HOST if True.
465
466 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
467 ${dhcp_enabled}= Set Variable If ${curr_mode} == ${False} ${True} ${False}
468
469 ${default}= Set Variable 0.0.0.0
470 ${origin}= Set Variable If ${curr_mode} == ${False} DHCP Static
471 Set VMI IPv4 Origin ${dhcp_enabled} ${HTTP_ACCEPTED}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500472 Verify VMI Network Interface Details ${default} ${origin} ${default} ${default}
Vijay06a169d2020-04-23 09:28:24 -0500473
474 [Return] ${origin}
Anves Kumar rayankulad7deb892020-08-24 02:58:20 -0500475
Anves Kumar rayankulad5de2072020-09-30 06:24:11 -0500476
477Delete VMI Static IP Address Using Different Users
478 [Documentation] Update user role and delete vmi static IP address.
479 [Arguments] ${username} ${password} ${valid_status_code}
480 [Teardown] Run Keywords Redfish.Login AND
481 ... Verify Assigning Static IPv4 Address To VMI ${test_ipv4} ${test_gateway}
482 ... ${test_netmask} ${HTTP_ACCEPTED} AND Redfish.Logout
483
484 # Description of argument(s):
485 # username The host username.
486 # password The host password.
487 # valid_status_code The expected valid status code.
488
489 Redfish.Login ${username} ${password}
490 Delete VMI IPv4 Address delete_param=IPv4StaticAddresses valid_status_code=${valid_status_code}
491 Redfish.Logout
492
493
494Config VMI Static IP Address Using Different Users
495 [Documentation] Update user role and update vmi static ip address.
496 [Arguments] ${username} ${password} ${ip} ${gateway} ${netmask}
497 ... ${valid_status_code}
498
499 # Description of argument(s):
500 # username The host username.
501 # password The host password.
502 # ip IP address to be added (e.g. "10.7.7.7").
503 # subnet_mask Subnet mask for the IP to be added
504 # (e.g. "255.255.0.0").
505 # gateway Gateway for the IP to be added (e.g. "10.7.7.1").
506 # valid_status_code The expected valid status code.
507
508 Redfish.Login ${username} ${password}
509 Verify Assigning Static IPv4 Address To VMI ${ip} ${gateway} ${netmask} ${valid_status_code}
510 Redfish.Logout
511
512
513Read VMI Static IP Address Using Different Users
514 [Documentation] Update user role and read vmi static ip address.
515 [Arguments] ${username} ${password} ${valid_status_code}
516
517 # Description of argument(s):
518 # username The host username.
519 # password The host password.
520 # valid_status_code The expected valid status code.
521
522 Redfish.Login ${username} ${password}
523 Redfish.Get
524 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
525 ... valid_status_codes=[${valid_status_code}]
526 Redfish.Logout
527
528
529Delete BMC Users Using Redfish
530 [Documentation] Delete BMC users via redfish.
531
532 Redfish.Login
533 Delete BMC Users Via Redfish users=${USERS}