blob: a17495285d2fb0bff03ff698dcf8c4a97b07d9b4 [file] [log] [blame]
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -05001*** Settings ***
2
3Documentation Module to test IPMI network functionality.
4Resource ../lib/ipmi_client.robot
5Resource ../lib/openbmc_ffdc.robot
Rahul Maheshwaria7c39032019-09-18 02:15:01 -05006Resource ../lib/bmc_network_utils.robot
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -05007Library ../lib/ipmi_utils.py
8Library ../lib/gen_robot_valid.py
Tony Leeea741302019-11-08 11:01:58 +08009Library ../lib/var_funcs.py
10Library ../lib/bmc_network_utils.py
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -050011
Anvesh Kumar Rayankulaada25db2020-02-19 01:29:17 -060012Suite Setup Suite Setup Execution
Tony Leeea741302019-11-08 11:01:58 +080013Test Setup Printn
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -050014Test Teardown FFDC On Test Case Fail
15
16Force Tags IPMI_Network
17
Rahul Maheshwaridf04d922019-07-30 12:15:36 -050018
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -050019*** Variables ***
Anvesh Kumar Rayankulaada25db2020-02-19 01:29:17 -060020${vlan_id} ${10}
21@{vlan_ids} ${20} ${30}
22${interface} eth0
23${ip} 10.0.0.1
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -050024${initial_lan_config} &{EMPTY}
Anvesh Kumar Rayankulaada25db2020-02-19 01:29:17 -060025${vlan_resource} ${NETWORK_MANAGER}action/VLAN
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -050026
27*** Test Cases ***
28
Rahul Maheshwaridf04d922019-07-30 12:15:36 -050029Retrieve IP Address Via IPMI And Verify Using Redfish
30 [Documentation] Retrieve IP address using IPMI and verify using Redfish.
31 [Tags] Retrieve_IP_Address_Via_IPMI_And_Verify_Using_Redish
32
Tony Leeea741302019-11-08 11:01:58 +080033 ${active_channel_config}= Get Active Channel Config
Rahul Maheshwari3a1d9912020-02-25 03:13:14 -060034 FOR ${channel_number} IN @{active_channel_config.keys()}
35 Verify Channel Info ${channel_number} IPv4StaticAddresses ${active_channel_config}
Tony Leeea741302019-11-08 11:01:58 +080036 END
Rahul Maheshwaridf04d922019-07-30 12:15:36 -050037
Rahul Maheshwari3a1d9912020-02-25 03:13:14 -060038
Prashanth Katti9bebccb2019-09-25 06:38:04 -050039Retrieve Default Gateway Via IPMI And Verify
40 [Documentation] Retrieve default gateway via IPMI and verify it's existence on the BMC.
41 [Tags] Retrieve_Default_Gateway_Via_IPMI_And_Verify
Rahul Maheshwaridf04d922019-07-30 12:15:36 -050042
43 ${lan_print_ipmi}= Get LAN Print Dict
44
Prashanth Katti9bebccb2019-09-25 06:38:04 -050045 Verify Gateway On BMC ${lan_print_ipmi['Default Gateway IP']}
Rahul Maheshwaridf04d922019-07-30 12:15:36 -050046
47
48Retrieve MAC Address Via IPMI And Verify Using Redfish
49 [Documentation] Retrieve MAC address via IPMI and verify using Redfish.
50 [Tags] Retrieve_MAC_Address_Via_IPMI_And_Verify_Using_Redfish
51
Tony Leeea741302019-11-08 11:01:58 +080052 ${active_channel_config}= Get Active Channel Config
Rahul Maheshwari3a1d9912020-02-25 03:13:14 -060053 FOR ${channel_number} IN @{active_channel_config.keys()}
54 Verify Channel Info ${channel_number} MACAddress ${active_channel_config}
Tony Leeea741302019-11-08 11:01:58 +080055 END
Rahul Maheshwaridf04d922019-07-30 12:15:36 -050056
57
Rahul Maheshwaria7c39032019-09-18 02:15:01 -050058Test Valid IPMI Channels Supported
59 [Documentation] Verify IPMI channels supported on a given system.
60 [Tags] Test_Valid_IPMI_Channels_Supported
61
62 ${channel_count}= Get Physical Network Interface Count
63
64 # Note: IPMI network channel logically starts from 1.
Rahul Maheshwari3a1d9912020-02-25 03:13:14 -060065 FOR ${channel_number} IN RANGE 1 ${channel_count}
66 Run IPMI Standard Command lan print ${channel_number}
67 END
Rahul Maheshwaria7c39032019-09-18 02:15:01 -050068
69
70Test Invalid IPMI Channel Response
71 [Documentation] Verify invalid IPMI channels supported response.
72 [Tags] Test_Invalid_IPMI_Channel_Response
73
74 ${channel_count}= Get Physical Network Interface Count
75
76 # To target invalid channel, increment count.
77 ${channel_number}= Evaluate ${channel_count} + 1
78
79 # Example of invalid channel:
80 # $ ipmitool -I lanplus -H xx.xx.xx.xx -P password lan print 3
81 # Get Channel Info command failed: Parameter out of range
82 # Invalid channel: 3
83
84 ${stdout}= Run External IPMI Standard Command
85 ... lan print ${channel_number} fail_on_err=${0}
86 Should Contain ${stdout} Invalid channel
87 ... msg=IPMI channel ${channel_number} is invalid but seen working.
88
89
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -050090Verify IPMI Inband Network Configuration
91 [Documentation] Verify BMC network configuration via inband IPMI.
92 [Tags] Verify_IPMI_Inband_Network_Configuration
93 [Teardown] Run Keywords Restore Configuration AND FFDC On Test Case Fail
94
95 Redfish Power On
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -050096
97 Set IPMI Inband Network Configuration 10.10.10.10 255.255.255.0 10.10.10.10
98 Sleep 10
99
Tony Leec762a7a2019-12-30 17:12:50 +0800100 ${lan_print_output}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500101 Valid Value lan_print_output['IP Address'] ["10.10.10.10"]
102 Valid Value lan_print_output['Subnet Mask'] ["255.255.255.0"]
103 Valid Value lan_print_output['Default Gateway IP'] ["10.10.10.10"]
104
105
Sushma M M08adaa02020-01-23 03:25:19 -0600106Get IP Address Source And Verify Using Redfish
107 [Documentation] Get IP address source and verify it using Redfish.
108 [Tags] Get_IP_Address_Source_And_Verify_Using_Redfish
109
Tony Lee5a200142020-02-11 13:33:05 +0800110 ${active_channel_config}= Get Active Channel Config
111 ${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER}
112
113 ${ipv4_addresses}= Redfish.Get Attribute
George Keishing093c1bd2020-02-10 09:47:34 -0600114 ... /redfish/v1/Managers/bmc/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
115 ... IPv4Addresses
Tony Lee5a200142020-02-11 13:33:05 +0800116
117 FOR ${ipv4_address} IN @{ipv4_addresses}
Rahul Maheshwari3a1d9912020-02-25 03:13:14 -0600118 ${ip_address_source}=
119 ... Set Variable if '${ipv4_address['Address']}' == '${lan_config['IP Address']}'
120 ... ${ipv4_address['AddressOrigin']} Address
121 Exit For Loop IF "${ip_address_source}" != 'None'
Tony Lee5a200142020-02-11 13:33:05 +0800122 END
123
Tony Lee4b7fd152020-02-24 14:10:33 +0800124 Valid Value lan_config['IP Address Source'] ['${ip_address_source}']
Sushma M M08adaa02020-01-23 03:25:19 -0600125
Anvesh Kumar Rayankulaada25db2020-02-19 01:29:17 -0600126Disable VLAN Via IPMI When Multiple VLAN Exist On BMC
127 [Documentation] Disable VLAN Via IPMI When Multiple VLAN Exist On BMC.
128 [Tags] Disable_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
129 [Teardown] Run Keywords FFDC On Test Case Fail AND
130 ... Create VLAN Via IPMI off AND Restore Configuration
131
132 FOR ${id} IN @{vlan_ids}
133 @{data_vlan_id}= Create List ${interface} ${id}
134 ${data}= Create Dictionary data=@{data_vlan_id}
135 ${resp}= OpenBMC Post Request ${vlan_resource} data=${data}
136 END
137
138 Create VLAN Via IPMI off
139
140 ${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
141 Valid Value lan_config['802.1q VLAN ID'] ['Disabled']
142
143
144Configure IP On VLAN Via IPMI
145 [Documentation] Configure IP On VLAN Via IPMI.
146 [Tags] Configure_IP_On_VLAN_Via_IPMI
147 [Teardown] Run Keywords FFDC On Test Case Fail AND
148 ... Create VLAN Via IPMI off AND Restore Configuration
149
150 Create VLAN Via IPMI ${vlan_id}
151
152 Run Inband IPMI Standard Command
153 ... lan set ${CHANNEL_NUMBER} ipaddr ${ip} login_host=${0}
154
155 ${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
156 Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id}']
157 Valid Value lan_config['IP Address'] ["${ip}"]
158
159
160Create VLAN Via IPMI When LAN And VLAN Exist On BMC
161 [Documentation] Create VLAN Via IPMI When LAN And VLAN Exist On BMC.
162 [Tags] Create_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
163 [Teardown] Run Keywords FFDC On Test Case Fail AND
164 ... Create VLAN Via IPMI off AND Restore Configuration
165
166 @{data_vlan_id}= Create List ${interface} ${vlan_id}
167 ${data}= Create Dictionary data=@{data_vlan_id}
168 ${resp}= OpenBMC Post Request ${vlan_resource} data=${data}
169
170 Create VLAN Via IPMI ${vlan_id}
171
172 ${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
173 Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id}']
174
Sushma M M08adaa02020-01-23 03:25:19 -0600175
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500176*** Keywords ***
177
Rahul Maheshwaria7c39032019-09-18 02:15:01 -0500178Get Physical Network Interface Count
179 [Documentation] Return valid physical network interfaces count.
180 # Example:
181 # link/ether 22:3a:7f:70:92:cb brd ff:ff:ff:ff:ff:ff
182 # link/ether 0e:8e:0d:6b:e9:e4 brd ff:ff:ff:ff:ff:ff
183
184 ${mac_entry_list}= Get BMC MAC Address List
185 ${mac_unique_list}= Remove Duplicates ${mac_entry_list}
186 ${physical_interface_count}= Get Length ${mac_unique_list}
187
188 [Return] ${physical_interface_count}
189
190
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500191Set IPMI Inband Network Configuration
192 [Documentation] Run sequence of standard IPMI command in-band and set
193 ... the IP configuration.
194 [Arguments] ${ip} ${netmask} ${gateway} ${login}=${1}
195
196 # Description of argument(s):
197 # ip The IP address to be set using ipmitool-inband.
198 # netmask The Netmask to be set using ipmitool-inband.
199 # gateway The Gateway address to be set using ipmitool-inband.
200
201 Run Inband IPMI Standard Command
Tony Leec762a7a2019-12-30 17:12:50 +0800202 ... lan set ${CHANNEL_NUMBER} ipsrc static login_host=${login}
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500203 Run Inband IPMI Standard Command
Tony Leec762a7a2019-12-30 17:12:50 +0800204 ... lan set ${CHANNEL_NUMBER} ipaddr ${ip} login_host=${0}
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500205 Run Inband IPMI Standard Command
Tony Leec762a7a2019-12-30 17:12:50 +0800206 ... lan set ${CHANNEL_NUMBER} netmask ${netmask} login_host=${0}
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500207 Run Inband IPMI Standard Command
Tony Leec762a7a2019-12-30 17:12:50 +0800208 ... lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway} login_host=${0}
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500209
210
211Restore Configuration
212 [Documentation] Restore the configuration to its pre-test state
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500213 ${length}= Get Length ${initial_lan_config}
214 Return From Keyword If ${length} == ${0}
215
Anvesh Kumar Rayankulaada25db2020-02-19 01:29:17 -0600216 Set IPMI Inband Network Configuration ${network_configurations[0]['Address']}
217 ... ${network_configurations[0]['SubnetMask']}
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500218 ... ${initial_lan_config['Default Gateway IP']} login=${0}
Rahul Maheshwaridf04d922019-07-30 12:15:36 -0500219
Tony Leeea741302019-11-08 11:01:58 +0800220
221Verify Channel Info
222 [Documentation] Verify the channel info.
223 [Arguments] ${channel_number} ${network_parameter} ${active_channel_config}
224
225 Run Keyword If '${network_parameter}' == 'IPv4StaticAddresses'
226 ... Verify IPv4 Static Address ${channel_number} ${active_channel_config}
227 ... ELSE IF '${network_parameter}' == 'MACAddress'
228 ... Verify MAC Address ${channel_number} ${active_channel_config}
229
230
231Verify IPv4 Static Address
232 [Documentation] Verify the IPv4 Static Address.
233 [Arguments] ${channel_number} ${active_channel_config}
234
235 ${lan_print_ipmi}= Get LAN Print Dict ${channel_number}
236 ${ipv4_static_addresses}= Redfish.Get Attribute
237 ... ${REDFISH_NW_ETH_IFACE}${active_channel_config['${channel_number}']['name']} IPv4StaticAddresses
238 ${redfish_ips}= Nested Get Address ${ipv4_static_addresses}
239 Rprint Vars lan_print_ipmi ipv4_static_addresses redfish_ips
240 Valid Value lan_print_ipmi['IP Address'] ${redfish_ips}
241
242
243Verify MAC Address
244 [Documentation] Verify the MAC Address.
245 [Arguments] ${channel_number} ${active_channel_config}
246
247 ${lan_print_ipmi}= Get LAN Print Dict ${channel_number}
248 ${redfish_mac_address}= Redfish.Get Attribute
249 ... ${REDFISH_NW_ETH_IFACE}${active_channel_config['${channel_number}']['name']} MACAddress
250 Rprint Vars lan_print_ipmi redfish_mac_address
251 Valid Value lan_print_ipmi['MAC Address'] ['${redfish_mac_address}']
Anvesh Kumar Rayankulaada25db2020-02-19 01:29:17 -0600252
253
254Create VLAN Via IPMI
255 [Arguments] ${vlan_id} ${channel_number}=${CHANNEL_NUMBER}
256
257 # Description of argument(s):
258 # vlan_id The VLAN ID (e.g. '10').
259
260 Run Inband IPMI Standard Command
261 ... lan set ${channel_number} vlan id ${vlan_id} login_host=${0}
262
263
264Suite Setup Execution
265 [Documentation] Suite Setup Execution.
266
267 Redfish.Login
268
269 Run Inband IPMI Standard Command
270 ... lan set ${CHANNEL_NUMBER} ipsrc static login_host=${1}
271
272 @{network_configurations}= Get Network Configuration
273 Set Suite Variable @{network_configurations}
274
275 ${initial_lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
276 Set Suite Variable ${initial_lan_config}