blob: b221290983398fa69a70bb37eed2b6e7851ba8da [file] [log] [blame]
Prashanth Katti1dcd5392017-05-12 04:35:53 -05001*** Settings ***
2
Sandhya Somashekar839a0c22019-01-31 05:05:43 -06003Resource ../xcat/resource.robot
4Resource ../../lib/resource.robot
Prashanth Katti1dcd5392017-05-12 04:35:53 -05005
6Library SSHLibrary
7Library OperatingSystem
Prashanth Katti477debc2017-05-19 03:01:04 -05008Library String
Prashanth Katti1dcd5392017-05-12 04:35:53 -05009
10*** Keywords ***
11
12Open 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 Keishing37c97bb2017-10-24 08:29:12 -050020 SSHLibrary.Open Connection ${xcat_host} port=${xcat_port}
George Keishing73af9272025-03-17 12:30:58 +053021 SSHLibrary.Login ${XCAT_USERNAME} ${XCAT_PASSWORD}
Prashanth Katti1dcd5392017-05-12 04:35:53 -050022
Rahul Maheshwari99c092f2017-07-31 02:32:14 -050023
24Execute 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 Keishing409df052024-01-17 22:36:14 +053039 RETURN ${stdout}
Rahul Maheshwari99c092f2017-07-31 02:32:14 -050040
41
Prashanth Katti1dcd5392017-05-12 04:35:53 -050042Get 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 Ramesh89242292025-07-20 02:36:56 -050047 # 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 Katti1dcd5392017-05-12 04:35:53 -050050
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 Keishingfb218a12018-11-28 11:20:42 -060054 ${bmc_list}= OperatingSystem.Get File ${node_cfg_file_path}
George Keishing409df052024-01-17 22:36:14 +053055 RETURN ${bmc_list}
Prashanth Katti477debc2017-05-19 03:01:04 -050056
Sridevi Ramesh89242292025-07-20 02:36:56 -050057
Prashanth Katti477debc2017-05-19 03:01:04 -050058Add 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 Ramesh89242292025-07-20 02:36:56 -050064 # node Name of the node to be added.
65 # username User name to login.
66 # password Password to login.
Prashanth Katti477debc2017-05-19 03:01:04 -050067
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 Ramesh89242292025-07-20 02:36:56 -050072
Prashanth Katti477debc2017-05-19 03:01:04 -050073Validate 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
85Power 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
96Power 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
107Get 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 Keishing409df052024-01-17 22:36:14 +0530118 RETURN ${stdout}
Prashanth Kattib974a742017-05-25 06:52:29 -0500119
120Add 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
132Get 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 Keishing409df052024-01-17 22:36:14 +0530148 RETURN ${stdout}
Prashanth Kattib974a742017-05-25 06:52:29 -0500149
150Validate 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 Katti56cbd172017-07-07 05:38:12 -0500162Get 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 Keishing409df052024-01-17 22:36:14 +0530174 RETURN ${stdout}