George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 1 | *** Settings *** |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 2 | Documentation Keywords for system test. |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 3 | |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 4 | Library ../lib/gen_robot_keyword.py |
Steven Sombar | 07be374 | 2018-01-11 13:02:40 -0600 | [diff] [blame] | 5 | Resource ../lib/boot_utils.robot |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 6 | Resource ../extended/obmc_boot_test_resource.robot |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 7 | Resource ../lib/utils.robot |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 8 | Resource ../lib/state_manager.robot |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 9 | Resource ../lib/rest_client.robot |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 10 | Resource resource.txt |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 11 | Library OperatingSystem |
| 12 | Library DateTime |
| 13 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 14 | *** Variables *** |
| 15 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 16 | ${htx_log_dir_path} ${EXECDIR}${/}logs${/} |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 17 | |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 18 | # Error strings to check from dmesg. |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 19 | ${ERROR_REGEX} error|GPU|NVRM|nvidia |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 20 | |
| 21 | # GPU specific error message from dmesg. |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 22 | ${ERROR_DBE_MSG} (DBE) has been detected on GPU |
| 23 | |
| 24 | # Inventory - List of I/O devices to collect for Inventory |
| 25 | @{I/O} communication disk display generic input multimedia |
| 26 | ... network printer tape |
| 27 | |
| 28 | # Inventory Paths of the JSON and YAML files |
Steven Sombar | a2f166c | 2017-08-02 14:22:45 -0500 | [diff] [blame] | 29 | ${json_tmp_file_path} ${EXECDIR}/inventory_temp_file.json |
| 30 | ${yaml_file_path} ${EXECDIR}/inventory_temp_file.yaml |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 31 | |
| 32 | |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 33 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 34 | *** Keywords *** |
| 35 | |
| 36 | Execute Command On OS |
| 37 | [Documentation] Execute given command on OS and return output. |
| 38 | [Arguments] ${command} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 39 | # Description of argument(s): |
| 40 | # command Shell command to be executed on OS. |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 41 | ${stdout} ${stderr}= Execute Command ${command} return_stderr=True |
| 42 | Should Be Empty ${stderr} |
| 43 | [Return] ${stdout} |
| 44 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 45 | Login To OS |
| 46 | [Documentation] Login to OS Host. |
| 47 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 48 | ... ${os_password}=${OS_PASSWORD} |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 49 | ... ${alias_name}=os_connection |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 50 | # Description of argument(s): |
| 51 | # os_host IP address of the OS Host. |
| 52 | # os_username OS Host Login user name. |
| 53 | # os_password OS Host Login passwrd. |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 54 | # alias_name Default OS SSH session connection alias name. |
| 55 | # TODO: Generalize alias naming using openbmc/openbmc-test-automation#633 |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 56 | |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 57 | Ping Host ${os_host} |
George Keishing | 664a016 | 2017-06-05 12:24:24 -0500 | [diff] [blame] | 58 | SSHLibrary.Open Connection ${os_host} alias=${alias_name} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 59 | Login ${os_username} ${os_password} |
| 60 | |
| 61 | |
George Keishing | 88366b3 | 2017-05-12 13:50:48 -0500 | [diff] [blame] | 62 | Tool Exist |
| 63 | [Documentation] Check whether given tool is installed on OS. |
| 64 | [Arguments] ${tool_name} |
| 65 | # Description of argument(s): |
| 66 | # tool_name Tool name whose existence is to be checked. |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 67 | Login To OS |
George Keishing | 88366b3 | 2017-05-12 13:50:48 -0500 | [diff] [blame] | 68 | ${output}= Execute Command On OS which ${tool_name} |
| 69 | Should Contain ${output} ${tool_name} |
| 70 | ... msg=Please install ${tool_name} tool. |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 71 | |
| 72 | |
| 73 | Boot To OS |
| 74 | [Documentation] Boot host OS. |
| 75 | Run Key OBMC Boot Test \ REST Power On |
| 76 | |
| 77 | |
| 78 | Power Off Host |
| 79 | [Documentation] Power off host. |
| 80 | Run Key OBMC Boot Test \ REST Power Off |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 81 | |
George Keishing | 6fec3ab | 2017-05-05 10:45:08 -0500 | [diff] [blame] | 82 | |
| 83 | File Exist On OS |
| 84 | [Documentation] Check if the given file path exist on OS. |
| 85 | [Arguments] ${file_path} |
| 86 | # Description of argument(s): |
| 87 | # file_path Absolute file path. |
| 88 | |
| 89 | Login To OS |
| 90 | ${out}= Execute Command On OS ls ${file_path} |
| 91 | Log To Console \n File Exist: ${out} |
| 92 | |
George Keishing | 8740a0c | 2017-05-13 07:19:16 -0500 | [diff] [blame] | 93 | |
| 94 | Is HTX Running |
| 95 | [Documentation] Check if the HTX exerciser is currently running. |
| 96 | |
| 97 | ${status}= Execute Command On OS htxcmdline -status |
| 98 | Should Not Contain ${status} Daemon state is <IDLE> |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 99 | |
| 100 | |
| 101 | Write Log Data To File |
| 102 | [Documentation] Write log data to the logs directory. |
| 103 | [Arguments] ${data}= ${log_file_path}= |
| 104 | # Description of argument(s): |
| 105 | # data String buffer. |
| 106 | # log_file_path The log file path. |
| 107 | |
| 108 | Create File ${log_file_path} ${data} |
| 109 | |
| 110 | |
| 111 | Collect HTX Log Files |
| 112 | [Documentation] Collect status and error log files. |
| 113 | # Collects the following files: |
| 114 | # HTX error log file /tmp/htxerr |
| 115 | # HTX status log file /tmp/htxstats |
| 116 | |
| 117 | # Create logs directory and get current datetime. |
| 118 | Create Directory ${htx_log_dir_path} |
| 119 | ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f |
| 120 | |
| 121 | File Exist On OS /tmp/htxerr |
| 122 | ${htx_err}= Execute Command On BMC cat /tmp/htxerr |
| 123 | Write Log Data To File |
| 124 | ... ${htx_err} ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr |
| 125 | |
| 126 | File Exist On OS /tmp/htxstats |
| 127 | ${htx_stats}= Execute Command On BMC cat /tmp/htxstats |
| 128 | Write Log Data To File |
| 129 | ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats |
| 130 | |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 131 | |
| 132 | REST Upload File To BMC |
| 133 | [Documentation] Upload a file via REST to BMC. |
| 134 | |
| 135 | # Generate 32 MB file size |
| 136 | Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB |
| 137 | OperatingSystem.File Should Exist dummyfile |
| 138 | |
| 139 | # Get the content of the file and upload to BMC |
| 140 | ${image_data}= OperatingSystem.Get Binary File dummyfile |
| 141 | |
| 142 | # Get REST session to BMC |
| 143 | Initialize OpenBMC |
| 144 | |
| 145 | # Create the REST payload headers and data |
| 146 | ${data}= Create Dictionary data ${image_data} |
| 147 | ${headers}= Create Dictionary Content-Type=application/octet-stream |
| 148 | ... Accept=application/octet-stream |
| 149 | Set To Dictionary ${data} headers ${headers} |
| 150 | |
| 151 | ${resp}= Post Request openbmc /upload/image &{data} |
| 152 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 153 | |
| 154 | # Delete uploaded image file. |
| 155 | # TODO: Delete via REST openbmc/openbmc#1550 |
| 156 | # Take SSH connection to BMC and switch to BMC connection to perform |
| 157 | # the task. |
| 158 | &{bmc_connection_args}= Create Dictionary alias=bmc_connection |
| 159 | Open Connection And Log In &{bmc_connection_args} |
| 160 | |
| 161 | # Currently OS SSH session is active, switch to BMC connection. |
| 162 | Switch Connection bmc_connection |
| 163 | Execute Command On BMC rm -f /tmp/images/* |
| 164 | |
| 165 | # Switch back to OS SSH connection. |
| 166 | Switch Connection os_connection |
| 167 | |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 168 | |
Steven Sombar | 1dc6fa7 | 2018-01-12 10:58:20 -0600 | [diff] [blame] | 169 | Get CPU Min Frequency Limit |
| 170 | [Documentation] Get CPU minimum assignable frequency. |
| 171 | |
| 172 | # lscpu | grep min returns |
| 173 | # CPU min MHz: 1983.0000 |
| 174 | |
| 175 | ${cmd}= Catenate lscpu | grep min | tr -dc '0-9.\n' |
| 176 | ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 177 | [Return] ${cpu_freq} |
| 178 | |
| 179 | |
| 180 | Get CPU Min Frequency |
| 181 | [Documentation] Get CPU assigned minimum frequency. |
| 182 | |
| 183 | # ppc64_cpu --frequency -t 10 returns |
| 184 | # min: 3.295 GHz (cpu 143) |
| 185 | # max: 3.295 GHz (cpu 0) |
| 186 | # avg: 3.295 GHz |
| 187 | |
| 188 | ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep min |
| 189 | ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n' |
| 190 | ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 191 | [Return] ${cpu_freq} |
| 192 | |
| 193 | |
| 194 | Get CPU Max Frequency Limit |
| 195 | [Documentation] Get CPU maximum assignable frequency. |
| 196 | |
| 197 | # lscpu | grep max returns |
| 198 | # CPU max MHz: 3300.0000 |
| 199 | |
| 200 | ${cmd}= Catenate lscpu | grep max | tr -dc '0-9.\n' |
| 201 | ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 202 | [Return] ${cpu_freq} |
| 203 | |
| 204 | |
| 205 | Get CPU Max Frequency |
| 206 | [Documentation] Get CPU assigned maximum frequency. |
| 207 | |
| 208 | # ppc64_cpu --frequency -t 10 returns |
| 209 | # min: 3.295 GHz (cpu 143) |
| 210 | # max: 3.295 GHz (cpu 0) |
| 211 | # avg: 3.295 GHz |
| 212 | |
| 213 | ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep max |
| 214 | ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n' |
| 215 | ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 216 | [Return] ${cpu_freq} |
| 217 | |
| 218 | |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 219 | Check For Errors On OS Dmesg Log |
| 220 | [Documentation] Check if dmesg has nvidia errors logged. |
| 221 | |
| 222 | ${dmesg_log}= Execute Command On OS dmesg | egrep '${ERROR_REGEX}' |
| 223 | # To enable multiple string check. |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 224 | Should Not Contain ${dmesg_log} ${ERROR_DBE_MSG} |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 225 | |
| 226 | |
| 227 | Collect NVIDIA Log File |
| 228 | [Documentation] Collect ndivia-smi command output. |
George Keishing | 664a016 | 2017-06-05 12:24:24 -0500 | [diff] [blame] | 229 | [Arguments] ${suffix} |
| 230 | # Description of argument(s): |
| 231 | # suffix String name to append. |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 232 | |
| 233 | # Collects the output of ndivia-smi cmd output. |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 234 | # +-----------------------------------------------------------------------------+ |
| 235 | # | NVIDIA-SMI 361.89 Driver Version: 361.89 | |
| 236 | # |-------------------------------+----------------------+----------------------+ |
| 237 | # | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | |
| 238 | # | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |
| 239 | # |===============================+======================+======================| |
| 240 | # | 0 Tesla P100-SXM2... On | 0002:01:00.0 Off | 0 | |
| 241 | # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default | |
| 242 | # +-------------------------------+----------------------+----------------------+ |
| 243 | # | 1 Tesla P100-SXM2... On | 0003:01:00.0 Off | 0 | |
| 244 | # | N/A 26C P0 40W / 300W | 1477MiB / 16280MiB | 0% Default | |
| 245 | # +-------------------------------+----------------------+----------------------+ |
| 246 | # | 2 Tesla P100-SXM2... On | 0006:01:00.0 Off | 0 | |
| 247 | # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default | |
| 248 | # +-------------------------------+----------------------+----------------------+ |
| 249 | # | 3 Tesla P100-SXM2... On | 0007:01:00.0 Off | 0 | |
| 250 | # | N/A 44C P0 290W / 300W | 965MiB / 16280MiB | 99% Default | |
| 251 | # +-------------------------------+----------------------+----------------------+ |
| 252 | # +-----------------------------------------------------------------------------+ |
| 253 | # | Processes: GPU Memory | |
| 254 | # | GPU PID Type Process name Usage | |
| 255 | # |=============================================================================| |
| 256 | # | 0 28459 C hxenvidia 929MiB | |
| 257 | # | 1 28460 C hxenvidia 1475MiB | |
| 258 | # | 2 28461 C hxenvidia 929MiB | |
| 259 | # | 3 28462 C hxenvidia 963MiB | |
| 260 | # +-----------------------------------------------------------------------------+ |
| 261 | |
| 262 | # Create logs directory and get current datetime. |
| 263 | Create Directory ${htx_log_dir_path} |
| 264 | ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f |
| 265 | |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 266 | ${nvidia_out} ${stderr} ${rc}= OS Execute Command nvidia-smi |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 267 | Write Log Data To File |
George Keishing | 664a016 | 2017-06-05 12:24:24 -0500 | [diff] [blame] | 268 | ... ${nvidia_out} |
| 269 | ... ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.nvidia_${suffix} |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 270 | |
| 271 | |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 272 | Get GPU Power Limit |
| 273 | [Documentation] Get NVIDIA GPU maximum permitted power draw. |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 274 | |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 275 | # nvidia-smi --query-gpu=power.limit --format=csv returns |
| 276 | # power.limit [W] |
| 277 | # 300.00 W |
| 278 | # 300.00 W |
| 279 | # 300.00 W |
| 280 | # 300.00 W |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 281 | |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 282 | ${cmd}= Catenate nvidia-smi --query-gpu=power.limit |
| 283 | ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1 |
| 284 | ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 285 | # Allow for sensor overshoot. That is, max power reported for |
| 286 | # a GPU could be a few watts above the limit. |
| 287 | ${power_max}= Evaluate ${nvidia_out}+${7.00} |
| 288 | [Return] ${power_max} |
| 289 | |
| 290 | |
| 291 | Get GPU Power |
| 292 | [Documentation] Get the GPU power dissipation. |
| 293 | |
| 294 | # nvidia-smi --query-gpu=power.draw --format=csv returns |
| 295 | # power.draw [W] |
| 296 | # 34.12 W |
| 297 | # 34.40 W |
| 298 | # 36.55 W |
| 299 | # 36.05 W |
| 300 | |
| 301 | ${cmd}= Catenate nvidia-smi --query-gpu=power.draw |
| 302 | ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1 |
| 303 | ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 304 | [Return] ${nvidia_out} |
| 305 | |
| 306 | |
| 307 | Get GPU Temperature Limit |
| 308 | [Documentation] Get NVIDIA GPU maximum permitted temperature. |
| 309 | |
| 310 | # nvidia-smi -q -d TEMPERATURE | grep "GPU Max" returns |
| 311 | # GPU Max Operating Temp : 83 C |
| 312 | # GPU Max Operating Temp : 83 C |
| 313 | # GPU Max Operating Temp : 83 C |
| 314 | # GPU Max Operating Temp : 83 C |
| 315 | |
| 316 | ${cmd}= Catenate nvidia-smi -q -d TEMPERATURE | grep "GPU Max" |
| 317 | ... | cut -f 2 -d ":" | tr -dc '0-9\n' | sort -n -u | tail -n 1 |
| 318 | ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 319 | [Return] ${nvidia_out} |
| 320 | |
| 321 | |
| 322 | Get GPU Temperature |
| 323 | [Documentation] Get the GPU temperature. |
| 324 | |
| 325 | # nvidia-smi --query-gpu=temperature.gpu --format=csv returns |
| 326 | # 38 |
| 327 | # 41 |
| 328 | # 38 |
| 329 | # 40 |
| 330 | |
| 331 | ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu |
| 332 | ... --format=csv | sort -n -u | tail -n 1 |
| 333 | ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 334 | [Return] ${nvidia_out} |
| 335 | |
| 336 | |
| 337 | Get GPU Clock Limit |
| 338 | [Documentation] Get NVIDIA GPU maximum permitted graphics clock. |
| 339 | |
| 340 | # nvidia-smi --query-gpu=clocks.max.gr --format=csv returns |
| 341 | # 1530 MHz |
| 342 | # 1530 MHz |
| 343 | # 1530 MHz |
| 344 | # 1530 MHz |
| 345 | |
| 346 | ${cmd}= Catenate nvidia-smi --query-gpu=clocks.max.gr |
| 347 | ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1 |
| 348 | ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 349 | [Return] ${nvidia_out} |
| 350 | |
| 351 | |
| 352 | Get GPU Clock |
| 353 | [Documentation] Get the highest assigned value of the GPU graphics clock. |
| 354 | |
| 355 | # nvidia-smi --query-gpu=clocks.gr --format=csv returns |
| 356 | # 1230 MHz |
| 357 | # 1230 MHz |
| 358 | # 135 MHz |
| 359 | # 150 MHz |
| 360 | |
| 361 | ${cmd}= Catenate nvidia-smi --query-gpu=clocks.gr |
| 362 | ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1 |
| 363 | ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd} |
| 364 | [Return] ${nvidia_out} |
| 365 | |
| 366 | |
| 367 | Count GPUs From BMC |
| 368 | [Documentation] Determine number of GPUs from the BMC. Hostboot |
| 369 | ... needs to have been run previously because the BMC gets GPU data |
| 370 | ... from Hostboot. |
| 371 | |
| 372 | # Example of gv* endpoint data: |
| 373 | # "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0": { |
| 374 | # "Functional": 1, |
| 375 | # "Present": 1, |
| 376 | # "PrettyName": "" |
| 377 | # }, |
| 378 | |
| 379 | ${num_bmc_gpus}= Set Variable ${0} |
| 380 | |
| 381 | ${gpu_list}= Get Endpoint Paths |
| 382 | ... ${HOST_INVENTORY_URI}system/chassis/motherboard gv* |
| 383 | |
| 384 | :FOR ${gpu_uri} IN @{gpu_list} |
| 385 | \ ${present}= Read Attribute ${gpu_uri} Present |
| 386 | \ ${state}= Read Attribute ${gpu_uri} Functional |
| 387 | \ Rpvars gpu_uri present state |
| 388 | \ ${num_bmc_gpus}= Run Keyword If ${present} and ${state} |
| 389 | ... Evaluate ${num_bmc_gpus}+${1} |
| 390 | [Return] ${num_bmc_gpus} |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 391 | |
| 392 | |
| 393 | Create Default MDT Profile |
| 394 | [Documentation] Create default mdt.bu profile and run. |
| 395 | |
| 396 | Rprint Timen Create HTX mdt profile. |
| 397 | |
| 398 | ${profile}= Execute Command On OS htxcmdline -createmdt |
| 399 | Rprintn ${profile} |
| 400 | Should Contain ${profile} mdts are created successfully |
| 401 | |
| 402 | |
| 403 | Run MDT Profile |
| 404 | [Documentation] Load user pre-defined MDT profile. |
| 405 | |
| 406 | Rprint Timen Start HTX mdt profile execution. |
| 407 | ${htx_run}= Execute Command On OS |
| 408 | ... htxcmdline -run -mdt ${HTX_MDT_PROFILE} |
| 409 | Rprintn ${htx_run} |
| 410 | Should Contain ${htx_run} Activated |
| 411 | |
| 412 | |
| 413 | Check HTX Run Status |
| 414 | [Documentation] Get HTX exerciser status and check for error. |
| 415 | |
| 416 | Rprint Timen Check HTX mdt Status and error. |
| 417 | ${status}= Execute Command On OS |
| 418 | ... htxcmdline -status -mdt ${HTX_MDT_PROFILE} |
| 419 | Rprintn ${status} |
| 420 | |
| 421 | ${errlog}= Execute Command On OS htxcmdline -geterrlog |
| 422 | Rprintn ${errlog} |
| 423 | |
| 424 | Should Contain ${errlog} file </tmp/htxerr> is empty |
| 425 | |
| 426 | |
| 427 | Shutdown HTX Exerciser |
| 428 | [Documentation] Shut down HTX exerciser run. |
| 429 | |
| 430 | Rprint Timen Shutdown HTX Run |
| 431 | ${shutdown}= Execute Command On OS |
| 432 | ... htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE} |
| 433 | Rprintn ${shutdown} |
| 434 | Should Contain ${shutdown} shutdown successfully |
| 435 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 436 | |
| 437 | Create JSON Inventory File |
| 438 | [Documentation] Create a JSON inventory file, and make a YAML copy. |
| 439 | [Arguments] ${json_file_path} |
| 440 | # Description of argument: |
| 441 | # json_file_path Where the inventory file is wrtten to. |
| 442 | |
| 443 | Login To OS |
| 444 | Compile Inventory JSON |
| 445 | Run json2yaml ${json_tmp_file_path} ${yaml_file_path} |
| 446 | # Format to JSON pretty print to file. |
| 447 | Run python -m json.tool ${json_tmp_file_path} > ${json_file_path} |
| 448 | OperatingSystem.File Should Exist ${json_file_path} |
| 449 | |
| 450 | |
| 451 | Compile Inventory JSON |
| 452 | [Documentation] Compile the Inventory into a JSON file. |
| 453 | Create File ${json_tmp_file_path} |
| 454 | Write New JSON List ${json_tmp_file_path} Inventory |
| 455 | Retrieve HW Info And Write processor ${json_tmp_file_path} |
| 456 | Retrieve HW Info And Write memory ${json_tmp_file_path} |
| 457 | Retrieve HW Info And Write List ${I/O} ${json_tmp_file_path} I/O last |
| 458 | Close New JSON List ${json_tmp_file_path} |
| 459 | |
| 460 | Write New JSON List |
| 461 | [Documentation] Start a new JSON list element in file. |
| 462 | [Arguments] ${json_tmp_file_path} ${json_field_name} |
| 463 | # Description of argument(s): |
| 464 | # json_tmp_file_path Name of file to write to. |
| 465 | # json_field_name Name to give json list element. |
| 466 | Append to File ${json_tmp_file_path} { "${json_field_name}" : [ |
| 467 | |
| 468 | Close New JSON List |
| 469 | [Documentation] Close JSON list element in file. |
| 470 | [Arguments] ${json_tmp_file_path} |
| 471 | # Description of argument(s): |
| 472 | # json_tmp_file_path Path of file to write to. |
| 473 | Append to File ${json_tmp_file_path} ]} |
| 474 | |
| 475 | Retrieve HW Info And Write |
| 476 | [Documentation] Retrieve and write info, add a comma if not last item. |
| 477 | [Arguments] ${class} ${json_tmp_file_path} ${last}=false |
| 478 | # Description of argument(s): |
| 479 | # class Device class to retrieve with lshw. |
| 480 | # json_tmp_file_path Path of file to write to. |
| 481 | # last Is this the last element in the parent JSON? |
| 482 | Write New JSON List ${json_tmp_file_path} ${class} |
| 483 | ${output} = Retrieve Hardware Info ${class} |
| 484 | ${output} = Clean Up String ${output} |
| 485 | Run Keyword if ${output.__class__ is not type(None)} |
| 486 | ... Append To File ${json_tmp_file_path} ${output} |
| 487 | Close New JSON List ${json_tmp_file_path} |
| 488 | Run Keyword if '${last}' == 'false' |
| 489 | ... Append to File ${json_tmp_file_path} , |
| 490 | |
| 491 | Retrieve HW Info And Write List |
| 492 | [Documentation] Does a Retrieve/Write with a list of classes and |
| 493 | ... encapsulates them into one large JSON element. |
| 494 | [Arguments] ${list} ${json_tmp_file_path} ${json_field_name} |
| 495 | ... ${last}=false |
| 496 | # Description of argument(s): |
| 497 | # list The list of devices classes to retrieve with lshw. |
| 498 | # json_tmp_file_path Path of file to write to. |
| 499 | # json_field_name Name of the JSON element to encapsulate this list. |
| 500 | # last Is this the last element in the parent JSON? |
| 501 | Write New JSON List ${json_tmp_file_path} ${json_field_name} |
| 502 | : FOR ${class} IN @{list} |
| 503 | \ ${tail} Get From List ${list} -1 |
| 504 | \ Run Keyword if '${tail}' == '${class}' |
| 505 | \ ... Retrieve HW Info And Write ${class} ${json_tmp_file_path} true |
| 506 | \ ... ELSE Retrieve HW Info And Write ${class} ${json_tmp_file_path} |
| 507 | Close New JSON List ${json_tmp_file_path} |
| 508 | Run Keyword if '${last}' == 'false' |
| 509 | ... Append to File ${json_tmp_file_path} , |
| 510 | |
| 511 | Retrieve Hardware Info |
| 512 | [Documentation] Retrieves the lshw output of the device class as JSON. |
| 513 | [Arguments] ${class} |
| 514 | # Description of argument(s): |
| 515 | # class Device class to retrieve with lshw. |
| 516 | ${output} = Execute Command On OS lshw -c ${class} -json |
| 517 | ${output} = Verify JSON string ${output} |
| 518 | [Return] ${output} |
| 519 | |
| 520 | Verify JSON String |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 521 | [Documentation] Ensure the JSON string content is separated by commas. |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 522 | [Arguments] ${unver_string} |
| 523 | # Description of argument(s): |
| 524 | # unver_string JSON String we will be checking for lshw comma errors. |
| 525 | ${unver_string} = Convert to String ${unver_string} |
| 526 | ${ver_string} = Replace String Using Regexp ${unver_string} }\\s*{ },{ |
| 527 | [Return] ${ver_string} |
| 528 | |
| 529 | Clean Up String |
| 530 | [Documentation] Remove extra whitespace and trailing commas. |
| 531 | [Arguments] ${dirty_string} |
| 532 | # Description of argument(s): |
| 533 | # dirty_string String that will be space stripped and have comma removed. |
| 534 | ${clean_string} = Strip String ${dirty_string} |
| 535 | ${last_char} = Get Substring ${clean_string} -1 |
| 536 | ${trimmed_string} = Get Substring ${clean_string} 0 -1 |
| 537 | ${clean_string} = Set Variable If '${last_char}' == ',' |
| 538 | ... ${trimmed_string} ${clean_string} |
| 539 | [Return] ${clean_string} |