1ebfb6626SSteven Sombar*** Settings *** 2ebfb6626SSteven SombarDocumentation Utilities for power management tests. 3ebfb6626SSteven Sombar 4ebfb6626SSteven SombarResource ../lib/rest_client.robot 5ebfb6626SSteven SombarResource ../lib/openbmc_ffdc.robot 6ebfb6626SSteven SombarResource ../lib/boot_utils.robot 7ebfb6626SSteven SombarResource ../lib/ipmi_client.robot 8ebfb6626SSteven SombarLibrary ../lib/var_funcs.py 9ebfb6626SSteven Sombar 10a670bf3eSGeorge Keishing*** Variables *** 11a670bf3eSGeorge Keishing 12a670bf3eSGeorge Keishing${power_cap_uri} /redfish/v1/Chassis/${CHASSIS_ID}/EnvironmentMetrics 13ebfb6626SSteven Sombar 14ebfb6626SSteven Sombar*** Keywords *** 15ebfb6626SSteven Sombar 16a670bf3eSGeorge KeishingGet System Power Cap Limit 17a670bf3eSGeorge Keishing [Documentation] Get the allowed MAX and MIN power limit of the chassis. 18a670bf3eSGeorge Keishing 19a670bf3eSGeorge Keishing # GET request of /redfish/v1/Chassis/chassis/EnvironmentMetrics | grep -A5 Power 20a670bf3eSGeorge Keishing # "PowerLimitWatts": { 21a670bf3eSGeorge Keishing # "AllowableMax": 2488, 22a670bf3eSGeorge Keishing # "AllowableMin": 1778, 23a670bf3eSGeorge Keishing # "ControlMode": "Disabled", 24a670bf3eSGeorge Keishing # "SetPoint": 2488 25a670bf3eSGeorge Keishing # } 26a670bf3eSGeorge Keishing 27a670bf3eSGeorge Keishing ${power_limit_watts}= Redfish.Get Attribute ${power_cap_uri} PowerLimitWatts 28a670bf3eSGeorge Keishing 29*409df05dSGeorge Keishing RETURN ${power_limit_watts} 30a670bf3eSGeorge Keishing 31a670bf3eSGeorge Keishing 32ebfb6626SSteven SombarDCMI Power Get Limits 33ebfb6626SSteven Sombar [Documentation] Run dcmi power get_limit and return values as a 34ebfb6626SSteven Sombar ... dictionary. 35ebfb6626SSteven Sombar 36ebfb6626SSteven Sombar # This keyword packages the five lines returned by dcmi power get_limit 37ebfb6626SSteven Sombar # command into a dictionary. For example, the dcmi command may return: 38ebfb6626SSteven Sombar # Current Limit State: No Active Power Limit 39ebfb6626SSteven Sombar # Exception actions: Hard Power Off & Log Event to SEL 40ebfb6626SSteven Sombar # Power Limit: 500 Watts 41ebfb6626SSteven Sombar # Correction time: 0 milliseconds 42ebfb6626SSteven Sombar # Sampling period: 0 seconds 43ebfb6626SSteven Sombar # The power limit setting can be obtained with the following: 44ebfb6626SSteven Sombar # &{limits}= DCMI Power Get Limits 45ebfb6626SSteven Sombar # ${power_setting}= Set Variable ${limits['power_limit']} 46ebfb6626SSteven Sombar 47ebfb6626SSteven Sombar ${output}= Run External IPMI Standard Command dcmi power get_limit 48ebfb6626SSteven Sombar ${output}= Remove String ${output} Watts 49ebfb6626SSteven Sombar ${output}= Remove String ${output} milliseconds 50ebfb6626SSteven Sombar ${output}= Remove String ${output} seconds 51ebfb6626SSteven Sombar &{limits}= Key Value Outbuf To Dict ${output} 52*409df05dSGeorge Keishing RETURN &{limits} 53ebfb6626SSteven Sombar 54ebfb6626SSteven Sombar 55ebfb6626SSteven SombarGet DCMI Power Limit 56ebfb6626SSteven Sombar [Documentation] Return the system's current DCMI power_limit 57ebfb6626SSteven Sombar ... watts setting. 58ebfb6626SSteven Sombar 59ebfb6626SSteven Sombar &{limits}= DCMI Power Get Limits 60ebfb6626SSteven Sombar ${power_setting}= Get From Dictionary ${limits} power_limit 61*409df05dSGeorge Keishing RETURN ${power_setting} 62ebfb6626SSteven Sombar 63ebfb6626SSteven Sombar 64ebfb6626SSteven SombarSet DCMI Power Limit And Verify 65ebfb6626SSteven Sombar [Documentation] Set system power limit via IPMI DCMI command. 66ebfb6626SSteven Sombar [Arguments] ${power_limit} 67ebfb6626SSteven Sombar 68ebfb6626SSteven Sombar # Description of argument(s): 69ebfb6626SSteven Sombar # limit The power limit in watts 70ebfb6626SSteven Sombar 71ebfb6626SSteven Sombar ${cmd}= Catenate dcmi power set_limit limit ${power_limit} 72ebfb6626SSteven Sombar Run External IPMI Standard Command ${cmd} 73ebfb6626SSteven Sombar ${power}= Get DCMI Power Limit 74ebfb6626SSteven Sombar Should Be True ${power} == ${power_limit} 75fc4d575aSSteven Sombar ... msg=Failed setting dcmi power limit to ${power_limit} watts. 76ebfb6626SSteven Sombar 77ebfb6626SSteven Sombar 78ebfb6626SSteven SombarActivate DCMI Power And Verify 79ebfb6626SSteven Sombar [Documentation] Activate DCMI power limiting. 80ebfb6626SSteven Sombar 81ebfb6626SSteven Sombar ${resp}= Run External IPMI Standard Command dcmi power activate 82ebfb6626SSteven Sombar Should Contain ${resp} successfully activated 83ebfb6626SSteven Sombar ... msg=Command failed: dcmi power activate. 84ebfb6626SSteven Sombar 85ebfb6626SSteven Sombar 86ebfb6626SSteven SombarFail If DCMI Power Is Not Activated 87ebfb6626SSteven Sombar [Documentation] Fail if DCMI power limiting is not activated. 88ebfb6626SSteven Sombar 89ebfb6626SSteven Sombar ${cmd}= Catenate dcmi power get_limit | grep State: 90ebfb6626SSteven Sombar ${resp}= Run External IPMI Standard Command ${cmd} 91ebfb6626SSteven Sombar Should Contain ${resp} Power Limit Active msg=DCMI power is not active. 92ebfb6626SSteven Sombar 93ebfb6626SSteven Sombar 94ebfb6626SSteven SombarDeactivate DCMI Power And Verify 95ebfb6626SSteven Sombar [Documentation] Deactivate DCMI power power limiting. 96ebfb6626SSteven Sombar 97ebfb6626SSteven Sombar ${cmd}= Catenate dcmi power deactivate | grep deactivated 98ebfb6626SSteven Sombar ${resp}= Run External IPMI Standard Command ${cmd} 99ebfb6626SSteven Sombar Should Contain ${resp} successfully deactivated 100ebfb6626SSteven Sombar ... msg=Command failed: dcmi power deactivater. 101ebfb6626SSteven Sombar 102ebfb6626SSteven Sombar 103ebfb6626SSteven SombarFail If DCMI Power Is Not Deactivated 104ebfb6626SSteven Sombar [Documentation] Fail if DCMI power limiting is not deactivated. 105ebfb6626SSteven Sombar 106ebfb6626SSteven Sombar ${cmd}= Catenate dcmi power get_limit | grep State: 107ebfb6626SSteven Sombar ${resp}= Run External IPMI Standard Command ${cmd} 108ebfb6626SSteven Sombar Should Contain ${resp} No Active Power Limit 109ebfb6626SSteven Sombar ... msg=DCMI power is not deactivated. 110ebfb6626SSteven Sombar 111ebfb6626SSteven Sombar 112c4351022SSteven SombarGet DCMI Power Limit Via REST 113c4351022SSteven Sombar [Documentation] Return the system's current DCMI power_limit 114c4351022SSteven Sombar ... watts setting using REST interface. 115c4351022SSteven Sombar 116c4351022SSteven Sombar ${power_limit}= Read Attribute ${CONTROL_HOST_URI}power_cap PowerCap 117*409df05dSGeorge Keishing RETURN ${power_limit} 118c4351022SSteven Sombar 119c4351022SSteven Sombar 120c4351022SSteven SombarSet DCMI Power Limit Via REST 121c4351022SSteven Sombar [Documentation] Set system power limit via REST command. 122c4351022SSteven Sombar [Arguments] ${power_limit} ${verify}=${True} 123c4351022SSteven Sombar 124c4351022SSteven Sombar # Description of argument(s): 125c4351022SSteven Sombar # power_limit The power limit in watts. 126c4351022SSteven Sombar # verify If True, read the power setting to confirm. 127c4351022SSteven Sombar 12890b76108SSteven Sombar ${int_power_limit}= Convert To Integer ${power_limit} 12990b76108SSteven Sombar ${data}= Create Dictionary data=${int_power_limit} 130c4351022SSteven Sombar Write Attribute ${CONTROL_HOST_URI}power_cap PowerCap data=${data} 131c4351022SSteven Sombar Return From Keyword If ${verify} == ${False} 132c4351022SSteven Sombar ${power}= Read Attribute ${CONTROL_HOST_URI}power_cap PowerCap 133c4351022SSteven Sombar Should Be True ${power} == ${power_limit} 134c4351022SSteven Sombar ... msg=Failed setting power limit to ${power_limit} watts via REST. 135c4351022SSteven Sombar 136c4351022SSteven Sombar 137c4351022SSteven SombarActivate DCMI Power Via REST 138c4351022SSteven Sombar [Documentation] Activate DCMI power limiting via REST. 139c4351022SSteven Sombar [Arguments] ${verify}=${True} 140c4351022SSteven Sombar 141c4351022SSteven Sombar # Description of argument(s): 142c4351022SSteven Sombar # verify If True, read the setting to confirm. 143c4351022SSteven Sombar 144c4351022SSteven Sombar ${data}= Create Dictionary data=${True} 145c4351022SSteven Sombar Write Attribute ${CONTROL_HOST_URI}power_cap PowerCapEnable 146c4351022SSteven Sombar ... data=${data} 147c4351022SSteven Sombar Return From Keyword If ${verify} == ${False} 1489bfdf8a7SGeorge Keishing ${setting}= Get DCMI Power Activation Via REST 149c4351022SSteven Sombar Should Be True ${setting} == ${1} 150c4351022SSteven Sombar ... msg=Failed to activate power limiting via REST. 151c4351022SSteven Sombar 152c4351022SSteven Sombar 153c4351022SSteven SombarDeactivate DCMI Power Via REST 154c4351022SSteven Sombar [Documentation] Deactivate DCMI power limiting via REST. 155c4351022SSteven Sombar [Arguments] ${verify}=${True} 156c4351022SSteven Sombar 157c4351022SSteven Sombar # Description of argument(s): 158c4351022SSteven Sombar # verify If True, read the setting to confirm. 159c4351022SSteven Sombar 160c4351022SSteven Sombar ${data}= Create Dictionary data=${False} 161c4351022SSteven Sombar Write Attribute ${CONTROL_HOST_URI}power_cap PowerCapEnable 162c4351022SSteven Sombar ... data=${data} 163c4351022SSteven Sombar Return From Keyword If ${verify} == ${False} 1649bfdf8a7SGeorge Keishing ${setting}= Get DCMI Power Activation Via REST 165c4351022SSteven Sombar Should Be True ${setting} == ${0} 166c4351022SSteven Sombar ... msg=Failed to deactivate power limiting via REST. 167c4351022SSteven Sombar 168c4351022SSteven Sombar 1699bfdf8a7SGeorge KeishingGet DCMI Power Activation Via REST 170c4351022SSteven Sombar [Documentation] Return the system's current DCMI power activation 171c4351022SSteven Sombar ... state setting using REST interface. 172c4351022SSteven Sombar 173c4351022SSteven Sombar ${power_activation_setting}= Read Attribute 174c4351022SSteven Sombar ... ${CONTROL_HOST_URI}power_cap PowerCapEnable 175*409df05dSGeorge Keishing RETURN ${power_activation_setting} 176c4351022SSteven Sombar 177c4351022SSteven Sombar 178ebfb6626SSteven SombarOCC Tool Upload Setup 179ebfb6626SSteven Sombar [Documentation] Upload occtoolp9 to /tmp on the OS. 180ebfb6626SSteven Sombar 181ebfb6626SSteven Sombar ${cmd}= Catenate wget --no-check-certificate 182ebfb6626SSteven Sombar ... -O/tmp/occtoolp9 --content-disposition 183ebfb6626SSteven Sombar ... https://github.com/open-power/occ/raw/master/src/tools/occtoolp9 184ebfb6626SSteven Sombar ... && chmod 777 /tmp/occtoolp9 185ebfb6626SSteven Sombar ${output} ${stderr} ${rc}= OS Execute Command ${cmd} 186