| Rahul Maheshwari | fdd5ff6 | 2017-08-01 04:15:03 -0500 | [diff] [blame] | 1 | *** Settings *** | 
 | 2 | Documentation       This suite is for testing general IPMI functions. | 
 | 3 |  | 
 | 4 | Resource            ../../lib/ipmi_client.robot | 
 | 5 | Resource            ../../lib/openbmc_ffdc.robot | 
| George Keishing | 0825a11 | 2018-03-30 10:48:07 -0500 | [diff] [blame] | 6 | Resource            ../../lib/boot_utils.robot | 
| George Keishing | 78ce8dc | 2018-03-30 11:49:06 -0500 | [diff] [blame] | 7 | Resource            ../../lib/utils.robot | 
| Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 8 | Resource            ../../lib/bmc_network_utils.robot | 
| George Keishing | d627380 | 2018-09-07 07:06:53 -0500 | [diff] [blame] | 9 | Resource            ../../lib/logging_utils.robot | 
| George Keishing | 78ce8dc | 2018-03-30 11:49:06 -0500 | [diff] [blame] | 10 | Library             ../../lib/ipmi_utils.py | 
| George Keishing | 0825a11 | 2018-03-30 10:48:07 -0500 | [diff] [blame] | 11 | Variables           ../../data/ipmi_raw_cmd_table.py | 
| Rahul Maheshwari | df6f05d | 2018-09-04 03:48:37 -0500 | [diff] [blame] | 12 | Library             ../../lib/gen_misc.py | 
| Tony Lee | 9bca44b | 2019-12-13 09:34:26 +0800 | [diff] [blame] | 13 | Library             ../../lib/gen_robot_valid.py | 
| Rahul Maheshwari | fdd5ff6 | 2017-08-01 04:15:03 -0500 | [diff] [blame] | 14 |  | 
| Michael Walsh | c9eb34e | 2019-01-23 11:08:43 -0600 | [diff] [blame] | 15 | Test Setup          Log to Console  ${EMPTY} | 
| Rahul Maheshwari | fdd5ff6 | 2017-08-01 04:15:03 -0500 | [diff] [blame] | 16 | Test Teardown       FFDC On Test Case Fail | 
 | 17 |  | 
 | 18 | *** Variables *** | 
 | 19 |  | 
| Rahul Maheshwari | 901dcde | 2018-02-06 03:14:31 -0600 | [diff] [blame] | 20 | ${allowed_temp_diff}=  ${1} | 
| Rahul Maheshwari | 615da15 | 2018-02-13 23:53:36 -0600 | [diff] [blame] | 21 | ${allowed_power_diff}=  ${10} | 
| Sweta Potthuri | 5c6c72e | 2018-01-23 05:48:35 -0600 | [diff] [blame] | 22 |  | 
| Rahul Maheshwari | fdd5ff6 | 2017-08-01 04:15:03 -0500 | [diff] [blame] | 23 | *** Test Cases *** | 
 | 24 |  | 
| Sweta Potthuri | 7d3af3c | 2018-01-29 03:07:07 -0600 | [diff] [blame] | 25 | Test Watchdog Reset Via IPMI And Verify Using REST | 
 | 26 |     [Documentation]  Test watchdog reset via IPMI and verify using REST. | 
 | 27 |     [Tags]  Test_Watchdog_Reset_Via_IPMI_And_Verify_Using_REST | 
 | 28 |  | 
 | 29 |     Initiate Host Boot | 
 | 30 |  | 
 | 31 |     Set Watchdog Enabled Using REST  ${1} | 
 | 32 |  | 
 | 33 |     Watchdog Object Should Exist | 
 | 34 |  | 
 | 35 |     # Resetting the watchdog via IPMI. | 
 | 36 |     Run IPMI Standard Command  mc watchdog reset | 
 | 37 |  | 
 | 38 |     # Verify the watchdog is reset using REST after an interval of 1000ms. | 
 | 39 |     Sleep  1000ms | 
 | 40 |     ${watchdog_time_left}= | 
 | 41 |     ...  Read Attribute  ${HOST_WATCHDOG_URI}  TimeRemaining | 
 | 42 |     Should Be True | 
 | 43 |     ...  ${watchdog_time_left}<${1200000} and ${watchdog_time_left}>${2000} | 
 | 44 |     ...  msg=Watchdog timer didn't reset. | 
 | 45 |  | 
| Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 46 |  | 
| Sweta Potthuri | 7d3af3c | 2018-01-29 03:07:07 -0600 | [diff] [blame] | 47 | Test Watchdog Off Via IPMI And Verify Using REST | 
 | 48 |     [Documentation]  Test watchdog off via IPMI and verify using REST. | 
 | 49 |     [Tags]  Test_Watchdog_Off_Via_IPMI_And_Verify_Using_REST | 
 | 50 |  | 
 | 51 |     Initiate Host Boot | 
 | 52 |  | 
 | 53 |     Set Watchdog Enabled Using REST  ${1} | 
 | 54 |  | 
 | 55 |     Watchdog Object Should Exist | 
 | 56 |  | 
 | 57 |     # Turn off the watchdog via IPMI. | 
 | 58 |     Run IPMI Standard Command  mc watchdog off | 
 | 59 |  | 
 | 60 |     # Verify the watchdog is off using REST | 
 | 61 |     ${watchdog_state}=  Read Attribute  ${HOST_WATCHDOG_URI}  Enabled | 
 | 62 |     Should Be Equal  ${watchdog_state}  ${0} | 
 | 63 |     ...  msg=msg=Verification failed for watchdog off check. | 
| Rahul Maheshwari | 901dcde | 2018-02-06 03:14:31 -0600 | [diff] [blame] | 64 |  | 
 | 65 |  | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 66 | Verify Get Device ID | 
 | 67 |     [Documentation]  Verify get device ID command output. | 
 | 68 |     [Tags]  Verify_Get_Device_ID | 
 | 69 |  | 
 | 70 |     # Example of get device ID command output: | 
 | 71 |     # Device ID                 : 0 | 
 | 72 |     # Device Revision           : 0 | 
 | 73 |     # Firmware Revision         : 2.01 | 
 | 74 |     # IPMI Version              : 2.0 | 
 | 75 |     # Manufacturer ID           : 42817 | 
 | 76 |     # Manufacturer Name         : Unknown (0xA741) | 
 | 77 |     # Product ID                : 16975 (0x424f) | 
 | 78 |     # Product Name              : Unknown (0x424F) | 
 | 79 |     # Device Available          : yes | 
 | 80 |     # Provides Device SDRs      : yes | 
 | 81 |     # Additional Device Support : | 
 | 82 |     #     Sensor Device | 
 | 83 |     #     SEL Device | 
 | 84 |     #     FRU Inventory Device | 
 | 85 |     #     Chassis Device | 
 | 86 |     # Aux Firmware Rev Info     : | 
| George Keishing | 3511a3f | 2018-04-19 10:38:30 -0500 | [diff] [blame] | 87 |     #     0x04 | 
 | 88 |     #     0x38 | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 89 |     #     0x00 | 
| George Keishing | 3511a3f | 2018-04-19 10:38:30 -0500 | [diff] [blame] | 90 |     #     0x03 | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 91 |  | 
| Tony Lee | 9bca44b | 2019-12-13 09:34:26 +0800 | [diff] [blame] | 92 |     # Verify Manufacturer and Product IDs, etc. directly from json file. | 
 | 93 |     ${device_id_config}=  Get Device Id Config | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 94 |     ${mc_info}=  Get MC Info | 
 | 95 |  | 
| Tony Lee | 9bca44b | 2019-12-13 09:34:26 +0800 | [diff] [blame] | 96 |     Rprint Vars  device_id_config  mc_info | 
 | 97 |     Valid Value  ${mc_info['device_id']}  [${device_id_config['id']}] | 
 | 98 |     Valid Value  ${mc_info['device_revision']}  [${device_id_config['device_revision']}] | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 99 |  | 
| Rahul Maheshwari | bb9e257 | 2018-04-02 05:24:37 -0500 | [diff] [blame] | 100 |     # Get firmware revision from mc info command output i.e. 2.01 | 
 | 101 |     ${ipmi_fw_major_version}  ${ipmi_fw_minor_version}= | 
 | 102 |     ...  Split String  ${mc_info['firmware_revision']}  . | 
 | 103 |     # Convert minor firmware version from BCD format to integer. i.e. 01 to 1 | 
 | 104 |     ${ipmi_fw_minor_version}=  Convert To Integer  ${ipmi_fw_minor_version} | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 105 |  | 
| George Keishing | e0a8128 | 2018-06-08 10:02:30 -0500 | [diff] [blame] | 106 |     # Get BMC version from BMC CLI i.e. 2.2 from "v2.2-253-g00050f1" | 
| George Keishing | 3511a3f | 2018-04-19 10:38:30 -0500 | [diff] [blame] | 107 |     ${bmc_version_full}=  Get BMC Version | 
| Rahul Maheshwari | bb9e257 | 2018-04-02 05:24:37 -0500 | [diff] [blame] | 108 |     ${bmc_version}= | 
| George Keishing | 3511a3f | 2018-04-19 10:38:30 -0500 | [diff] [blame] | 109 |     ...  Remove String Using Regexp  ${bmc_version_full}  ^[^0-9]+  [^0-9\.].* | 
| Rahul Maheshwari | bb9e257 | 2018-04-02 05:24:37 -0500 | [diff] [blame] | 110 |  | 
 | 111 |     # Get major and minor version from BMC version i.e. 2 and 1 from 2.1 | 
| George Keishing | c95e998 | 2019-01-14 09:27:45 -0600 | [diff] [blame] | 112 |     @{major_minor_version}=  Split String  ${bmc_version}  . | 
| Rahul Maheshwari | bb9e257 | 2018-04-02 05:24:37 -0500 | [diff] [blame] | 113 |  | 
| George Keishing | c95e998 | 2019-01-14 09:27:45 -0600 | [diff] [blame] | 114 |     Should Be Equal As Strings  ${ipmi_fw_major_version}  ${major_minor_version[0]} | 
| George Keishing | 2ee2f00 | 2019-02-16 09:36:02 -0600 | [diff] [blame] | 115 |     ...  msg=Major version mismatch. | 
| George Keishing | c95e998 | 2019-01-14 09:27:45 -0600 | [diff] [blame] | 116 |     Should Be Equal As Strings  ${ipmi_fw_minor_version}  ${major_minor_version[1]} | 
| George Keishing | 2ee2f00 | 2019-02-16 09:36:02 -0600 | [diff] [blame] | 117 |     ...  msg=Minor version mismatch. | 
| Rahul Maheshwari | bb9e257 | 2018-04-02 05:24:37 -0500 | [diff] [blame] | 118 |  | 
| Tony Lee | 9bca44b | 2019-12-13 09:34:26 +0800 | [diff] [blame] | 119 |     Valid Value  mc_info['ipmi_version']  ['2.0'] | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 120 |  | 
| Tony Lee | 9bca44b | 2019-12-13 09:34:26 +0800 | [diff] [blame] | 121 |     Valid Value  ${mc_info['manufacturer_id']}  [${device_id_config['manuf_id']}] | 
 | 122 |     ${product_id_hex} =  Convert To Hex  ${device_id_config['prod_id']}  lowercase=True | 
 | 123 |     Valid Value  mc_info['product_id']  ['${device_id_config['prod_id']} (0x${product_id_hex})'] | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 124 |  | 
| Tony Lee | 9bca44b | 2019-12-13 09:34:26 +0800 | [diff] [blame] | 125 |     Valid Value  mc_info['device_available']  ['yes'] | 
 | 126 |     Valid Value  mc_info['provides_device_sdrs']  ['yes'] | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 127 |     Should Contain  ${mc_info['additional_device_support']}  Sensor Device | 
 | 128 |     Should Contain  ${mc_info['additional_device_support']}  SEL Device | 
 | 129 |     Should Contain | 
 | 130 |     ...  ${mc_info['additional_device_support']}  FRU Inventory Device | 
 | 131 |     Should Contain  ${mc_info['additional_device_support']}  Chassis Device | 
| George Keishing | b746d3f | 2018-04-19 10:53:10 -0500 | [diff] [blame] | 132 |  | 
| George Keishing | 3511a3f | 2018-04-19 10:38:30 -0500 | [diff] [blame] | 133 |     # Auxiliary revision data verification. | 
 | 134 |     ${aux_version}=  Get Aux Version  ${bmc_version_full} | 
 | 135 |  | 
 | 136 |     # From aux_firmware_rev_info field ['0x04', '0x38', '0x00', '0x03'] | 
 | 137 |     ${bmc_aux_version}=  Catenate | 
 | 138 |     ...  SEPARATOR= | 
 | 139 |     ...  ${mc_info['aux_firmware_rev_info'][0][2:]} | 
 | 140 |     ...  ${mc_info['aux_firmware_rev_info'][1][2:]} | 
 | 141 |     ...  ${mc_info['aux_firmware_rev_info'][2][2:]} | 
 | 142 |     ...  ${mc_info['aux_firmware_rev_info'][3][2:]} | 
 | 143 |  | 
 | 144 |     Should Be Equal As Integers | 
 | 145 |     ...  ${bmc_aux_version}  ${aux_version} | 
 | 146 |     ...  msg=BMC aux version ${bmc_aux_version} does not match expected value of ${aux_version}. | 
| Rahul Maheshwari | fe8639b | 2018-02-05 22:42:24 -0600 | [diff] [blame] | 147 |  | 
 | 148 |  | 
| George Keishing | e85113a | 2019-06-07 08:21:51 -0500 | [diff] [blame] | 149 | Test IPMI Restriction Mode | 
 | 150 |     [Documentation]  Set restricition mode via REST and verify IPMI operation. | 
 | 151 |     [Tags]  Test_IPMI_Restriction_Mode | 
 | 152 |     # Forego normal test setup: | 
 | 153 |     [Setup]  No Operation | 
 | 154 |     [Teardown]  Run Keywords  FFDC On Test Case Fail  AND | 
 | 155 |     ...  Set IPMI Restriction Mode  xyz.openbmc_project.Control.Security.RestrictionMode.Modes.None | 
 | 156 |  | 
 | 157 |     # By default no IPMI operations are restricted. | 
 | 158 |     # /xyz/openbmc_project/control/host0/restriction_mode/attr/RestrictionMode | 
 | 159 |     # { | 
 | 160 |     #    "data": "xyz.openbmc_project.Control.Security.RestrictionMode.Modes.None", | 
 | 161 |     #    "message": "200 OK", | 
 | 162 |     #    "status": "ok" | 
 | 163 |     # } | 
 | 164 |  | 
 | 165 |     # Refer to: #openbmc/phosphor-host-ipmid/blob/master/host-ipmid-whitelist.conf | 
| Sushma M M | 8cd1d3e | 2020-07-13 02:14:30 -0500 | [diff] [blame] | 166 |     # Set the restriction mode to Allowed list IPMI commands only: | 
| George Keishing | e85113a | 2019-06-07 08:21:51 -0500 | [diff] [blame] | 167 |     # /xyz/openbmc_project/control/host0/restriction_mode/attr/RestrictionMode | 
 | 168 |     # { | 
 | 169 |     #    "data": "xyz.openbmc_project.Control.Security.RestrictionMode.Modes.Whitelist", | 
 | 170 |     #    "message": "200 OK", | 
 | 171 |     #    "status": "ok" | 
 | 172 |     # } | 
 | 173 |  | 
 | 174 |     Set IPMI Restriction Mode  xyz.openbmc_project.Control.Security.RestrictionMode.Modes.Whitelist | 
 | 175 |  | 
| Sushma M M | 8cd1d3e | 2020-07-13 02:14:30 -0500 | [diff] [blame] | 176 |     # Attempt allowed listed operation expecting success. | 
| George Keishing | e85113a | 2019-06-07 08:21:51 -0500 | [diff] [blame] | 177 |     IPMI Power On | 
 | 178 |  | 
| Sushma M M | 8cd1d3e | 2020-07-13 02:14:30 -0500 | [diff] [blame] | 179 |     # Attempt non allowed listed operation expecting failure. | 
| George Keishing | e85113a | 2019-06-07 08:21:51 -0500 | [diff] [blame] | 180 |     Run Keyword And Expect Error  *Insufficient privilege level* | 
| Rahul Maheshwari | 4019398 | 2019-10-11 00:55:08 -0500 | [diff] [blame] | 181 |     ...  Run Inband IPMI Standard Command  lan set 1 access on | 
| George Keishing | e85113a | 2019-06-07 08:21:51 -0500 | [diff] [blame] | 182 |  | 
 | 183 |  | 
| Rahul Maheshwari | fdd5ff6 | 2017-08-01 04:15:03 -0500 | [diff] [blame] | 184 | *** Keywords *** | 
| Sweta Potthuri | 5c6c72e | 2018-01-23 05:48:35 -0600 | [diff] [blame] | 185 |  | 
| Sweta Potthuri | 7d3af3c | 2018-01-29 03:07:07 -0600 | [diff] [blame] | 186 | Set Watchdog Enabled Using REST | 
 | 187 |     [Documentation]  Set watchdog Enabled field using REST. | 
 | 188 |     [Arguments]  ${value} | 
 | 189 |  | 
 | 190 |     # Description of argument(s): | 
 | 191 |     # value  Integer value (eg. "0-Disabled", "1-Enabled"). | 
 | 192 |  | 
 | 193 |     ${value_dict}=  Create Dictionary  data=${value} | 
| Steven Sombar | aaaab22 | 2018-12-19 13:16:23 -0600 | [diff] [blame] | 194 |     ${resp}=  OpenBMC Put Request  ${HOST_WATCHDOG_URI}attr/Enabled | 
| Sweta Potthuri | 7d3af3c | 2018-01-29 03:07:07 -0600 | [diff] [blame] | 195 |     ...  data=${value_dict} | 
| Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 196 |  | 
 | 197 |  | 
| Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 198 | Fetch Details From LAN Print | 
 | 199 |     [Documentation]  Fetch details from LAN print. | 
 | 200 |     [Arguments]  ${field_name} | 
 | 201 |  | 
 | 202 |     # Description of argument(s): | 
 | 203 |     # ${field_name}   Field name to be fetched from LAN print | 
 | 204 |     #                 (e.g. "MAC Address", "Source"). | 
 | 205 |  | 
| Rahul Maheshwari | d8037d3 | 2018-12-17 00:59:57 -0600 | [diff] [blame] | 206 |     ${stdout}=  Run IPMI Standard Command  lan print | 
| Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 207 |     ${fetch_value}=  Get Lines Containing String  ${stdout}  ${field_name} | 
 | 208 |     ${value_fetch}=  Fetch From Right  ${fetch_value}  :${SPACE} | 
 | 209 |     [Return]  ${value_fetch} | 
 | 210 |  | 
| Sweta Potthuri | 78dd1e1 | 2018-02-21 00:03:33 -0600 | [diff] [blame] | 211 |  | 
| George Keishing | e85113a | 2019-06-07 08:21:51 -0500 | [diff] [blame] | 212 | Set IPMI Restriction Mode | 
 | 213 |     [Documentation]  Set the IPMI restriction mode. | 
 | 214 |     [Arguments]  ${restriction_mode} | 
 | 215 |  | 
 | 216 |     # Description of argument(s): | 
 | 217 |     # restriction_mode   IPMI valid restriction modes. | 
 | 218 |  | 
 | 219 |     ${valueDict}=  Create Dictionary  data=${restriction_mode} | 
 | 220 |  | 
 | 221 |     Write Attribute  ${CONTROL_HOST_URI}restriction_mode/ | 
 | 222 |     ...  RestrictionMode  data=${valueDict} |