| Prashanth Katti | 1dcd539 | 2017-05-12 04:35:53 -0500 | [diff] [blame] | 1 | *** Settings *** | 
 | 2 |  | 
| Sandhya Somashekar | 839a0c2 | 2019-01-31 05:05:43 -0600 | [diff] [blame] | 3 | Resource    ../xcat/resource.robot | 
 | 4 | Resource    ../../lib/resource.robot | 
| 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 |  | 
| George Keishing | 37c97bb | 2017-10-24 08:29:12 -0500 | [diff] [blame] | 20 |     SSHLibrary.Open Connection  ${xcat_host}  port=${xcat_port} | 
| George Keishing | 73af927 | 2025-03-17 12:30:58 +0530 | [diff] [blame] | 21 |     SSHLibrary.Login  ${XCAT_USERNAME}  ${XCAT_PASSWORD} | 
| Prashanth Katti | 1dcd539 | 2017-05-12 04:35:53 -0500 | [diff] [blame] | 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 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 39 |     RETURN  ${stdout} | 
| Rahul Maheshwari | 99c092f | 2017-07-31 02:32:14 -0500 | [diff] [blame] | 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. | 
| Sridevi Ramesh | 8924229 | 2025-07-20 02:36:56 -0500 | [diff] [blame] | 47 |     # node_cfg_file_path    This keyword expects file having list of BMC nodes | 
 | 48 |     #                       as an input. | 
 | 49 |     #                       File should have IP addresses of BMC nodes. | 
| Prashanth Katti | 1dcd539 | 2017-05-12 04:35:53 -0500 | [diff] [blame] | 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 |  | 
| George Keishing | fb218a1 | 2018-11-28 11:20:42 -0600 | [diff] [blame] | 54 |     ${bmc_list}=  OperatingSystem.Get File  ${node_cfg_file_path} | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 55 |     RETURN  ${bmc_list} | 
| Prashanth Katti | 477debc | 2017-05-19 03:01:04 -0500 | [diff] [blame] | 56 |  | 
| Sridevi Ramesh | 8924229 | 2025-07-20 02:36:56 -0500 | [diff] [blame] | 57 |  | 
| Prashanth Katti | 477debc | 2017-05-19 03:01:04 -0500 | [diff] [blame] | 58 | Add Nodes To XCAT | 
 | 59 |     [Documentation]  Add nodes to XCAT configuration. | 
 | 60 |     [Arguments]  ${node}  ${username}=${OPENBMC_USERNAME} | 
 | 61 |     ...          ${password}=${OPENBMC_PASSWORD} | 
 | 62 |  | 
 | 63 |     # Description of the argument(s): | 
| Sridevi Ramesh | 8924229 | 2025-07-20 02:36:56 -0500 | [diff] [blame] | 64 |     # node         Name of the node to be added. | 
 | 65 |     # username     User name to login. | 
 | 66 |     # password     Password to login. | 
| Prashanth Katti | 477debc | 2017-05-19 03:01:04 -0500 | [diff] [blame] | 67 |  | 
 | 68 |     ${cmd_buf}=  Catenate  ${XCAT_DIR_PATH}/mkdef ${node} bmc=${node} | 
 | 69 |     ...  bmcusername=${username} bmcpassword=${password} mgt=openbmc groups=all | 
 | 70 |     Execute Command  ${cmd_buf} | 
 | 71 |  | 
| Sridevi Ramesh | 8924229 | 2025-07-20 02:36:56 -0500 | [diff] [blame] | 72 |  | 
| Prashanth Katti | 477debc | 2017-05-19 03:01:04 -0500 | [diff] [blame] | 73 | Validate Added Node | 
 | 74 |     [Documentation]  Validate added node. | 
 | 75 |     [Arguments]  ${node} | 
 | 76 |  | 
 | 77 |     # Description of the argument(s): | 
 | 78 |     # node  Name of the node. | 
 | 79 |  | 
 | 80 |     ${stdout}  ${stderr}=  Execute Command  ${XCAT_DIR_PATH}/nodels | 
 | 81 |     ...  return_stderr=True | 
 | 82 |     Should Be Empty  ${stderr} | 
 | 83 |     Should Contain  ${std_out}  ${node}  msg=Node is not added. | 
 | 84 |  | 
 | 85 | Power On Via XCAT | 
 | 86 |     [Documentation]  Power on via XCAT. | 
 | 87 |     [Arguments]  ${node} | 
 | 88 |  | 
 | 89 |     # Description of the argument(s): | 
 | 90 |     # node  Name of the node. | 
 | 91 |  | 
 | 92 |     ${stdout}  ${stderr}=  Execute Command  ${XCAT_DIR_PATH}/rpower ${node} on | 
 | 93 |     ...  return_stderr=True | 
 | 94 |     Should Be Empty  ${stderr} | 
 | 95 |  | 
 | 96 | Power Off Via XCAT | 
 | 97 |     [Documentation]  Power off via XCAT. | 
 | 98 |     [Arguments]  ${node} | 
 | 99 |  | 
 | 100 |     # Description of the argument(s): | 
 | 101 |     # node  Name of the node. | 
 | 102 |  | 
 | 103 |     ${stdout}  ${stderr}=  Execute Command  ${XCAT_DIR_PATH}/rpower ${node} off | 
 | 104 |     ...  return_stderr=True | 
 | 105 |     Should Be Empty  ${stderr} | 
 | 106 |  | 
 | 107 | Get Power Status | 
 | 108 |     [Documentation]  Get power status via XCAT. | 
 | 109 |     [Arguments]  ${node} | 
 | 110 |  | 
 | 111 |     # Description of the argument(s): | 
 | 112 |     # node  Name of the node. | 
 | 113 |  | 
 | 114 |     ${stdout}  ${stderr}=  Execute Command | 
 | 115 |     ...  ${XCAT_DIR_PATH}/rpower ${node} state  return_stderr=True | 
 | 116 |     Should Be Empty  ${stderr} | 
 | 117 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 118 |     RETURN  ${stdout} | 
| Prashanth Katti | b974a74 | 2017-05-25 06:52:29 -0500 | [diff] [blame] | 119 |  | 
 | 120 | Add Nodes To Group | 
 | 121 |     [Documentation]  Add BMC nodes to group. | 
 | 122 |     [Arguments]  ${node}  ${group}=${GROUP} | 
 | 123 |  | 
 | 124 |     # Description of argument(s): | 
 | 125 |     # node   Name of the node (e.g. "node1"). | 
 | 126 |     # group  Name of the group (e.g. "openbmc"). | 
 | 127 |  | 
 | 128 |     ${stdout}  ${stderr}=  Execute Command | 
 | 129 |     ...  ${XCAT_DIR_PATH}/chdef ${node} groups=${group}  return_stderr=True | 
 | 130 |     Should Be Empty  ${stderr} | 
 | 131 |  | 
 | 132 | Get List Of Nodes In Group | 
 | 133 |     [Documentation]  Get list of nodes in BMC. | 
 | 134 |     [Arguments]  ${group}=${GROUP} | 
 | 135 |  | 
 | 136 |     # Description of argument(s): | 
 | 137 |     # group  Name of the group (e.g. "openbmc"). | 
 | 138 |  | 
 | 139 |     # Sample output of this keyword: | 
 | 140 |     # XXX.XXX.XXX.XXX | 
 | 141 |     # YYY.YYY.YYY.YYY | 
 | 142 |     # ZZZ.ZZZ.ZZZ.ZZZ | 
 | 143 |  | 
 | 144 |     ${stdout}  ${stderr}=  Execute Command | 
 | 145 |     ...  ${XCAT_DIR_PATH}/nodels ${group}  return_stderr=True | 
 | 146 |     Should Be Empty  ${stderr} | 
 | 147 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 148 |     RETURN  ${stdout} | 
| Prashanth Katti | b974a74 | 2017-05-25 06:52:29 -0500 | [diff] [blame] | 149 |  | 
 | 150 | Validate Node Added In Group | 
 | 151 |     [Documentation]  Validate whether node is added in group. | 
 | 152 |     [Arguments]  ${node}  ${group} | 
 | 153 |  | 
 | 154 |     # Description of argument(s): | 
 | 155 |     # node   Name of the node (e.g. "node1"). | 
 | 156 |     # group  Name of the group (e.g. "openbmc"). | 
 | 157 |  | 
 | 158 |     ${nodes_in_group}=  Get List Of Nodes In Group  ${group} | 
 | 159 |     Should Contain  ${nodes_in_group}  ${node} | 
 | 160 |     ...  msg=BMC node is not added in a group. | 
 | 161 |  | 
| Prashanth Katti | 56cbd17 | 2017-07-07 05:38:12 -0500 | [diff] [blame] | 162 | Get Hardware Vitals Via XCAT | 
 | 163 |     [Documentation]  Get hardware vitals via XCAT. | 
 | 164 |     [Arguments]  ${node}  ${option} | 
 | 165 |  | 
 | 166 |     # Description of argument(s): | 
 | 167 |     # node    Name of the node (e.g. "node1"). | 
 | 168 |     # option  Hardware vitals option (e.g. "temp", "voltage", "fanspeed", etc.). | 
 | 169 |  | 
 | 170 |     ${cmd_buf}=  Catenate  ${XCAT_DIR_PATH}/rvitals ${node} ${option} | 
 | 171 |     ${stdout}  ${stderr}=  Execute Command  ${cmd_buf}  return_stderr=True | 
 | 172 |     Should Be Empty  ${stderr} | 
 | 173 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 174 |     RETURN  ${stdout} |