Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Module to test IPMI network functionality. |
| 4 | Resource ../lib/ipmi_client.robot |
| 5 | Resource ../lib/openbmc_ffdc.robot |
Rahul Maheshwari | a7c3903 | 2019-09-18 02:15:01 -0500 | [diff] [blame] | 6 | Resource ../lib/bmc_network_utils.robot |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 7 | Library ../lib/ipmi_utils.py |
| 8 | Library ../lib/gen_robot_valid.py |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 9 | Library ../lib/var_funcs.py |
| 10 | Library ../lib/bmc_network_utils.py |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 11 | |
Anvesh Kumar Rayankula | ada25db | 2020-02-19 01:29:17 -0600 | [diff] [blame] | 12 | Suite Setup Suite Setup Execution |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 13 | Test Setup Printn |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 14 | Test Teardown FFDC On Test Case Fail |
| 15 | |
| 16 | Force Tags IPMI_Network |
| 17 | |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 18 | |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 19 | *** Variables *** |
Anvesh Kumar Rayankula | ada25db | 2020-02-19 01:29:17 -0600 | [diff] [blame] | 20 | ${vlan_id} ${10} |
| 21 | @{vlan_ids} ${20} ${30} |
| 22 | ${interface} eth0 |
| 23 | ${ip} 10.0.0.1 |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 24 | ${initial_lan_config} &{EMPTY} |
Anvesh Kumar Rayankula | ada25db | 2020-02-19 01:29:17 -0600 | [diff] [blame] | 25 | ${vlan_resource} ${NETWORK_MANAGER}action/VLAN |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 26 | |
| 27 | *** Test Cases *** |
| 28 | |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 29 | Retrieve 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 Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 33 | ${active_channel_config}= Get Active Channel Config |
Rahul Maheshwari | 3a1d991 | 2020-02-25 03:13:14 -0600 | [diff] [blame] | 34 | FOR ${channel_number} IN @{active_channel_config.keys()} |
| 35 | Verify Channel Info ${channel_number} IPv4StaticAddresses ${active_channel_config} |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 36 | END |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 37 | |
Rahul Maheshwari | 3a1d991 | 2020-02-25 03:13:14 -0600 | [diff] [blame] | 38 | |
Prashanth Katti | 9bebccb | 2019-09-25 06:38:04 -0500 | [diff] [blame] | 39 | Retrieve 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 Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 42 | |
| 43 | ${lan_print_ipmi}= Get LAN Print Dict |
| 44 | |
Prashanth Katti | 9bebccb | 2019-09-25 06:38:04 -0500 | [diff] [blame] | 45 | Verify Gateway On BMC ${lan_print_ipmi['Default Gateway IP']} |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 46 | |
| 47 | |
| 48 | Retrieve 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 Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 52 | ${active_channel_config}= Get Active Channel Config |
Rahul Maheshwari | 3a1d991 | 2020-02-25 03:13:14 -0600 | [diff] [blame] | 53 | FOR ${channel_number} IN @{active_channel_config.keys()} |
| 54 | Verify Channel Info ${channel_number} MACAddress ${active_channel_config} |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 55 | END |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 56 | |
| 57 | |
Rahul Maheshwari | a7c3903 | 2019-09-18 02:15:01 -0500 | [diff] [blame] | 58 | Test 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 Maheshwari | 3a1d991 | 2020-02-25 03:13:14 -0600 | [diff] [blame] | 65 | FOR ${channel_number} IN RANGE 1 ${channel_count} |
| 66 | Run IPMI Standard Command lan print ${channel_number} |
| 67 | END |
Rahul Maheshwari | a7c3903 | 2019-09-18 02:15:01 -0500 | [diff] [blame] | 68 | |
| 69 | |
| 70 | Test 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 Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 90 | Verify 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 Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 96 | |
| 97 | Set IPMI Inband Network Configuration 10.10.10.10 255.255.255.0 10.10.10.10 |
| 98 | Sleep 10 |
| 99 | |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 100 | ${lan_print_output}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 101 | 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 M | 08adaa0 | 2020-01-23 03:25:19 -0600 | [diff] [blame] | 106 | Get 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 Lee | 5a20014 | 2020-02-11 13:33:05 +0800 | [diff] [blame] | 110 | ${active_channel_config}= Get Active Channel Config |
| 111 | ${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} |
| 112 | |
| 113 | ${ipv4_addresses}= Redfish.Get Attribute |
George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 114 | ... /redfish/v1/Managers/bmc/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} |
| 115 | ... IPv4Addresses |
Tony Lee | 5a20014 | 2020-02-11 13:33:05 +0800 | [diff] [blame] | 116 | |
| 117 | FOR ${ipv4_address} IN @{ipv4_addresses} |
Rahul Maheshwari | 3a1d991 | 2020-02-25 03:13:14 -0600 | [diff] [blame] | 118 | ${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 Lee | 5a20014 | 2020-02-11 13:33:05 +0800 | [diff] [blame] | 122 | END |
| 123 | |
Tony Lee | 4b7fd15 | 2020-02-24 14:10:33 +0800 | [diff] [blame] | 124 | Valid Value lan_config['IP Address Source'] ['${ip_address_source}'] |
Sushma M M | 08adaa0 | 2020-01-23 03:25:19 -0600 | [diff] [blame] | 125 | |
Anvesh Kumar Rayankula | ada25db | 2020-02-19 01:29:17 -0600 | [diff] [blame] | 126 | Disable 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 | |
| 144 | Configure 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 | |
| 160 | Create 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 M | 08adaa0 | 2020-01-23 03:25:19 -0600 | [diff] [blame] | 175 | |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 176 | *** Keywords *** |
| 177 | |
Rahul Maheshwari | a7c3903 | 2019-09-18 02:15:01 -0500 | [diff] [blame] | 178 | Get 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 Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 191 | Set 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 Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 202 | ... lan set ${CHANNEL_NUMBER} ipsrc static login_host=${login} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 203 | Run Inband IPMI Standard Command |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 204 | ... lan set ${CHANNEL_NUMBER} ipaddr ${ip} login_host=${0} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 205 | Run Inband IPMI Standard Command |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 206 | ... lan set ${CHANNEL_NUMBER} netmask ${netmask} login_host=${0} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 207 | Run Inband IPMI Standard Command |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 208 | ... lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway} login_host=${0} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 209 | |
| 210 | |
| 211 | Restore Configuration |
| 212 | [Documentation] Restore the configuration to its pre-test state |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 213 | ${length}= Get Length ${initial_lan_config} |
| 214 | Return From Keyword If ${length} == ${0} |
| 215 | |
Anvesh Kumar Rayankula | ada25db | 2020-02-19 01:29:17 -0600 | [diff] [blame] | 216 | Set IPMI Inband Network Configuration ${network_configurations[0]['Address']} |
| 217 | ... ${network_configurations[0]['SubnetMask']} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 218 | ... ${initial_lan_config['Default Gateway IP']} login=${0} |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 219 | |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 220 | |
| 221 | Verify 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 | |
| 231 | Verify 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 | |
| 243 | Verify 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 Rayankula | ada25db | 2020-02-19 01:29:17 -0600 | [diff] [blame] | 252 | |
| 253 | |
| 254 | Create VLAN Via IPMI |
George Keishing | 08512df | 2020-03-03 21:58:41 -0600 | [diff] [blame] | 255 | [Documentation] Create VLAN via inband IPMI command. |
Anvesh Kumar Rayankula | ada25db | 2020-02-19 01:29:17 -0600 | [diff] [blame] | 256 | [Arguments] ${vlan_id} ${channel_number}=${CHANNEL_NUMBER} |
| 257 | |
| 258 | # Description of argument(s): |
| 259 | # vlan_id The VLAN ID (e.g. '10'). |
| 260 | |
| 261 | Run Inband IPMI Standard Command |
| 262 | ... lan set ${channel_number} vlan id ${vlan_id} login_host=${0} |
| 263 | |
| 264 | |
| 265 | Suite Setup Execution |
| 266 | [Documentation] Suite Setup Execution. |
| 267 | |
| 268 | Redfish.Login |
| 269 | |
| 270 | Run Inband IPMI Standard Command |
| 271 | ... lan set ${CHANNEL_NUMBER} ipsrc static login_host=${1} |
| 272 | |
| 273 | @{network_configurations}= Get Network Configuration |
| 274 | Set Suite Variable @{network_configurations} |
| 275 | |
| 276 | ${initial_lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband |
| 277 | Set Suite Variable ${initial_lan_config} |