Prashanth Katti | 1dcd539 | 2017-05-12 04:35:53 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Resource ../xcat/resource.txt |
Prashanth Katti | 477debc | 2017-05-19 03:01:04 -0500 | [diff] [blame] | 4 | Resource ../../lib/resource.txt |
Prashanth Katti | 1dcd539 | 2017-05-12 04:35:53 -0500 | [diff] [blame] | 5 | |
| 6 | Library SSHLibrary |
| 7 | Library OperatingSystem |
Prashanth Katti | 477debc | 2017-05-19 03:01:04 -0500 | [diff] [blame] | 8 | Library String |
Prashanth Katti | 1dcd539 | 2017-05-12 04:35:53 -0500 | [diff] [blame] | 9 | |
| 10 | *** Keywords *** |
| 11 | |
| 12 | Open Connection And Login To XCAT |
| 13 | [Documentation] Open connection and login to xCAT server. |
| 14 | [Arguments] ${xcat_host}=${XCAT_HOST} ${xcat_port}=${XCAT_PORT} |
| 15 | |
| 16 | # Description of argument(s): |
| 17 | # xcat_host IP address of the XCAT server. |
| 18 | # xcat_port Network port on which XCAT server accepts ssh session. |
| 19 | |
| 20 | Open Connection ${xcat_host} port=${xcat_port} |
| 21 | Login ${XCAT_USERNAME} ${XCAT_PASSWORD} |
| 22 | |
Rahul Maheshwari | 99c092f | 2017-07-31 02:32:14 -0500 | [diff] [blame] | 23 | |
| 24 | Execute Command On XCAT |
| 25 | [Documentation] Execute command using XCAT. |
| 26 | [Arguments] ${command} ${command_option}=${EMPTY} |
| 27 | ... ${node}=${OPENBMC_HOST} |
| 28 | |
| 29 | # Description of argument(s): |
| 30 | # command Command to be run(e.g. "rinv"). |
| 31 | # command_option Command's option to be run(e.g. "dimm"). |
| 32 | # node Name of the node(e.g. "node1"). |
| 33 | |
| 34 | ${xcat_cmd}= Catenate SEPARATOR= |
| 35 | ... ${XCAT_DIR_PATH}/${command} ${node} ${command_option} |
| 36 | ${stdout} ${stderr}= Execute Command ${xcat_cmd} return_stderr=True |
| 37 | Should Be Empty ${stderr} |
| 38 | |
| 39 | [Return] ${stdout} |
| 40 | |
| 41 | |
Prashanth Katti | 1dcd539 | 2017-05-12 04:35:53 -0500 | [diff] [blame] | 42 | Get List Of BMC Nodes |
| 43 | [Documentation] Get list of BMC nodes. |
| 44 | [Arguments] ${node_cfg_file_path}=${NODE_CFG_FILE_PATH} |
| 45 | |
| 46 | # Get the list of BMC nodes to be added. |
| 47 | # This keyword expects file having list of BMC nodes |
| 48 | # as an input. |
| 49 | # File should have IP addresses of BMC nodes. |
| 50 | |
| 51 | OperatingSystem.File Should Exist ${node_cfg_file_path} msg=cfg file missing. |
| 52 | File Should Not Be Empty ${node_cfg_file_path} msg=Empty config file. |
| 53 | |
| 54 | ${bmc_list} = OperatingSystem.Get File ${node_cfg_file_path} |
| 55 | [Return] ${bmc_list} |
Prashanth Katti | 477debc | 2017-05-19 03:01:04 -0500 | [diff] [blame] | 56 | |
| 57 | Add Nodes To XCAT |
| 58 | [Documentation] Add nodes to XCAT configuration. |
| 59 | [Arguments] ${node} ${username}=${OPENBMC_USERNAME} |
| 60 | ... ${password}=${OPENBMC_PASSWORD} |
| 61 | |
| 62 | # Description of the argument(s): |
| 63 | # node Name of the node to be added. |
| 64 | |
| 65 | ${cmd_buf}= Catenate ${XCAT_DIR_PATH}/mkdef ${node} bmc=${node} |
| 66 | ... bmcusername=${username} bmcpassword=${password} mgt=openbmc groups=all |
| 67 | Execute Command ${cmd_buf} |
| 68 | |
| 69 | Validate Added Node |
| 70 | [Documentation] Validate added node. |
| 71 | [Arguments] ${node} |
| 72 | |
| 73 | # Description of the argument(s): |
| 74 | # node Name of the node. |
| 75 | |
| 76 | ${stdout} ${stderr}= Execute Command ${XCAT_DIR_PATH}/nodels |
| 77 | ... return_stderr=True |
| 78 | Should Be Empty ${stderr} |
| 79 | Should Contain ${std_out} ${node} msg=Node is not added. |
| 80 | |
| 81 | Power On Via XCAT |
| 82 | [Documentation] Power on via XCAT. |
| 83 | [Arguments] ${node} |
| 84 | |
| 85 | # Description of the argument(s): |
| 86 | # node Name of the node. |
| 87 | |
| 88 | ${stdout} ${stderr}= Execute Command ${XCAT_DIR_PATH}/rpower ${node} on |
| 89 | ... return_stderr=True |
| 90 | Should Be Empty ${stderr} |
| 91 | |
| 92 | Power Off Via XCAT |
| 93 | [Documentation] Power off via XCAT. |
| 94 | [Arguments] ${node} |
| 95 | |
| 96 | # Description of the argument(s): |
| 97 | # node Name of the node. |
| 98 | |
| 99 | ${stdout} ${stderr}= Execute Command ${XCAT_DIR_PATH}/rpower ${node} off |
| 100 | ... return_stderr=True |
| 101 | Should Be Empty ${stderr} |
| 102 | |
| 103 | Get Power Status |
| 104 | [Documentation] Get power status via XCAT. |
| 105 | [Arguments] ${node} |
| 106 | |
| 107 | # Description of the argument(s): |
| 108 | # node Name of the node. |
| 109 | |
| 110 | ${stdout} ${stderr}= Execute Command |
| 111 | ... ${XCAT_DIR_PATH}/rpower ${node} state return_stderr=True |
| 112 | Should Be Empty ${stderr} |
| 113 | |
| 114 | [Return] ${stdout} |
Prashanth Katti | b974a74 | 2017-05-25 06:52:29 -0500 | [diff] [blame] | 115 | |
| 116 | Add Nodes To Group |
| 117 | [Documentation] Add BMC nodes to group. |
| 118 | [Arguments] ${node} ${group}=${GROUP} |
| 119 | |
| 120 | # Description of argument(s): |
| 121 | # node Name of the node (e.g. "node1"). |
| 122 | # group Name of the group (e.g. "openbmc"). |
| 123 | |
| 124 | ${stdout} ${stderr}= Execute Command |
| 125 | ... ${XCAT_DIR_PATH}/chdef ${node} groups=${group} return_stderr=True |
| 126 | Should Be Empty ${stderr} |
| 127 | |
| 128 | Get List Of Nodes In Group |
| 129 | [Documentation] Get list of nodes in BMC. |
| 130 | [Arguments] ${group}=${GROUP} |
| 131 | |
| 132 | # Description of argument(s): |
| 133 | # group Name of the group (e.g. "openbmc"). |
| 134 | |
| 135 | # Sample output of this keyword: |
| 136 | # XXX.XXX.XXX.XXX |
| 137 | # YYY.YYY.YYY.YYY |
| 138 | # ZZZ.ZZZ.ZZZ.ZZZ |
| 139 | |
| 140 | ${stdout} ${stderr}= Execute Command |
| 141 | ... ${XCAT_DIR_PATH}/nodels ${group} return_stderr=True |
| 142 | Should Be Empty ${stderr} |
| 143 | |
| 144 | [Return] ${stdout} |
| 145 | |
| 146 | Validate Node Added In Group |
| 147 | [Documentation] Validate whether node is added in group. |
| 148 | [Arguments] ${node} ${group} |
| 149 | |
| 150 | # Description of argument(s): |
| 151 | # node Name of the node (e.g. "node1"). |
| 152 | # group Name of the group (e.g. "openbmc"). |
| 153 | |
| 154 | ${nodes_in_group}= Get List Of Nodes In Group ${group} |
| 155 | Should Contain ${nodes_in_group} ${node} |
| 156 | ... msg=BMC node is not added in a group. |
| 157 | |
| 158 | # TBD openbmc/openbmc-test-automation/issues/647 |