blob: 5cb0f86c7a6bd883cdff48848fef9be15283cbcd [file] [log] [blame]
Vijay06a169d2020-04-23 09:28:24 -05001*** Settings ***
2
3Documentation VMI static/dynamic IP config and certificate exchange tests.
4
5Resource ../../lib/resource.robot
6Resource ../../lib/bmc_redfish_resource.robot
7Resource ../../lib/openbmc_ffdc.robot
8
9Suite Setup Redfish.Login
10Test Teardown FFDC On Test Case Fail
11Suite Teardown Redfish.Logout
12
13*** Variables ***
14
15&{DHCP_ENABLED} DHCPEnabled=${${True}}
16&{DHCP_DISABLED} DHCPEnabled=${${False}}
17
18&{ENABLE_DHCP} DHCPv4=&{DHCP_ENABLED}
19&{DISABLE_DHCP} DHCPv4=&{DHCP_DISABLED}
20
21
22*** Test Cases ***
23
24Verify All VMI EthernetInterfaces
25 [Documentation] Verify all VMI ethernet interfaces.
26 [Tags] Verify_All_VMI_EthernetINterfaces
27
28 Verify VMI EthernetInterfaces
29
30
31Verify Existing VMI Network Interface Details
32 [Documentation] Verify existing VMI network interface details.
33 [Tags] Verify_VMI_Network_Interface_Details
34
35 ${vmi_ip}= Get VMI Network Interface Details
36 ${origin}= Set Variable If ${vmi_ip["DHCPv4"]} == ${False} Static DHCP
37
38 Should Not Be Equal ${vmi_ip["DHCPv4"]} ${vmi_ip["IPv4StaticAddresses"]}
39 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]}
40 Should Be Equal As Strings ${vmi_ip["Id"]} intf0
George Keishingb3ea0952020-07-01 05:03:56 -050041 Should Be Equal As Strings ${vmi_ip["Description"]}
42 ... Ethernet Interface for Virtual Management Interface
43 Should Be Equal As Strings ${vmi_ip["Name"]} Virtual Management Interface
Vijay06a169d2020-04-23 09:28:24 -050044 Should Be True ${vmi_ip["InterfaceEnabled"]}
45
46
47Delete Existing Static VMI IP Address
48 [Documentation] Delete existing static VMI IP address.
49 [Tags] Delete_Existing_Static_VMI_IP_Address
50
51 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
52 Run Keyword If ${curr_origin} == ${True} Set VMI IPv4 Origin ${False} ${HTTP_ACCEPTED}
53
54 Delete VMI IPv4 Address IPv4StaticAddresses valid_status_code=${HTTP_ACCEPTED}
55 ${default}= Set Variable 0.0.0.0
56 Verify VMI Network Interface Details ${default} Static ${default} ${default} ${True}
57
58
59Verify User Cannot Delete ReadOnly Property IPv4Addresses
60 [Documentation] Verify user cannot delete readonly property IPv4Addresses.
61 [Tags] Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses
62
63 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
64 Run Keyword If ${curr_origin} == ${False} Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
65 Delete VMI IPv4 Address IPv4Addresses valid_status_code=${HTTP_BAD_REQUEST}
66
67
68Assign Static IPv4 Address To VMI
69 [Documentation] Assign static IPv4 address to VMI.
70 [Tags] Assign_Static_IPv4_Address_To_VMI
71 [Template] Verify Assigning Static IPv4 Address To VMI
72
73 # ip gateway netmask del_curr_ip host_reboot valid_status_code
74 ${VMI_IP} ${VMI_GATEWAY} ${VMI_NETMASK} ${False} ${True} ${HTTP_ACCEPTED}
75 a.3.118.94 ${VMI_GATEWAY} ${VMI_NETMASK} ${False} ${False} ${HTTP_BAD_REQUEST}
76 10.118.94 10.118.3.Z ${VMI_NETMASK} ${False} ${False} ${HTTP_BAD_REQUEST}
77
78
79Switch Between IP Origins On VMI And Verify Details
80 [Documentation] Switch between IP origins on VMI and verify details.
81 [Tags] Switch_Between_IP_Origins_On_VMI_And_Verify_Details
82
83 Switch VMI IPv4 Origin And Verify Details
84 Switch VMI IPv4 Origin And Verify Details
85
86
87Verify Persistency Of VMI IPv4 Details After Host Reboot
88 [Documentation] Verify persistency of VMI IPv4 details after host reboot.
89 [Tags] Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot
90
91 # Verifying persistency of dynamic address.
92 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
93 ${default}= Set Variable 0.0.0.0
94 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} ${True}
95 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} ${True}
96
97 # Verifying persistency of static address.
98 Switch VMI IPv4 Origin And Verify Details ${True}
99 Verify Assigning Static IPv4 Address To VMI ${VMI_IP} ${VMI_GATEWAY} ${VMI_NETMASK} ${False}
100 Verify VMI Network Interface Details ${VMI_IP} Static ${VMI_GATEWAY} ${VMI_NETMASK} ${True}
101
102
103*** Keywords ***
104
105Get VMI Network Interface Details
106 [Documentation] Get VMI network interface details.
107 [Arguments] ${valid_status_code}=${HTTP_OK}
108
109 # Description of argument(s):
110 # valid_status_code Expected valid status code from GET request.
111
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500112 # Note: It returns a dictionary of VMI eth0 parameters.
Vijay06a169d2020-04-23 09:28:24 -0500113
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500114 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0
Vijay06a169d2020-04-23 09:28:24 -0500115 ... valid_status_codes=[${valid_status_code}]
116
117 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
118
119 ${static_exists}= Run Keyword And Ignore Error
120 ... Set Variable ${ip_resp["IPv4StaticAddresses"][0]["Address"]}
121 ${static_exists}= Set Variable If '${static_exists[0]}' == 'PASS' ${True} ${False}
122
123 ${vmi_ip}= Create Dictionary DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}} Id=${ip_resp["Id"]}
124 ... Description=${ip_resp["Description"]} IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]}
125 ... IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]} Name=${ip_resp["Name"]}
Sushil Singh810234d2020-05-13 12:12:03 -0500126 ... IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]}
127 ... InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}}
Vijay06a169d2020-04-23 09:28:24 -0500128 ... IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]} MACAddress=${ip_resp["MACAddress"]}
129 ... IPv4StaticAddresses=${${static_exists}}
130
131 [Return] &{vmi_ip}
132
133
134Get Immediate Child Parameter From VMI Network Interface
135 [Documentation] Get immediate child parameter from VMI network interface.
136 [Arguments] ${parameter} ${valid_status_code}=${HTTP_OK}
137
138 # Description of argument(s):
139 # parameter parameter for which value is required. Ex: DHCPEnabled, MACAddress etc.
140 # valid_status_code Expected valid status code from GET request.
141
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500142 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0
Vijay06a169d2020-04-23 09:28:24 -0500143 ... valid_status_codes=[${valid_status_code}]
144
145 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
146 ${value}= Set Variable If '${parameter}' != 'DHCPEnabled' ${ip_resp["${parameter}"]}
147 ... ${ip_resp["DHCPv4"]["${parameter}"]}
148
149 [Return] ${value}
150
151
152Verify VMI EthernetInterfaces
153 [Documentation] Verify VMI ethernet interfaces.
154 [Arguments] ${valid_status_code}=${HTTP_OK}
155
156 # Description of argument(s):
157 # valid_status_code Expected valid status code from GET request.
158
159 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces
160 ... valid_status_codes=[${valid_status_code}]
161
162 ${resp}= Evaluate json.loads('''${resp.text}''') json
163 ${interfaces}= Set Variable ${resp["Members"]}
164
165 Should Be Equal As Strings ${interfaces[0]}[@odata.id]
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500166 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0
Vijay06a169d2020-04-23 09:28:24 -0500167 Should Be Equal As Strings ${interfaces[1]}[@odata.id]
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500168 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth1
Vijay06a169d2020-04-23 09:28:24 -0500169
170 Should Be Equal ${resp["Members@odata.count"]} ${2}
171
172
173Verify VMI Network Interface Details
174 [Documentation] Verify VMI network interface details.
175 [Arguments] ${ip} ${origin} ${gateway} ${netmask}
176 ... ${host_reboot}=${False} ${valid_status_code}=${HTTP_OK}
177
178 # Description of argument(s):
179 # ip VMI IPv4 address.
180 # origin Origin of IPv4 address eg. Static or DHCP.
181 # gateway Gateway for VMI IP.
182 # netmask Subnetmask for VMI IP.
183 # valid_status_code Expected valid status code from GET request. Default is HTTP_OK.
184 # host_reboot Reboot HOST if True.
185
186 Run Keyword If ${host_reboot} == ${True} Run Keywords
187 ... Redfish Power Off AND Redfish Power On AND Redfish.Login
188
189 ${vmi_ip}= Get VMI Network Interface Details ${valid_status_code}
190 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]}
191 Should Be Equal As Strings ${gateway} ${vmi_ip["IPv4_Gateway"]}
192 Should Be Equal As Strings ${netmask} ${vmi_ip["IPv4_SubnetMask"]}
193
194 Return From Keyword If '${origin}' == 'DHCP'
195 Should Be Equal As Strings ${ip} ${vmi_ip["IPv4_Address"]}
196
197
198Set Static IPv4 Address To VMI
199 [Documentation] Set static IPv4 address to VMI.
200 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED}
201
202 # Description of argument(s):
203 # ip VMI IPv4 address.
204 # gateway Gateway for VMI IP.
205 # netmask Subnetmask for VMI IP.
206 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED.
207
208 ${data}= Set Variable
209 ... {"IPv4StaticAddresses": [{"Address": "${ip}","SubnetMask": "${netmask}","Gateway": "${gateway}"}]}
210
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500211 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 body=${data}
Vijay06a169d2020-04-23 09:28:24 -0500212 ... valid_status_codes=[${valid_status_code}]
213 Redfish Power On stack_mode=skip
214 Log To Console ${resp.text}
215
216
217Verify Assigning Static IPv4 Address To VMI
218 [Documentation] Verify assigning static IPv4 address to VMI.
219 [Arguments] ${ip} ${gateway} ${netmask} ${del_curr_ip}=${True} ${host_reboot}=${True}
220 ... ${valid_status_code}=${HTTP_ACCEPTED}
221
222 # Description of argument(s):
223 # ip VMI IPv4 address.
224 # gateway Gateway for VMI IP.
225 # netmask Subnetmask for VMI IP.
226 # del_curr_ip Delete current VMI static IP if True.
227 # host_reboot True when HOST reboot is required.
228 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED.
229
230 # Delete current static IP based on user input.
231 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
232 Run Keyword If ${curr_origin} == ${False} and ${del_curr_ip} == ${True} Delete VMI IPv4 Address
233
234 Set Static IPv4 Address To VMI ${ip} ${gateway} ${netmask} valid_status_code=${valid_status_code}
235 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED}
236
237 Verify VMI Network Interface Details ${ip} Static ${gateway} ${netmask} host_reboot=${host_reboot}
238
239
240Delete VMI IPv4 Address
241 [Documentation] Delete VMI IPv4 address.
242 [Arguments] ${delete_param}=IPv4StaticAddresses ${valid_status_code}=${HTTP_ACCEPTED}
243
244 # Description of argument(s):
245 # delete_param Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses.
246 # Default is IPv4StaticAddresses.
247 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
248
249 ${data}= Set Variable {"${delete_param}": [${Null}]}
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500250 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 body=${data}
Vijay06a169d2020-04-23 09:28:24 -0500251 ... valid_status_codes=[${valid_status_code}]
252
253
254Set VMI IPv4 Origin
255 [Documentation] Set VMI IPv4 origin.
256 [Arguments] ${dhcp_enabled}=${False} ${valid_status_code}=${HTTP_ACCEPTED}
257
258 # Description of argument(s):
259 # dhcp_enabled True if user wants to enable DHCP. Default is Static, hence value is set to False.
260 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
261
262 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
Anves Kumar rayankulaaa33b052020-07-22 04:24:51 -0500263 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 body=${data}
Vijay06a169d2020-04-23 09:28:24 -0500264 ... valid_status_codes=[${valid_status_code}]
265
266
267Switch VMI IPv4 Origin And Verify Details
268 [Documentation] Switch VMI IPv4 origin and verify details.
269 [Arguments] ${host_reboot}=${False}
270
271 # Description of argument(s):
272 # host_reboot Reboot HOST if True.
273
274 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
275 ${dhcp_enabled}= Set Variable If ${curr_mode} == ${False} ${True} ${False}
276
277 ${default}= Set Variable 0.0.0.0
278 ${origin}= Set Variable If ${curr_mode} == ${False} DHCP Static
279 Set VMI IPv4 Origin ${dhcp_enabled} ${HTTP_ACCEPTED}
280 Verify VMI Network Interface Details ${default} ${origin} ${default} ${default} ${host_reboot}
281
282 [Return] ${origin}