blob: 90bd68d19fe7e27cd86df8aac4e065c25503c293 [file] [log] [blame]
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -05001*** Settings ***
2Documentation Test BMC multiple network interface functionalities.
3
4# User input BMC IP for the eth1.
5# Use can input as -v OPENBMC_HOST_1:xx.xxx.xx from command line.
6Library ../../lib/bmc_redfish.py https://${OPENBMC_HOST_1}:${HTTPS_PORT}
7... ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} WITH NAME Redfish1
8
9Resource ../../lib/resource.robot
10Resource ../../lib/common_utils.robot
11Resource ../../lib/connection_client.robot
12Resource ../../lib/bmc_network_utils.robot
13Resource ../../lib/openbmc_ffdc.robot
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050014Resource ../../lib/bmc_ldap_utils.robot
Anves Kumar rayankula2f9632f2021-07-05 04:37:45 -050015Resource ../../lib/snmp/resource.robot
16Resource ../../lib/snmp/redfish_snmp_utils.robot
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -050017Resource ../../lib/certificate_utils.robot
Anves Kumar rayankulaa38ec2e2021-07-10 01:09:23 -050018Library ../../lib/jobs_processing.py
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -050019Library OperatingSystem
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -050020
21Suite Setup Suite Setup Execution
22Test Teardown FFDC On Test Case Fail
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050023Suite Teardown Run Keywords Redfish1.Logout AND Redfish.Logout
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -050024
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -050025*** Variables ***
26
27${cmd_prefix} ipmitool -I lanplus -C 17 -p 623 -U ${OPENBMC_USERNAME} -P ${OPENBMC_PASSWORD}
Sweta Potthuri2667f2c2022-10-11 07:55:21 -050028${test_ipv4_addr} 10.7.7.7
29${test_ipv4_addr2} 10.7.7.8
30${test_subnet_mask} 255.255.255.0
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -050031
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -050032*** Test Cases ***
33
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050034Verify Both Interfaces BMC IP Addresses Accessible Via SSH
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -050035 [Documentation] Verify both interfaces (eth0, eth1) BMC IP addresses accessible via SSH.
36 [Tags] Verify_Both_Interfaces_BMC_IP_Addresses_Accessible_Via_SSH
37
38 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${OPENBMC_HOST}
39 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${OPENBMC_HOST_1}
40 Close All Connections
41
42
Anves Kumar rayankula55d51922021-07-01 06:37:00 -050043Verify Redfish Works On Both Interfaces
44 [Documentation] Verify access BMC with both interfaces (eth0, eth1) IP addresses via Redfish.
45 [Tags] Verify_Redfish_Works_On_Both_Interfaces
46 [Teardown] Run Keywords
47 ... Configure Hostname ${hostname} AND Validate Hostname On BMC ${hostname}
48
49 Redfish1.Login
50 Redfish.Login
51
52 ${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}
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050068 ... AND Delete IP Address ${OPENBMC_HOST_1}
Sweta Potthurib9513c62023-03-01 01:11:43 -060069 ... AND Redfish.Login
70 [Teardown] Run Keywords Redfish.Logout AND
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050071 ... Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway}
72
73 Create LDAP Configuration
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050074 Redfish.Logout
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
81 [Setup] Redfish.Login
82 [Teardown] Redfish.Logout
83
84 Create LDAP Configuration
85 Redfish.Logout
86 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
87
88
89Verify Secure LDAP Login Works When Both Interfaces Are Configured
90 [Documentation] Verify Secure LDAP login works when both the interfaces are configured.
91 [Tags] Verify_Secure_LDAP_Login_Works_When_Both_Interfaces_Are_Configured
92 [Setup] Redfish.Login
93 [Teardown] Redfish.Logout
94
95 Create LDAP Configuration ${LDAP_TYPE} ${LDAP_SERVER_URI_1} ${LDAP_BIND_DN}
96 ... ${LDAP_BIND_DN_PASSWORD} ${LDAP_BASE_DN}
97 Redfish.Logout
98 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -050099
100
Anves Kumar rayankula2f9632f2021-07-05 04:37:45 -0500101Verify SNMP Works When Eth1 IP Is Not Configured
102 [Documentation] Verify SNMP works when eth1 IP is not configured.
103 [Tags] Verify_SNMP_Works_When_Eth1_IP_Is_Not_Configured
kothais01f95fc2023-11-01 14:12:51 +0000104 [Setup] Run Keywords Set Test Variable ${CHANNEL_NUMBER} ${SECONDARY_CHANNEL_NUMBER}
Anves Kumar rayankula2f9632f2021-07-05 04:37:45 -0500105 ... AND Delete IP Address ${OPENBMC_HOST_1}
106 [Teardown] Run Keywords Redfish.Login AND
107 ... Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway}
108
109 Create Error On BMC And Verify Trap
110
111
Anves Kumar rayankula04bc48c2021-07-08 23:33:37 -0500112Disable And Enable Eth0 Interface
113 [Documentation] Disable and Enable eth0 ethernet interface via redfish.
114 [Tags] Disable_And_Enable_Eth0_Interface
115 [Template] Set BMC Ethernet Interfaces State
116
117 # interface_ip interface enabled
118 ${OPENBMC_HOST} eth0 ${False}
119 ${OPENBMC_HOST} eth0 ${True}
120
121
Anves Kumar rayankulaa38ec2e2021-07-10 01:09:23 -0500122Verify Both Interfaces Access Concurrently Via Redfish
123 [Documentation] Verify both interfaces access conurrently via redfish.
124 [Tags] Verify_Both_Interfaces_Access_Concurrently_Via_Redfish
125
126 Redfish.Login
127 Redfish1.Login
128
129 ${dict}= Execute Process Multi Keyword ${2}
130 ... Redfish.Patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}}
131 ... Redfish1.Patch ${REDFISH_NW_ETH_IFACE}eth1 body={'DHCPv4':{'UseDNSServers':${True}}}
132
133 Dictionary Should Not Contain Value ${dict} False
134 ... msg=One or more operations has failed.
135
136 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}eth0
137 ${resp1}= Redfish1.Get ${REDFISH_NW_ETH_IFACE}eth1
138
139 Should Be Equal ${resp.dict["DHCPv4"]['UseDNSServers']} ${True}
140 Should Be Equal ${resp1.dict["DHCPv4"]['UseDNSServers']} ${True}
141
Anves Kumar rayankula54482cd2021-07-09 07:13:25 -0500142Able To Access Serial Console Via Both Network Interfaces
143 [Documentation] Able to access serial console via both network interfaces.
George Keishingc4914b72021-07-27 08:03:19 -0500144 [Tags] Able_To_Access_Serial_Console_Via_Both_Network_Interfaces
Anves Kumar rayankula54482cd2021-07-09 07:13:25 -0500145
146 Open Connection And Log In host=${OPENBMC_HOST} port=2200
147 Open Connection And Log In host=${OPENBMC_HOST_1} port=2200
148 Close All Connections
149
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -0500150Verify IPMI Works On Both Network Interfaces
151 [Documentation] Verify IPMI works on both network interfaces.
152 [Tags] Verify_IPMI_Works_On_Both_Network_Interfaces
153
154 Run IPMI ${OPENBMC_HOST_1} power on
155 ${status1}= Run IPMI ${OPENBMC_HOST} power status
156 ${status2}= Run IPMI ${OPENBMC_HOST_1} power status
157 Should Be Equal ${status1} ${status2}
158
Sweta Potthuri2667f2c2022-10-11 07:55:21 -0500159Verify Modifying IP Address Multiple Times On Interface
160 [Documentation] Verify modifying IP address multiple times on interface.
161 [Tags] Verify_Modifying_IP_Address_Multiple_Times_On_Interface
162 [Teardown] Run Keywords
163 ... Delete IP Address ${test_ipv4_addr} AND Test Teardown
164
165 ${test_gateway}= Get BMC Default Gateway
166 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
167 Update IP Address ${test_ipv4_addr} ${test_ipv4_addr2} ${test_subnet_mask} ${test_gateway}
168 Update IP Address ${test_ipv4_addr2} ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway}
169 Run Keyword Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
170 Run Keyword Wait For Host To Ping ${OPENBMC_HOST_1} ${NETWORK_TIMEOUT}
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500171
172Verify Able To Load Certificates Via Eth1 IP Address
George Keishingb13682a2021-07-20 08:52:39 -0500173 [Documentation] Verify able to load certificates via eth1 IP address.
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500174 [Setup] Create Directory certificate_dir
175 [Tags] Verify_Able_To_Load_Certificates_Via_Eth1_IP_Address
176 [Teardown] Run Keywords Remove Directory certificate_dir recursive=True
177 ... AND FFDC On Test Case Fail
178 [Template] Install Certificate Via Redfish And Verify
179
180 # cert_type cert_format expected_status
181 CA Valid Certificate ok
182 Client Valid Certificate Valid Privatekey ok
183
Anves Kumar rayankulad2e98ff2021-06-29 05:03:02 -0500184*** Keywords ***
185
186Get Network Configuration Using Channel Number
187 [Documentation] Get ethernet interface.
188 [Arguments] ${channel_number}
189
190 # Description of argument(s):
191 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
192
193 ${active_channel_config}= Get Active Channel Config
194 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']}
195 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
196
197 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
198 [Return] @{network_configurations}
199
200
201Suite Setup Execution
202 [Documentation] Do suite setup task.
203
204 Valid Value OPENBMC_HOST_1
205
206 # Check both interfaces are configured and reachable.
207 Ping Host ${OPENBMC_HOST}
208 Ping Host ${OPENBMC_HOST_1}
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -0500209
kothais01f95fc2023-11-01 14:12:51 +0000210 ${network_configurations}= Get Network Configuration Using Channel Number ${SECONDARY_CHANNEL_NUMBER}
Anves Kumar rayankula4fa52d72021-07-04 02:37:30 -0500211 FOR ${network_configuration} IN @{network_configurations}
212
213 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
214 ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']}
215 ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']}
216 ... AND Exit For Loop
217
218 END
Anves Kumar rayankula04bc48c2021-07-08 23:33:37 -0500219
220
221Set BMC Ethernet Interfaces State
222 [Documentation] Set BMC ethernet interface state.
223 [Arguments] ${interface_ip} ${interface} ${enabled}
224 [Teardown] Redfish1.Logout
225
226 # Description of argument(s):
227 # interface_ip IP address of ethernet interface.
228 # interface The ethernet interface name (eg. eth0 or eth1).
229 # enabled Indicates interface should be enabled (eg. True or False).
230
231 Redfish1.Login
232
233 ${data}= Create Dictionary InterfaceEnabled=${enabled}
234
235 Redfish1.patch ${REDFISH_NW_ETH_IFACE}${interface} body=&{data}
236 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
237
238 Sleep ${NETWORK_TIMEOUT}s
239 ${interface_status}= Redfish1.Get Attribute ${REDFISH_NW_ETH_IFACE}${interface} InterfaceEnabled
240 Should Be Equal ${interface_status} ${enabled}
241
242 ${status}= Run Keyword And Return Status Ping Host ${interface_ip}
243
244 Run Keyword If ${enabled} == ${True} Should Be Equal ${status} ${True}
245 ... ELSE Should Be Equal ${status} ${False}
Anves Kumar rayankulad0a2f332021-07-14 07:53:12 -0500246
247
248Run IPMI
249 [Documentation] Run IPMI command.
250 [Arguments] ${host} ${sub_cmd}
251
252 # Description of argument(s):
253 # host BMC host name or IP address.
254 # sub_cmd The IPMI command string to be executed.
255
256 ${rc} ${output}= Run And Return Rc And Output ${cmd_prefix} -H ${host} ${sub_cmd}
257 Should Be Equal As Strings ${rc} 0
258 [Return] ${output}
259
Anves Kumar rayankula75ac4292021-07-14 01:30:43 -0500260
261Install Certificate Via Redfish And Verify
262 [Documentation] Install and verify certificate using Redfish.
263 [Arguments] ${cert_type} ${cert_format} ${expected_status} ${delete_cert}=${True}
264
265 # Description of argument(s):
266 # cert_type Certificate type (e.g. "Client" or "CA").
267 # cert_format Certificate file format
268 # (e.g. "Valid_Certificate_Valid_Privatekey").
269 # expected_status Expected status of certificate replace Redfish
270 # request (i.e. "ok" or "error").
271 # delete_cert Certificate will be deleted before installing if this True.
272
273 # AUTH_URI is a global variable defined in lib/resource.robot
274 Set Test Variable ${AUTH_URI} https://${OPENBMC_HOST_1}
275 Run Keyword If '${cert_type}' == 'CA' and '${delete_cert}' == '${True}'
276 ... Delete All CA Certificate Via Redfish
277 ... ELSE IF '${cert_type}' == 'Client' and '${delete_cert}' == '${True}'
278 ... Delete Certificate Via BMC CLI ${cert_type}
279
280 ${cert_file_path}= Generate Certificate File Via Openssl ${cert_format}
281 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
282 ${file_data}= Decode Bytes To String ${bytes} UTF-8
283
284 ${certificate_uri}= Set Variable If
285 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI}
286 ... '${cert_type}' == 'CA' ${REDFISH_CA_CERTIFICATE_URI}
287
288 ${cert_id}= Install Certificate File On BMC ${certificate_uri} ${expected_status} data=${file_data}
289 Logging Installed certificate id: ${cert_id}
290
291 Sleep 30s
292 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
293 ${bmc_cert_content}= Run Keyword If '${expected_status}' == 'ok' redfish_utils.Get Attribute
294 ... ${certificate_uri}/${cert_id} CertificateString
295 Run Keyword If '${expected_status}' == 'ok' Should Contain ${cert_file_content} ${bmc_cert_content}
296 [Return] ${cert_id}