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 | |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 12 | Suite Setup Redfish.Login |
| 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 *** |
| 20 | |
| 21 | ${initial_lan_config} &{EMPTY} |
| 22 | |
| 23 | |
| 24 | *** Test Cases *** |
| 25 | |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 26 | Retrieve IP Address Via IPMI And Verify Using Redfish |
| 27 | [Documentation] Retrieve IP address using IPMI and verify using Redfish. |
| 28 | [Tags] Retrieve_IP_Address_Via_IPMI_And_Verify_Using_Redish |
| 29 | |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 30 | ${active_channel_config}= Get Active Channel Config |
| 31 | :FOR ${channel_number} IN @{active_channel_config.keys()} |
| 32 | \ Verify Channel Info ${channel_number} IPv4StaticAddresses ${active_channel_config} |
| 33 | END |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 34 | |
Prashanth Katti | 9bebccb | 2019-09-25 06:38:04 -0500 | [diff] [blame] | 35 | Retrieve Default Gateway Via IPMI And Verify |
| 36 | [Documentation] Retrieve default gateway via IPMI and verify it's existence on the BMC. |
| 37 | [Tags] Retrieve_Default_Gateway_Via_IPMI_And_Verify |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 38 | |
| 39 | ${lan_print_ipmi}= Get LAN Print Dict |
| 40 | |
Prashanth Katti | 9bebccb | 2019-09-25 06:38:04 -0500 | [diff] [blame] | 41 | Verify Gateway On BMC ${lan_print_ipmi['Default Gateway IP']} |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 42 | |
| 43 | |
| 44 | Retrieve MAC Address Via IPMI And Verify Using Redfish |
| 45 | [Documentation] Retrieve MAC address via IPMI and verify using Redfish. |
| 46 | [Tags] Retrieve_MAC_Address_Via_IPMI_And_Verify_Using_Redfish |
| 47 | |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 48 | ${active_channel_config}= Get Active Channel Config |
| 49 | :FOR ${channel_number} IN @{active_channel_config.keys()} |
| 50 | \ Verify Channel Info ${channel_number} MACAddress ${active_channel_config} |
| 51 | END |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 52 | |
| 53 | |
Rahul Maheshwari | a7c3903 | 2019-09-18 02:15:01 -0500 | [diff] [blame] | 54 | Test Valid IPMI Channels Supported |
| 55 | [Documentation] Verify IPMI channels supported on a given system. |
| 56 | [Tags] Test_Valid_IPMI_Channels_Supported |
| 57 | |
| 58 | ${channel_count}= Get Physical Network Interface Count |
| 59 | |
| 60 | # Note: IPMI network channel logically starts from 1. |
| 61 | :FOR ${channel_number} IN RANGE 1 ${channel_count} |
| 62 | \ Run IPMI Standard Command lan print ${channel_number} |
| 63 | |
| 64 | |
| 65 | Test Invalid IPMI Channel Response |
| 66 | [Documentation] Verify invalid IPMI channels supported response. |
| 67 | [Tags] Test_Invalid_IPMI_Channel_Response |
| 68 | |
| 69 | ${channel_count}= Get Physical Network Interface Count |
| 70 | |
| 71 | # To target invalid channel, increment count. |
| 72 | ${channel_number}= Evaluate ${channel_count} + 1 |
| 73 | |
| 74 | # Example of invalid channel: |
| 75 | # $ ipmitool -I lanplus -H xx.xx.xx.xx -P password lan print 3 |
| 76 | # Get Channel Info command failed: Parameter out of range |
| 77 | # Invalid channel: 3 |
| 78 | |
| 79 | ${stdout}= Run External IPMI Standard Command |
| 80 | ... lan print ${channel_number} fail_on_err=${0} |
| 81 | Should Contain ${stdout} Invalid channel |
| 82 | ... msg=IPMI channel ${channel_number} is invalid but seen working. |
| 83 | |
| 84 | |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 85 | Verify IPMI Inband Network Configuration |
| 86 | [Documentation] Verify BMC network configuration via inband IPMI. |
| 87 | [Tags] Verify_IPMI_Inband_Network_Configuration |
| 88 | [Teardown] Run Keywords Restore Configuration AND FFDC On Test Case Fail |
| 89 | |
| 90 | Redfish Power On |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 91 | ${initial_lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 92 | Set Suite Variable ${initial_lan_config} |
| 93 | |
| 94 | Set IPMI Inband Network Configuration 10.10.10.10 255.255.255.0 10.10.10.10 |
| 95 | Sleep 10 |
| 96 | |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 97 | ${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] | 98 | Valid Value lan_print_output['IP Address'] ["10.10.10.10"] |
| 99 | Valid Value lan_print_output['Subnet Mask'] ["255.255.255.0"] |
| 100 | Valid Value lan_print_output['Default Gateway IP'] ["10.10.10.10"] |
| 101 | |
| 102 | |
Sushma M M | 08adaa0 | 2020-01-23 03:25:19 -0600 | [diff] [blame] | 103 | Get IP Address Source And Verify Using Redfish |
| 104 | [Documentation] Get IP address source and verify it using Redfish. |
| 105 | [Tags] Get_IP_Address_Source_And_Verify_Using_Redfish |
| 106 | |
Tony Lee | 5a20014 | 2020-02-11 13:33:05 +0800 | [diff] [blame] | 107 | ${active_channel_config}= Get Active Channel Config |
| 108 | ${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} |
| 109 | |
| 110 | ${ipv4_addresses}= Redfish.Get Attribute |
George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 111 | ... /redfish/v1/Managers/bmc/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} |
| 112 | ... IPv4Addresses |
Tony Lee | 5a20014 | 2020-02-11 13:33:05 +0800 | [diff] [blame] | 113 | |
| 114 | FOR ${ipv4_address} IN @{ipv4_addresses} |
George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 115 | ${ip_address_source}= |
| 116 | ... Set Variable if '${ipv4_address['Address']}' == '${lan_config['IP Address']}' |
| 117 | ... ${ipv4_address['AddressOrigin']} Address |
Tony Lee | 5a20014 | 2020-02-11 13:33:05 +0800 | [diff] [blame] | 118 | Exit For Loop IF "${ip_address_source}" != 'None' |
| 119 | END |
| 120 | |
Sushma M M | 08adaa0 | 2020-01-23 03:25:19 -0600 | [diff] [blame] | 121 | Valid Value lan_config['IP Address Source'] [${ip_address_source}] |
| 122 | |
| 123 | |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 124 | *** Keywords *** |
| 125 | |
Rahul Maheshwari | a7c3903 | 2019-09-18 02:15:01 -0500 | [diff] [blame] | 126 | Get Physical Network Interface Count |
| 127 | [Documentation] Return valid physical network interfaces count. |
| 128 | # Example: |
| 129 | # link/ether 22:3a:7f:70:92:cb brd ff:ff:ff:ff:ff:ff |
| 130 | # link/ether 0e:8e:0d:6b:e9:e4 brd ff:ff:ff:ff:ff:ff |
| 131 | |
| 132 | ${mac_entry_list}= Get BMC MAC Address List |
| 133 | ${mac_unique_list}= Remove Duplicates ${mac_entry_list} |
| 134 | ${physical_interface_count}= Get Length ${mac_unique_list} |
| 135 | |
| 136 | [Return] ${physical_interface_count} |
| 137 | |
| 138 | |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 139 | Set IPMI Inband Network Configuration |
| 140 | [Documentation] Run sequence of standard IPMI command in-band and set |
| 141 | ... the IP configuration. |
| 142 | [Arguments] ${ip} ${netmask} ${gateway} ${login}=${1} |
| 143 | |
| 144 | # Description of argument(s): |
| 145 | # ip The IP address to be set using ipmitool-inband. |
| 146 | # netmask The Netmask to be set using ipmitool-inband. |
| 147 | # gateway The Gateway address to be set using ipmitool-inband. |
| 148 | |
| 149 | Run Inband IPMI Standard Command |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 150 | ... lan set ${CHANNEL_NUMBER} ipsrc static login_host=${login} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 151 | Run Inband IPMI Standard Command |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 152 | ... lan set ${CHANNEL_NUMBER} ipaddr ${ip} login_host=${0} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 153 | Run Inband IPMI Standard Command |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 154 | ... lan set ${CHANNEL_NUMBER} netmask ${netmask} login_host=${0} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 155 | Run Inband IPMI Standard Command |
Tony Lee | c762a7a | 2019-12-30 17:12:50 +0800 | [diff] [blame] | 156 | ... lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway} login_host=${0} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 157 | |
| 158 | |
| 159 | Restore Configuration |
| 160 | [Documentation] Restore the configuration to its pre-test state |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 161 | ${length}= Get Length ${initial_lan_config} |
| 162 | Return From Keyword If ${length} == ${0} |
| 163 | |
| 164 | Set IPMI Inband Network Configuration ${initial_lan_config['IP Address']} |
| 165 | ... ${initial_lan_config['Subnet Mask']} |
| 166 | ... ${initial_lan_config['Default Gateway IP']} login=${0} |
Rahul Maheshwari | df04d92 | 2019-07-30 12:15:36 -0500 | [diff] [blame] | 167 | |
Tony Lee | ea74130 | 2019-11-08 11:01:58 +0800 | [diff] [blame] | 168 | |
| 169 | Verify Channel Info |
| 170 | [Documentation] Verify the channel info. |
| 171 | [Arguments] ${channel_number} ${network_parameter} ${active_channel_config} |
| 172 | |
| 173 | Run Keyword If '${network_parameter}' == 'IPv4StaticAddresses' |
| 174 | ... Verify IPv4 Static Address ${channel_number} ${active_channel_config} |
| 175 | ... ELSE IF '${network_parameter}' == 'MACAddress' |
| 176 | ... Verify MAC Address ${channel_number} ${active_channel_config} |
| 177 | |
| 178 | |
| 179 | Verify IPv4 Static Address |
| 180 | [Documentation] Verify the IPv4 Static Address. |
| 181 | [Arguments] ${channel_number} ${active_channel_config} |
| 182 | |
| 183 | ${lan_print_ipmi}= Get LAN Print Dict ${channel_number} |
| 184 | ${ipv4_static_addresses}= Redfish.Get Attribute |
| 185 | ... ${REDFISH_NW_ETH_IFACE}${active_channel_config['${channel_number}']['name']} IPv4StaticAddresses |
| 186 | ${redfish_ips}= Nested Get Address ${ipv4_static_addresses} |
| 187 | Rprint Vars lan_print_ipmi ipv4_static_addresses redfish_ips |
| 188 | Valid Value lan_print_ipmi['IP Address'] ${redfish_ips} |
| 189 | |
| 190 | |
| 191 | Verify MAC Address |
| 192 | [Documentation] Verify the MAC Address. |
| 193 | [Arguments] ${channel_number} ${active_channel_config} |
| 194 | |
| 195 | ${lan_print_ipmi}= Get LAN Print Dict ${channel_number} |
| 196 | ${redfish_mac_address}= Redfish.Get Attribute |
| 197 | ... ${REDFISH_NW_ETH_IFACE}${active_channel_config['${channel_number}']['name']} MACAddress |
| 198 | Rprint Vars lan_print_ipmi redfish_mac_address |
| 199 | Valid Value lan_print_ipmi['MAC Address'] ['${redfish_mac_address}'] |