blob: 3af3e1feb7fa05744a78b26b33fa9e63a4cdd87f [file] [log] [blame]
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -05001*** Settings ***
2Documentation Test BMC multiple network interface functionalities.
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -05003... Run on setup with both eth0 and eth1 in static mode.
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -05004
5# User input BMC IP for the eth1.
6# Use can input as -v OPENBMC_HOST_1:xx.xxx.xx from command line.
7Library ../../lib/bmc_redfish.py https://${OPENBMC_HOST_1}:${HTTPS_PORT}
8... ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} WITH NAME Redfish1
9
10Resource ../../lib/resource.robot
11Resource ../../lib/common_utils.robot
12Resource ../../lib/connection_client.robot
13Resource ../../lib/bmc_network_utils.robot
14Resource ../../lib/openbmc_ffdc.robot
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050015Resource ../../lib/bmc_ldap_utils.robot
Anves Kumar rayankula2f9632f2021-07-05 04:37:45 -050016Resource ../../lib/snmp/resource.robot
17Resource ../../lib/snmp/redfish_snmp_utils.robot
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -050018Resource ../../lib/certificate_utils.robot
Sweta Potthuri79ba8a22024-09-25 04:09:45 -050019Resource ../../lib/protocol_setting_utils.robot
Anves Kumar rayankulaa38ec2e2021-07-10 01:09:23 -050020Library ../../lib/jobs_processing.py
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -050021Library OperatingSystem
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -050022
23Suite Setup Suite Setup Execution
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -050024Test Setup Run Keywords Redfish.Login AND Redfish1.Login
25Test Teardown Run Keywords FFDC On Test Case Fail AND Redfish.Logout AND Redfish1.Logout
Sweta Potthuri79ba8a22024-09-25 04:09:45 -050026Suite Teardown Run Keywords Redfish1.Logout AND Redfish.Logout
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -050027
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -050028*** Variables ***
29
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -050030${cmd_prefix} ipmitool -I lanplus -C 17 -p 623 -U ${IPMI_USERNAME} -P ${IPMI_PASSWORD}
Sweta Potthuri2667f2c2022-10-11 07:55:21 -050031${test_ipv4_addr} 10.7.7.7
32${test_ipv4_addr2} 10.7.7.8
33${test_subnet_mask} 255.255.255.0
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -050034
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -050035*** Test Cases ***
36
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050037Verify Both Interfaces BMC IP Addresses Accessible Via SSH
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -050038 [Documentation] Verify both interfaces (eth0, eth1) BMC IP addresses accessible via SSH.
39 [Tags] Verify_Both_Interfaces_BMC_IP_Addresses_Accessible_Via_SSH
40
41 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${OPENBMC_HOST}
42 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${OPENBMC_HOST_1}
43 Close All Connections
44
45
Anves Kumar rayankula55d51922021-07-01 06:37:00 -050046Verify Redfish Works On Both Interfaces
47 [Documentation] Verify access BMC with both interfaces (eth0, eth1) IP addresses via Redfish.
48 [Tags] Verify_Redfish_Works_On_Both_Interfaces
49 [Teardown] Run Keywords
50 ... Configure Hostname ${hostname} AND Validate Hostname On BMC ${hostname}
51
Anves Kumar rayankula55d51922021-07-01 06:37:00 -050052 ${hostname}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
53 ${data}= Create Dictionary HostName=openbmc
54 Redfish1.patch ${REDFISH_NW_ETH_IFACE}eth1 body=&{data}
55 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
56
57 Validate Hostname On BMC openbmc
58
59 ${resp1}= Redfish.Get ${REDFISH_NW_ETH_IFACE}eth0
60 ${resp2}= Redfish1.Get ${REDFISH_NW_ETH_IFACE}eth1
61 Should Be Equal ${resp1.dict['HostName']} ${resp2.dict['HostName']}
62
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050063
64Verify LDAP Login Works When Eth1 IP Is Not Configured
65 [Documentation] Verify LDAP login works when eth1 IP is erased.
66 [Tags] Verify_LDAP_Login_Works_When_Eth1_IP_Is_Not_Configured
kothais01f95fc2023-11-01 14:12:51 +000067 [Setup] Run Keywords Set Test Variable ${CHANNEL_NUMBER} ${SECONDARY_CHANNEL_NUMBER}
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -050068 ... AND Redfish.Login AND Delete IP Address ${OPENBMC_HOST_1}
69 [Teardown] Run Keywords Redfish.Logout AND Redfish.Login AND
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050070 ... Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway}
71
72 Create LDAP Configuration
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050073 Redfish.Logout
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -050074 Sleep 30
Sweta Potthurib9513c62023-03-01 01:11:43 -060075 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
76
77
78Verify LDAP Login Works When Both Interfaces Are Configured
79 [Documentation] Verify LDAP login works when both interfaces are configured.
80 [Tags] Verify_LDAP_Login_Works_When_Both_Interfaces_Are_Configured
Sweta Potthurib9513c62023-03-01 01:11:43 -060081
82 Create LDAP Configuration
83 Redfish.Logout
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -050084 Sleep 30
Sweta Potthurib9513c62023-03-01 01:11:43 -060085 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
86
87
88Verify Secure LDAP Login Works When Both Interfaces Are Configured
89 [Documentation] Verify Secure LDAP login works when both the interfaces are configured.
90 [Tags] Verify_Secure_LDAP_Login_Works_When_Both_Interfaces_Are_Configured
Sweta Potthurib9513c62023-03-01 01:11:43 -060091
92 Create LDAP Configuration ${LDAP_TYPE} ${LDAP_SERVER_URI_1} ${LDAP_BIND_DN}
93 ... ${LDAP_BIND_DN_PASSWORD} ${LDAP_BASE_DN}
94 Redfish.Logout
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -050095 Sleep 30
Sweta Potthurib9513c62023-03-01 01:11:43 -060096 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050097
98
Anves Kumar rayankula2f9632f2021-07-05 04:37:45 -050099Verify SNMP Works When Eth1 IP Is Not Configured
100 [Documentation] Verify SNMP works when eth1 IP is not configured.
101 [Tags] Verify_SNMP_Works_When_Eth1_IP_Is_Not_Configured
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -0500102 [Setup] Run Keywords Redfish.Login AND
103 ... Set Test Variable ${CHANNEL_NUMBER} ${SECONDARY_CHANNEL_NUMBER}
Anves Kumar rayankula2f9632f2021-07-05 04:37:45 -0500104 ... AND Delete IP Address ${OPENBMC_HOST_1}
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -0500105 [Teardown] Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway}
Anves Kumar rayankula2f9632f2021-07-05 04:37:45 -0500106
107 Create Error On BMC And Verify Trap
108
109
Anves Kumar rayankula04bc48c2021-07-08 23:33:37 -0500110Disable And Enable Eth0 Interface
111 [Documentation] Disable and Enable eth0 ethernet interface via redfish.
112 [Tags] Disable_And_Enable_Eth0_Interface
113 [Template] Set BMC Ethernet Interfaces State
114
115 # interface_ip interface enabled
116 ${OPENBMC_HOST} eth0 ${False}
117 ${OPENBMC_HOST} eth0 ${True}
118
119
Anves Kumar rayankulaa38ec2e2021-07-10 01:09:23 -0500120Verify Both Interfaces Access Concurrently Via Redfish
121 [Documentation] Verify both interfaces access conurrently via redfish.
122 [Tags] Verify_Both_Interfaces_Access_Concurrently_Via_Redfish
123
Anves Kumar rayankulaa38ec2e2021-07-10 01:09:23 -0500124 ${dict}= Execute Process Multi Keyword ${2}
Sweta Potthuri79ba8a22024-09-25 04:09:45 -0500125 ... Redfish.patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}}
126 ... Redfish1.patch ${REDFISH_NW_ETH_IFACE}eth1 body={'DHCPv4':{'UseDNSServers':${True}}}
Anves Kumar rayankulaa38ec2e2021-07-10 01:09:23 -0500127
128 Dictionary Should Not Contain Value ${dict} False
129 ... msg=One or more operations has failed.
130
131 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}eth0
132 ${resp1}= Redfish1.Get ${REDFISH_NW_ETH_IFACE}eth1
133
134 Should Be Equal ${resp.dict["DHCPv4"]['UseDNSServers']} ${True}
135 Should Be Equal ${resp1.dict["DHCPv4"]['UseDNSServers']} ${True}
136
Anves Kumar rayankula54482cd2021-07-09 07:13:25 -0500137Able To Access Serial Console Via Both Network Interfaces
138 [Documentation] Able to access serial console via both network interfaces.
George Keishingc4914b72021-07-27 08:03:19 -0500139 [Tags] Able_To_Access_Serial_Console_Via_Both_Network_Interfaces
Anves Kumar rayankula54482cd2021-07-09 07:13:25 -0500140
141 Open Connection And Log In host=${OPENBMC_HOST} port=2200
142 Open Connection And Log In host=${OPENBMC_HOST_1} port=2200
143 Close All Connections
144
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -0500145Verify IPMI Works On Both Network Interfaces
146 [Documentation] Verify IPMI works on both network interfaces.
147 [Tags] Verify_IPMI_Works_On_Both_Network_Interfaces
148
149 Run IPMI ${OPENBMC_HOST_1} power on
150 ${status1}= Run IPMI ${OPENBMC_HOST} power status
151 ${status2}= Run IPMI ${OPENBMC_HOST_1} power status
152 Should Be Equal ${status1} ${status2}
153
Sweta Potthuri2667f2c2022-10-11 07:55:21 -0500154Verify Modifying IP Address Multiple Times On Interface
155 [Documentation] Verify modifying IP address multiple times on interface.
156 [Tags] Verify_Modifying_IP_Address_Multiple_Times_On_Interface
157 [Teardown] Run Keywords
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -0500158 ... Delete IP Address ${test_ipv4_addr} AND Redfish.Logout
Sweta Potthuri2667f2c2022-10-11 07:55:21 -0500159
160 ${test_gateway}= Get BMC Default Gateway
161 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
162 Update IP Address ${test_ipv4_addr} ${test_ipv4_addr2} ${test_subnet_mask} ${test_gateway}
163 Update IP Address ${test_ipv4_addr2} ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
164 Run Keyword Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
165 Run Keyword Wait For Host To Ping ${OPENBMC_HOST_1} ${NETWORK_TIMEOUT}
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500166
167Verify Able To Load Certificates Via Eth1 IP Address
George Keishingb13682a2021-07-20 08:52:39 -0500168 [Documentation] Verify able to load certificates via eth1 IP address.
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500169 [Tags] Verify_Able_To_Load_Certificates_Via_Eth1_IP_Address
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500170 [Template] Install Certificate Via Redfish And Verify
171
172 # cert_type cert_format expected_status
173 CA Valid Certificate ok
174 Client Valid Certificate Valid Privatekey ok
175
Sweta Potthuri79ba8a22024-09-25 04:09:45 -0500176Enable SSH Protocol Via Eth1 And Verify On Both Interfaces
177 [Documentation] Enable SSH protocol via eth1 and verify on both interfaces.
178 [Tags] Enable_SSH_Protocol_Via_Eth1_And_Verify_On_Both_Interfaces
179
180 Set SSH Value Via Eth1 ${True}
181 # Check if SSH is really enabled via Redfish via eth1.
182 Verify SSH Protocol State Via Eth1 ${True}
183 # Check if SSH login and commands on SSH session work on both interfaces.
184 Verify SSH Login And Commands Work
185 Verify SSH Login And Commands Work ${OPENBMC_HOST_1}
186
187Disable SSH Protocol Via Eth1 And Verify On Both Interfaces
188 [Documentation] Disable SSH protocol via eth1 and verify on both interfaces.
189 [Tags] Disable_SSH_Protocol_Via_Eth1_And_Verify_On_Both_Interfaces
190 [Teardown] Set SSH Value Via Eth1 ${True}
191
192 Set SSH Value Via Eth1 ${False}
193 # Check if SSH is really disabled via Redfish via eth1.
194 Verify SSH Protocol State Via Eth1 ${False}
195 # Check if SSH login and commands fail on eth1.
196 ${status}= Run Keyword And Return Status
197 ... Verify SSH Login And Commands Work ${OPENBMC_HOST_1}
198
199 Should Be Equal As Strings ${status} False
200 ... msg=SSH Login and commands are working after disabling SSH via eth1.
201
202 # Check if SSH login and commands fail.
203 ${status}= Run Keyword And Return Status
204 ... Verify SSH Login And Commands Work
205
206 Should Be Equal As Strings ${status} False
207 ... msg=SSH Login and commands are working after disabling SSH.
208
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -0500209*** Keywords ***
210
211Get Network Configuration Using Channel Number
212 [Documentation] Get ethernet interface.
213 [Arguments] ${channel_number}
214
215 # Description of argument(s):
216 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
217
218 ${active_channel_config}= Get Active Channel Config
219 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']}
220 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
221
222 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
George Keishing409df052024-01-17 22:36:14 +0530223 RETURN @{network_configurations}
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -0500224
225
226Suite Setup Execution
227 [Documentation] Do suite setup task.
228
229 Valid Value OPENBMC_HOST_1
230
231 # Check both interfaces are configured and reachable.
232 Ping Host ${OPENBMC_HOST}
233 Ping Host ${OPENBMC_HOST_1}
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -0500234
kothais01f95fc2023-11-01 14:12:51 +0000235 ${network_configurations}= Get Network Configuration Using Channel Number ${SECONDARY_CHANNEL_NUMBER}
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -0500236 FOR ${network_configuration} IN @{network_configurations}
237
238 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
239 ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']}
240 ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']}
241 ... AND Exit For Loop
242
243 END
Anves Kumar rayankula04bc48c2021-07-08 23:33:37 -0500244
245
246Set BMC Ethernet Interfaces State
247 [Documentation] Set BMC ethernet interface state.
248 [Arguments] ${interface_ip} ${interface} ${enabled}
249 [Teardown] Redfish1.Logout
250
251 # Description of argument(s):
252 # interface_ip IP address of ethernet interface.
253 # interface The ethernet interface name (eg. eth0 or eth1).
254 # enabled Indicates interface should be enabled (eg. True or False).
255
256 Redfish1.Login
257
258 ${data}= Create Dictionary InterfaceEnabled=${enabled}
259
260 Redfish1.patch ${REDFISH_NW_ETH_IFACE}${interface} body=&{data}
261 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
262
263 Sleep ${NETWORK_TIMEOUT}s
264 ${interface_status}= Redfish1.Get Attribute ${REDFISH_NW_ETH_IFACE}${interface} InterfaceEnabled
265 Should Be Equal ${interface_status} ${enabled}
266
267 ${status}= Run Keyword And Return Status Ping Host ${interface_ip}
268
269 Run Keyword If ${enabled} == ${True} Should Be Equal ${status} ${True}
270 ... ELSE Should Be Equal ${status} ${False}
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -0500271
272
273Run IPMI
274 [Documentation] Run IPMI command.
275 [Arguments] ${host} ${sub_cmd}
276
277 # Description of argument(s):
278 # host BMC host name or IP address.
279 # sub_cmd The IPMI command string to be executed.
280
281 ${rc} ${output}= Run And Return Rc And Output ${cmd_prefix} -H ${host} ${sub_cmd}
282 Should Be Equal As Strings ${rc} 0
George Keishing409df052024-01-17 22:36:14 +0530283 RETURN ${output}
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -0500284
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500285
286Install Certificate Via Redfish And Verify
287 [Documentation] Install and verify certificate using Redfish.
288 [Arguments] ${cert_type} ${cert_format} ${expected_status} ${delete_cert}=${True}
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -0500289 [Teardown] Remove Directory certificate_dir recursive=True
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500290
291 # Description of argument(s):
292 # cert_type Certificate type (e.g. "Client" or "CA").
293 # cert_format Certificate file format
294 # (e.g. "Valid_Certificate_Valid_Privatekey").
295 # expected_status Expected status of certificate replace Redfish
296 # request (i.e. "ok" or "error").
297 # delete_cert Certificate will be deleted before installing if this True.
298
Anvesh-Kumar_Rayankula58b55692024-09-13 03:23:03 -0500299 Create Directory certificate_dir
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500300 # AUTH_URI is a global variable defined in lib/resource.robot
301 Set Test Variable ${AUTH_URI} https://${OPENBMC_HOST_1}
302 Run Keyword If '${cert_type}' == 'CA' and '${delete_cert}' == '${True}'
303 ... Delete All CA Certificate Via Redfish
304 ... ELSE IF '${cert_type}' == 'Client' and '${delete_cert}' == '${True}'
305 ... Delete Certificate Via BMC CLI ${cert_type}
306
307 ${cert_file_path}= Generate Certificate File Via Openssl ${cert_format}
308 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
309 ${file_data}= Decode Bytes To String ${bytes} UTF-8
310
311 ${certificate_uri}= Set Variable If
312 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI}
313 ... '${cert_type}' == 'CA' ${REDFISH_CA_CERTIFICATE_URI}
314
315 ${cert_id}= Install Certificate File On BMC ${certificate_uri} ${expected_status} data=${file_data}
316 Logging Installed certificate id: ${cert_id}
317
318 Sleep 30s
319 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
320 ${bmc_cert_content}= Run Keyword If '${expected_status}' == 'ok' redfish_utils.Get Attribute
321 ... ${certificate_uri}/${cert_id} CertificateString
322 Run Keyword If '${expected_status}' == 'ok' Should Contain ${cert_file_content} ${bmc_cert_content}
George Keishing409df052024-01-17 22:36:14 +0530323 RETURN ${cert_id}
Sweta Potthuri79ba8a22024-09-25 04:09:45 -0500324
325Set SSH Value Via Eth1
326 [Documentation] Enable or disable SSH protocol via Eth1.
327 [Arguments] ${enable_value}=${True}
328
329 # Description of argument(s}:
330 # enable_value Enable or disable SSH, e.g. (true, false).
331
332 ${ssh_state}= Create Dictionary ProtocolEnabled=${enable_value}
333 ${data}= Create Dictionary SSH=${ssh_state}
334
335 Redfish1.Login
336 Redfish1.patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
337 ... valid_status_codes=[${HTTP_NO_CONTENT}]
338
339 # Wait for timeout for new values to take effect.
340 Sleep ${NETWORK_TIMEOUT}s
341
342Verify SSH Protocol State Via Eth1
343 [Documentation] Verify SSH protocol state via eth1.
344 [Arguments] ${state}=${True}
345
346 # Description of argument(s}:
347 # state Enable or disable SSH, e.g. (true, false)
348
349 ${resp}= Redfish1.Get ${REDFISH_NW_PROTOCOL_URI}
350 Should Be Equal As Strings ${resp.dict['SSH']['ProtocolEnabled']} ${state}
351 ... msg=Protocol states are not matching.