George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame^] | 1 | *** Settings *** |
| 2 | Documentation Methods to execute commands on BMC and collect |
| 3 | ... data to a list of FFDC files |
| 4 | |
| 5 | Resource openbmc_ffdc_utils.robot |
| 6 | |
| 7 | *** Keywords *** |
| 8 | |
| 9 | ################################################################ |
| 10 | # Method : Call FFDC Methods # |
| 11 | # Execute the user define keywords from the FFDC List # |
| 12 | # Unlike any other keywords this will call into the # |
| 13 | # list of keywords defined in the FFDC list at one go # |
| 14 | ################################################################ |
| 15 | |
| 16 | Call FFDC Methods |
| 17 | [Documentation] Calls into FFDC Keyword index list |
| 18 | |
| 19 | @{entries}= Get ffdc method index |
| 20 | :FOR ${index} IN @{entries} |
| 21 | \ Method Call Keyword List ${index} |
| 22 | |
| 23 | |
| 24 | Method Call Keyword List |
| 25 | [Documentation] Iterate the list through keyword index |
| 26 | [Arguments] ${index} |
| 27 | |
| 28 | @{method_list}= Get ffdc method call ${index} |
| 29 | :FOR ${method} IN @{method_list} |
| 30 | \ Execute Keyword Method ${method[1]} |
| 31 | |
| 32 | |
| 33 | Execute Keyword Method |
| 34 | [Documentation] Calls into BMC method keywords. Don't let one |
| 35 | ... failure skips the remaining. Get whatever data |
| 36 | ... it could gather at worse case scenario. |
| 37 | [Arguments] ${keyword_name} |
| 38 | |
| 39 | Run Keyword And Continue On Failure ${keyword_name} |
| 40 | |
| 41 | |
| 42 | ################################################################ |
| 43 | # Method : BMC FFDC Manifest # |
| 44 | # Execute command on BMC and write to ffdc_report.txt # |
| 45 | ################################################################ |
| 46 | |
| 47 | BMC FFDC Manifest |
| 48 | [Documentation] Get the commands index for the FFDC_BMC_CMD, |
| 49 | ... login to BMC and execute commands. |
| 50 | Open Connection And Log In |
| 51 | |
| 52 | @{entries}= Get ffdc cmd index |
| 53 | :FOR ${index} IN @{entries} |
| 54 | \ Iterate BMC Command List Pairs ${index} |
| 55 | |
| 56 | |
| 57 | Iterate BMC Command List Pairs |
| 58 | [Documentation] Feed in key pair list from dictionary to execute |
| 59 | [Arguments] ${key_index} |
| 60 | |
| 61 | @{cmd_list}= Get ffdc bmc cmd ${key_index} |
| 62 | Set Suite Variable ${ENTRY_INDEX} ${key_index} |
| 63 | :FOR ${cmd} IN @{cmd_list} |
| 64 | \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} |
| 65 | |
| 66 | |
| 67 | Execute Command and Write FFDC |
| 68 | [Documentation] Execute command on BMC and write to ffdc |
| 69 | ... By default to ffdc_report.txt file else to |
| 70 | ... specified file path. |
| 71 | [Arguments] ${key_index} |
| 72 | ... ${cmd} |
| 73 | ... ${logpath}=${FFDC_FILE_PATH} |
| 74 | |
| 75 | Run Keyword If '${logpath}' == '${FFDC_FILE_PATH}' |
| 76 | ... Write Cmd Output to FFDC File ${key_index} ${cmd} |
| 77 | |
| 78 | ${stdout} ${stderr}= |
| 79 | ... Execute Command ${cmd} return_stderr=True |
| 80 | |
| 81 | # Write stdout data on success and error msg to the file on failure |
| 82 | Run Keyword If '${stderr}' == '${EMPTY}' |
| 83 | ... Write Data to File ${stdout}${\n} ${logpath} |
| 84 | ... ELSE Run Keyword Write Data to File ${stderr}${\n} ${logpath} |
| 85 | |
| 86 | |
| 87 | ################################################################ |
| 88 | # Method : BMC FFDC Files # |
| 89 | # Execute command on BMC and write to individual file # |
| 90 | # based on the file name pre-defined in the list # |
| 91 | ################################################################ |
| 92 | |
| 93 | BMC FFDC Files |
| 94 | [Documentation] Get the command list and iterate |
| 95 | Open Connection And Log In |
| 96 | @{entries}= Get ffdc file index |
| 97 | :FOR ${index} IN @{entries} |
| 98 | \ Create File and Write Data ${index} |
| 99 | |
| 100 | |
| 101 | Create File and Write Data |
| 102 | [Documentation] Create files to current FFDC log directory, |
| 103 | ... executes command and write to corresponding |
| 104 | ... file name in the current FFDC directory. |
| 105 | [Arguments] ${key_index} |
| 106 | |
| 107 | @{cmd_list}= Get ffdc bmc file ${key_index} |
| 108 | :FOR ${cmd} IN @{cmd_list} |
| 109 | \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]} |
| 110 | \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath} |
| 111 | |
| 112 | |
| 113 | ################################################################ |
| 114 | # Method : Log Test Case Status # |
| 115 | # Creates test result history footprint for reference # |
| 116 | ################################################################ |
| 117 | |
| 118 | Log Test Case Status |
| 119 | [Documentation] Test case execution result history. |
| 120 | ... Create once and append to this file |
| 121 | ... logs/test_history.txt |
| 122 | ... Format Date:Test suite:Test case:Status |
| 123 | ... 20160909214053719992:Test Warmreset:Test WarmReset via REST:FAIL |
| 124 | Create Directory ${FFDC_LOG_PATH} |
| 125 | |
| 126 | ${exist}= Run Keyword and Return Status |
| 127 | ... OperatingSystem.File Should Exist ${TEST_HISTORY} |
| 128 | |
| 129 | Run Keyword If '${exist}' == '${False}' |
| 130 | ... Create File ${TEST_HISTORY} |
| 131 | |
| 132 | ${cur_time}= Get Current Time Stamp |
| 133 | |
| 134 | Append To File ${TEST_HISTORY} |
| 135 | ... ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n} |
| 136 | |