blob: 53e92daf6dc5c454f663a08ddfc20e64f6460fb7 [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
41 Should Be Equal As Strings ${vmi_ip["Description"]} Virtual Interface Management Network Interface
42 Should Be Equal As Strings ${vmi_ip["Name"]} Virtual Management Ethernet Interface
43 Should Be True ${vmi_ip["InterfaceEnabled"]}
44
45
46Delete Existing Static VMI IP Address
47 [Documentation] Delete existing static VMI IP address.
48 [Tags] Delete_Existing_Static_VMI_IP_Address
49
50 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
51 Run Keyword If ${curr_origin} == ${True} Set VMI IPv4 Origin ${False} ${HTTP_ACCEPTED}
52
53 Delete VMI IPv4 Address IPv4StaticAddresses valid_status_code=${HTTP_ACCEPTED}
54 ${default}= Set Variable 0.0.0.0
55 Verify VMI Network Interface Details ${default} Static ${default} ${default} ${True}
56
57
58Verify User Cannot Delete ReadOnly Property IPv4Addresses
59 [Documentation] Verify user cannot delete readonly property IPv4Addresses.
60 [Tags] Verify_User_Cannot_Delete_ReadOnly_Property_IPv4Addresses
61
62 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
63 Run Keyword If ${curr_origin} == ${False} Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
64 Delete VMI IPv4 Address IPv4Addresses valid_status_code=${HTTP_BAD_REQUEST}
65
66
67Assign Static IPv4 Address To VMI
68 [Documentation] Assign static IPv4 address to VMI.
69 [Tags] Assign_Static_IPv4_Address_To_VMI
70 [Template] Verify Assigning Static IPv4 Address To VMI
71
72 # ip gateway netmask del_curr_ip host_reboot valid_status_code
73 ${VMI_IP} ${VMI_GATEWAY} ${VMI_NETMASK} ${False} ${True} ${HTTP_ACCEPTED}
74 a.3.118.94 ${VMI_GATEWAY} ${VMI_NETMASK} ${False} ${False} ${HTTP_BAD_REQUEST}
75 10.118.94 10.118.3.Z ${VMI_NETMASK} ${False} ${False} ${HTTP_BAD_REQUEST}
76
77
78Switch Between IP Origins On VMI And Verify Details
79 [Documentation] Switch between IP origins on VMI and verify details.
80 [Tags] Switch_Between_IP_Origins_On_VMI_And_Verify_Details
81
82 Switch VMI IPv4 Origin And Verify Details
83 Switch VMI IPv4 Origin And Verify Details
84
85
86Verify Persistency Of VMI IPv4 Details After Host Reboot
87 [Documentation] Verify persistency of VMI IPv4 details after host reboot.
88 [Tags] Verify_Persistency_Of_VMI_IPv4_Details_After_Host_Reboot
89
90 # Verifying persistency of dynamic address.
91 Set VMI IPv4 Origin ${True} ${HTTP_ACCEPTED}
92 ${default}= Set Variable 0.0.0.0
93 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} ${True}
94 Verify VMI Network Interface Details ${default} DHCP ${default} ${default} ${True}
95
96 # Verifying persistency of static address.
97 Switch VMI IPv4 Origin And Verify Details ${True}
98 Verify Assigning Static IPv4 Address To VMI ${VMI_IP} ${VMI_GATEWAY} ${VMI_NETMASK} ${False}
99 Verify VMI Network Interface Details ${VMI_IP} Static ${VMI_GATEWAY} ${VMI_NETMASK} ${True}
100
101
102*** Keywords ***
103
104Get VMI Network Interface Details
105 [Documentation] Get VMI network interface details.
106 [Arguments] ${valid_status_code}=${HTTP_OK}
107
108 # Description of argument(s):
109 # valid_status_code Expected valid status code from GET request.
110
111 # Note: It returns a dictionary of VMI intf0 parameters.
112
113 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0
114 ... valid_status_codes=[${valid_status_code}]
115
116 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
117
118 ${static_exists}= Run Keyword And Ignore Error
119 ... Set Variable ${ip_resp["IPv4StaticAddresses"][0]["Address"]}
120 ${static_exists}= Set Variable If '${static_exists[0]}' == 'PASS' ${True} ${False}
121
122 ${vmi_ip}= Create Dictionary DHCPv4=${${ip_resp["DHCPv4"]["DHCPEnabled"]}} Id=${ip_resp["Id"]}
123 ... Description=${ip_resp["Description"]} IPv4_Address=${ip_resp["IPv4Addresses"][0]["Address"]}
124 ... IPv4_AddressOrigin=${ip_resp["IPv4Addresses"][0]["AddressOrigin"]} Name=${ip_resp["Name"]}
125 ... IPv4_Gateway=${ip_resp["IPv4Addresses"][0]["Gateway"]} InterfaceEnabled=${${ip_resp["InterfaceEnabled"]}}
126 ... IPv4_SubnetMask=${ip_resp["IPv4Addresses"][0]["SubnetMask"]} MACAddress=${ip_resp["MACAddress"]}
127 ... IPv4StaticAddresses=${${static_exists}}
128
129 [Return] &{vmi_ip}
130
131
132Get Immediate Child Parameter From VMI Network Interface
133 [Documentation] Get immediate child parameter from VMI network interface.
134 [Arguments] ${parameter} ${valid_status_code}=${HTTP_OK}
135
136 # Description of argument(s):
137 # parameter parameter for which value is required. Ex: DHCPEnabled, MACAddress etc.
138 # valid_status_code Expected valid status code from GET request.
139
140 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0
141 ... valid_status_codes=[${valid_status_code}]
142
143 ${ip_resp}= Evaluate json.loads('''${resp.text}''') json
144 ${value}= Set Variable If '${parameter}' != 'DHCPEnabled' ${ip_resp["${parameter}"]}
145 ... ${ip_resp["DHCPv4"]["${parameter}"]}
146
147 [Return] ${value}
148
149
150Verify VMI EthernetInterfaces
151 [Documentation] Verify VMI ethernet interfaces.
152 [Arguments] ${valid_status_code}=${HTTP_OK}
153
154 # Description of argument(s):
155 # valid_status_code Expected valid status code from GET request.
156
157 ${resp}= Redfish.Get /redfish/v1/Systems/hypervisor/EthernetInterfaces
158 ... valid_status_codes=[${valid_status_code}]
159
160 ${resp}= Evaluate json.loads('''${resp.text}''') json
161 ${interfaces}= Set Variable ${resp["Members"]}
162
163 Should Be Equal As Strings ${interfaces[0]}[@odata.id]
164 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0
165 Should Be Equal As Strings ${interfaces[1]}[@odata.id]
166 ... /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf1
167
168 Should Be Equal ${resp["Members@odata.count"]} ${2}
169
170
171Verify VMI Network Interface Details
172 [Documentation] Verify VMI network interface details.
173 [Arguments] ${ip} ${origin} ${gateway} ${netmask}
174 ... ${host_reboot}=${False} ${valid_status_code}=${HTTP_OK}
175
176 # Description of argument(s):
177 # ip VMI IPv4 address.
178 # origin Origin of IPv4 address eg. Static or DHCP.
179 # gateway Gateway for VMI IP.
180 # netmask Subnetmask for VMI IP.
181 # valid_status_code Expected valid status code from GET request. Default is HTTP_OK.
182 # host_reboot Reboot HOST if True.
183
184 Run Keyword If ${host_reboot} == ${True} Run Keywords
185 ... Redfish Power Off AND Redfish Power On AND Redfish.Login
186
187 ${vmi_ip}= Get VMI Network Interface Details ${valid_status_code}
188 Should Be Equal As Strings ${origin} ${vmi_ip["IPv4_AddressOrigin"]}
189 Should Be Equal As Strings ${gateway} ${vmi_ip["IPv4_Gateway"]}
190 Should Be Equal As Strings ${netmask} ${vmi_ip["IPv4_SubnetMask"]}
191
192 Return From Keyword If '${origin}' == 'DHCP'
193 Should Be Equal As Strings ${ip} ${vmi_ip["IPv4_Address"]}
194
195
196Set Static IPv4 Address To VMI
197 [Documentation] Set static IPv4 address to VMI.
198 [Arguments] ${ip} ${gateway} ${netmask} ${valid_status_code}=${HTTP_ACCEPTED}
199
200 # Description of argument(s):
201 # ip VMI IPv4 address.
202 # gateway Gateway for VMI IP.
203 # netmask Subnetmask for VMI IP.
204 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED.
205
206 ${data}= Set Variable
207 ... {"IPv4StaticAddresses": [{"Address": "${ip}","SubnetMask": "${netmask}","Gateway": "${gateway}"}]}
208
209 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 body=${data}
210 ... valid_status_codes=[${valid_status_code}]
211 Redfish Power On stack_mode=skip
212 Log To Console ${resp.text}
213
214
215Verify Assigning Static IPv4 Address To VMI
216 [Documentation] Verify assigning static IPv4 address to VMI.
217 [Arguments] ${ip} ${gateway} ${netmask} ${del_curr_ip}=${True} ${host_reboot}=${True}
218 ... ${valid_status_code}=${HTTP_ACCEPTED}
219
220 # Description of argument(s):
221 # ip VMI IPv4 address.
222 # gateway Gateway for VMI IP.
223 # netmask Subnetmask for VMI IP.
224 # del_curr_ip Delete current VMI static IP if True.
225 # host_reboot True when HOST reboot is required.
226 # valid_status_code Expected valid status code from GET request. Default is HTTP_ACCEPTED.
227
228 # Delete current static IP based on user input.
229 ${curr_origin}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
230 Run Keyword If ${curr_origin} == ${False} and ${del_curr_ip} == ${True} Delete VMI IPv4 Address
231
232 Set Static IPv4 Address To VMI ${ip} ${gateway} ${netmask} valid_status_code=${valid_status_code}
233 Return From Keyword If ${valid_status_code} != ${HTTP_ACCEPTED}
234
235 Verify VMI Network Interface Details ${ip} Static ${gateway} ${netmask} host_reboot=${host_reboot}
236
237
238Delete VMI IPv4 Address
239 [Documentation] Delete VMI IPv4 address.
240 [Arguments] ${delete_param}=IPv4StaticAddresses ${valid_status_code}=${HTTP_ACCEPTED}
241
242 # Description of argument(s):
243 # delete_param Parameter to be deleted eg. IPv4StaticAddresses or IPv4Addresses.
244 # Default is IPv4StaticAddresses.
245 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
246
247 ${data}= Set Variable {"${delete_param}": [${Null}]}
248 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 body=${data}
249 ... valid_status_codes=[${valid_status_code}]
250
251
252Set VMI IPv4 Origin
253 [Documentation] Set VMI IPv4 origin.
254 [Arguments] ${dhcp_enabled}=${False} ${valid_status_code}=${HTTP_ACCEPTED}
255
256 # Description of argument(s):
257 # dhcp_enabled True if user wants to enable DHCP. Default is Static, hence value is set to False.
258 # valid_status_code Expected valid status code from PATCH request. Default is HTTP_OK.
259
260 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
261 ${resp}= Redfish.Patch /redfish/v1/Systems/hypervisor/EthernetInterfaces/intf0 body=${data}
262 ... valid_status_codes=[${valid_status_code}]
263
264
265Switch VMI IPv4 Origin And Verify Details
266 [Documentation] Switch VMI IPv4 origin and verify details.
267 [Arguments] ${host_reboot}=${False}
268
269 # Description of argument(s):
270 # host_reboot Reboot HOST if True.
271
272 ${curr_mode}= Get Immediate Child Parameter From VMI Network Interface DHCPEnabled
273 ${dhcp_enabled}= Set Variable If ${curr_mode} == ${False} ${True} ${False}
274
275 ${default}= Set Variable 0.0.0.0
276 ${origin}= Set Variable If ${curr_mode} == ${False} DHCP Static
277 Set VMI IPv4 Origin ${dhcp_enabled} ${HTTP_ACCEPTED}
278 Verify VMI Network Interface Details ${default} ${origin} ${default} ${default} ${host_reboot}
279
280 [Return] ${origin}