1*** Settings *** 2Documentation Module for testing BMC via XCAT. 3 4Resource ../lib/xcat/resource.robot 5Resource ../lib/xcat/xcat_utils.robot 6 7Library OperatingSystem 8Library String 9 10Suite Setup Validate XCAT Setup 11Suite Teardown Close All Connections 12 13*** Variables *** 14 15${poweron_flag} ON 16${poweroff_flag} OFF 17${NUM_POWER_STATUS_CHECKS} 1000 18 19*** Test Cases *** 20 21Add BMC Nodes To XCAT 22 [Documentation] Connect and add BMC nodes. 23 [Tags] Add_BMC_Nodes_To_XCAT 24 25 # Add BMC nodes one by one and check whether it is successfully added. 26 FOR ${bmc} IN @{BMC_LIST} 27 Add Nodes To XCAT ${bmc} 28 Validate Added Node ${bmc} 29 END 30 31 32Power On Via XCAT And Validate 33 [Documentation] Power on via XCAT and validate. 34 [Tags] Power_On_Via_XCAT_And_Validate 35 36 # Power on each BMC node and validate the power status. 37 FOR ${bmc} IN @{BMC_LIST} 38 Power On Via XCAT ${bmc} 39 Validate Power Status Via XCAT ${bmc} ${poweron_flag} 40 END 41 42 43Power Off Via XCAT And Validate 44 [Documentation] Power off via XCAT and validate. 45 [Tags] Power_Off_Via_XCAT_And_Validate 46 47 # Power off each BMC node and validate the power status. 48 FOR ${bmc} IN @{BMC_LIST} 49 Power Off Via XCAT ${bmc} 50 Validate Power Status Via XCAT ${bmc} ${poweroff_flag} 51 END 52 53 54Add Nodes To Group List 55 [Documentation] Add BMC nodes into group. 56 [Tags] Move_Added_Nodes_To_Group 57 58 # Add BMC nodes to group and validate. 59 FOR ${bmc} IN @{BMC_LIST} 60 Add Nodes To Group ${bmc} ${GROUP} 61 Validate Node Added In Group ${bmc} ${GROUP} 62 END 63 64 65Power On Group And Validate 66 [Documentation] Power on all BMCs in group and validate. 67 [Tags] Power_On_Group_And_Validate 68 69 # Sample output of this keyword: 70 # XXX.XXX.XXX.XXX 71 # YYY.YYY.YYY.YYY 72 # ZZZ.ZZZ.ZZZ.ZZZ 73 74 ${nodes}= Get List Of Nodes In Group ${GROUP} 75 Should Not Be Empty ${nodes} msg=Group is empty. 76 Power On Via XCAT ${GROUP} 77 78 # List the BMC nodes. 79 80 @{bmc_nodes}= Split String ${nodes} 81 82 # Validate power status on each BMC node one by one. 83 FOR ${bmc_node} IN @{bmc_nodes} 84 Validate Power Status Via XCAT ${bmc_node} ${poweron_flag} 85 END 86 87 88Power Off Group And Validate 89 [Documentation] Power off all BMCs in group and validate. 90 [Tags] Power_Off_Group_And_Validate 91 92 # Sample output of this keyword: 93 # XXX.XXX.XXX.XXX 94 # YYY.YYY.YYY.YYY 95 # ZZZ.ZZZ.ZZZ.ZZZ 96 97 ${nodes}= Get List Of Nodes In Group ${GROUP} 98 Should Not Be Empty ${nodes} msg=Group is empty. 99 Power Off Via XCAT ${GROUP} 100 101 # List the BMC nodes. 102 @{bmc_nodes}= Split String ${nodes} 103 104 # Validate power status on each BMC node one by one. 105 FOR ${bmc_node} IN @{bmc_nodes} 106 Validate Power Status Via XCAT ${bmc_node} ${poweroff_flag} 107 END 108 109 110Continuous Node Power Status 111 [Documentation] Continuously get the power status. 112 # This keyword verifies the REST connectivity between XCAT and the BMC node. 113 [Tags] Continuos_Node_Power_Status 114 115 # Performing this operation only on one BMC node. 116 117 Power On Via XCAT ${BMC_LIST[1]} 118 119 # Get the power status of the node repeatedly. 120 # By default it gets power status 1000 times. 121 # It bascially stress the BMC node and test REST implementation 122 # of the BMC node 123 124 FOR ${index} IN RANGE 1 ${NUM_POWER_STATUS_CHECKS} 125 Validate Power Status Via XCAT ${BMC_LIST[1]} ${poweron_flag} 126 END 127 128 129Get Temperature Reading Via XCAT 130 [Documentation] Get temperature reading via XCAT. 131 [Tags] Get_Temperature_Reading_Via_XCAT 132 133 # Sample output of the keyword: 134 # node1: Ambient: 28.62 C 135 # node1: P0 Vcs Temp: 35 C 136 # node1: P0 Vdd Temp: 35 C 137 # node1: P0 Vddr Temp: 35 C 138 # node1: P0 Vdn Temp: 35 C 139 # node1: P1 Vcs Temp: 33 C 140 # node1: P1 Vdd Temp: 33 C 141 # node1: P1 Vddr Temp: 34 C 142 # node1: P1 Vdn Temp: 34 C 143 144 # Get temperature reading from each BMC node. 145 146 FOR ${bmc} IN @{BMC_LIST} 147 ${temp_reading}= Get Hardware Vitals Via XCAT ${bmc} temp 148 Should Match ${temp_reading} ${bmc}* C 149 Log \n Temperature reading on $[bmc}\n ${temp_reading} 150 END 151 152 153Get Fanspeed Via XCAT 154 [Documentation] Get fanspeed via XCAT. 155 [Tags] Get_Fanspeed_Reading_Via_XCAT 156 157 # Sample output of the keyword: 158 # node1: Fan0 0: 10714 RPMS 159 # node1: Fan1 0: 10216 RPMS 160 # node1: Fan2 0: 14124 RPMS 161 # node1: Fan3 0: 11114 RPMS 162 163 # Get fanspeed from each BMC node. 164 165 FOR ${bmc} IN @{BMC_LIST} 166 ${fanspeed}= Get Hardware Vitals Via XCAT ${bmc} fanspeed 167 Should Match ${fanspeed} ${bmc}* RPMS 168 Log \n fanspeed on $[bmc}\n ${fanspeed} 169 END 170 171 172Get Voltage Reading Via XCAT 173 [Documentation] Get voltage via XCAT. 174 [Tags] Get_Voltage_Via_XCAT 175 176 # Sample output of the keyword: 177 # node1: No attributes returned from the BMC. 178 # BMC node is not returning anything, this will fail at present. 179 180 # Get voltage reading from each BMC node. 181 182 FOR ${bmc} IN @{BMC_LIST} 183 ${voltage}= Get Hardware Vitals Via XCAT ${bmc} voltage 184 Log \n Voltage reading on $[bmc}\n ${voltage} 185 END 186 187 188Get Wattage Via XCAT 189 [Documentation] Get wattage via XCAT. 190 [Tags] Get_Wattage_Via_XCAT 191 192 # Sample output of the keyword: 193 # node1: No attributes returned from the BMC. 194 # BMC node is not returning anything, this will fail at present. 195 196 # Get wattage reading from each BMC node. 197 198 FOR ${bmc} IN @{BMC_LIST} 199 ${wattage}= Get Hardware Vitals Via XCAT ${bmc} wattage 200 Log \n Wattage reading on $[bmc}\n ${wattage} 201 END 202 203*** Keywords *** 204 205Validate XCAT Setup 206 [Documentation] Validate XCAT setup. 207 208 Open Connection And Login To XCAT 209 210 # Check if XCAT is installed. 211 ${cmd_output}= Execute Command ${XCAT_DIR_PATH}/lsxcatd -v 212 Should Not Be Empty ${cmd_output} msg=XCAT not installed. 213 214 Log \n XCAT Version is: \n${cmd_output} 215 216 # Get all the BMC nodes from the config file. 217 ${nodes}= Get List Of BMC Nodes 218 # Make a list of BMC nodes. 219 @{BMC_LIST}= Split To Lines ${nodes} 220 Log To Console BMC nodes to be added:\n ${BMC_LIST} 221 Set Suite Variable @{BMC_LIST} 222 223 # GROUP should not be empty. 224 Should Not Be EMPTY ${GROUP} msg=Group does not exist. 225 226Validate Power Status Via XCAT 227 [Documentation] Validate power status. 228 [Arguments] ${node} ${flag}=ON 229 230 ${status}= Get Power Status ${node} 231 Run Keyword If '${flag}' == 'ON' 232 ... Should Contain ${status} on msg=Host is off. 233 ... ELSE Should Contain ${status} off msg=Host is on. 234