blob: d0839bde5d0b3a2fcefc9f05ca7132462ce4cda6 [file] [log] [blame]
Steven Sombarebfb6622017-09-19 08:51:24 -05001*** Settings ***
2Documentation Utilities for power management tests.
3
4Resource ../lib/rest_client.robot
5Resource ../lib/openbmc_ffdc.robot
6Resource ../lib/boot_utils.robot
7Resource ../lib/ipmi_client.robot
8Library ../lib/var_funcs.py
9
10
11*** Keywords ***
12
13DCMI Power Get Limits
14 [Documentation] Run dcmi power get_limit and return values as a
15 ... dictionary.
16
17 # This keyword packages the five lines returned by dcmi power get_limit
18 # command into a dictionary. For example, the dcmi command may return:
19 # Current Limit State: No Active Power Limit
20 # Exception actions: Hard Power Off & Log Event to SEL
21 # Power Limit: 500 Watts
22 # Correction time: 0 milliseconds
23 # Sampling period: 0 seconds
24 # The power limit setting can be obtained with the following:
25 # &{limits}= DCMI Power Get Limits
26 # ${power_setting}= Set Variable ${limits['power_limit']}
27
28 ${output}= Run External IPMI Standard Command dcmi power get_limit
29 ${output}= Remove String ${output} Watts
30 ${output}= Remove String ${output} milliseconds
31 ${output}= Remove String ${output} seconds
32 &{limits}= Key Value Outbuf To Dict ${output}
33 [Return] &{limits}
34
35
36Get DCMI Power Limit
37 [Documentation] Return the system's current DCMI power_limit
38 ... watts setting.
39
40 &{limits}= DCMI Power Get Limits
41 ${power_setting}= Get From Dictionary ${limits} power_limit
42 [Return] ${power_setting}
43
44
45Set DCMI Power Limit And Verify
46 [Documentation] Set system power limit via IPMI DCMI command.
47 [Arguments] ${power_limit}
48
49 # Description of argument(s):
50 # limit The power limit in watts
51
52 ${cmd}= Catenate dcmi power set_limit limit ${power_limit}
53 Run External IPMI Standard Command ${cmd}
54 ${power}= Get DCMI Power Limit
55 Should Be True ${power} == ${power_limit}
Steven Sombarfc4d5752017-11-28 11:56:35 -060056 ... msg=Failed setting dcmi power limit to ${power_limit} watts.
Steven Sombarebfb6622017-09-19 08:51:24 -050057
58
59Activate DCMI Power And Verify
60 [Documentation] Activate DCMI power limiting.
61
62 ${resp}= Run External IPMI Standard Command dcmi power activate
63 Should Contain ${resp} successfully activated
64 ... msg=Command failed: dcmi power activate.
65
66
67Fail If DCMI Power Is Not Activated
68 [Documentation] Fail if DCMI power limiting is not activated.
69
70 ${cmd}= Catenate dcmi power get_limit | grep State:
71 ${resp}= Run External IPMI Standard Command ${cmd}
72 Should Contain ${resp} Power Limit Active msg=DCMI power is not active.
73
74
75Deactivate DCMI Power And Verify
76 [Documentation] Deactivate DCMI power power limiting.
77
78 ${cmd}= Catenate dcmi power deactivate | grep deactivated
79 ${resp}= Run External IPMI Standard Command ${cmd}
80 Should Contain ${resp} successfully deactivated
81 ... msg=Command failed: dcmi power deactivater.
82
83
84Fail If DCMI Power Is Not Deactivated
85 [Documentation] Fail if DCMI power limiting is not deactivated.
86
87 ${cmd}= Catenate dcmi power get_limit | grep State:
88 ${resp}= Run External IPMI Standard Command ${cmd}
89 Should Contain ${resp} No Active Power Limit
90 ... msg=DCMI power is not deactivated.
91
92
Steven Sombarc4351022018-01-15 13:47:38 -060093Get DCMI Power Limit Via REST
94 [Documentation] Return the system's current DCMI power_limit
95 ... watts setting using REST interface.
96
97 ${power_limit}= Read Attribute ${CONTROL_HOST_URI}power_cap PowerCap
98 [Return] ${power_limit}
99
100
101Set DCMI Power Limit Via REST
102 [Documentation] Set system power limit via REST command.
103 [Arguments] ${power_limit} ${verify}=${True}
104
105 # Description of argument(s):
106 # power_limit The power limit in watts.
107 # verify If True, read the power setting to confirm.
108
Steven Sombar90b76102019-01-11 11:04:38 -0600109 ${int_power_limit}= Convert To Integer ${power_limit}
110 ${data}= Create Dictionary data=${int_power_limit}
Steven Sombarc4351022018-01-15 13:47:38 -0600111 Write Attribute ${CONTROL_HOST_URI}power_cap PowerCap data=${data}
112 Return From Keyword If ${verify} == ${False}
113 ${power}= Read Attribute ${CONTROL_HOST_URI}power_cap PowerCap
114 Should Be True ${power} == ${power_limit}
115 ... msg=Failed setting power limit to ${power_limit} watts via REST.
116
117
118Activate DCMI Power Via REST
119 [Documentation] Activate DCMI power limiting via REST.
120 [Arguments] ${verify}=${True}
121
122 # Description of argument(s):
123 # verify If True, read the setting to confirm.
124
125 ${data}= Create Dictionary data=${True}
126 Write Attribute ${CONTROL_HOST_URI}power_cap PowerCapEnable
127 ... data=${data}
128 Return From Keyword If ${verify} == ${False}
129 ${setting}= Get DCMI Power Acivation Via REST
130 Should Be True ${setting} == ${1}
131 ... msg=Failed to activate power limiting via REST.
132
133
134Deactivate DCMI Power Via REST
135 [Documentation] Deactivate DCMI power limiting via REST.
136 [Arguments] ${verify}=${True}
137
138 # Description of argument(s):
139 # verify If True, read the setting to confirm.
140
141 ${data}= Create Dictionary data=${False}
142 Write Attribute ${CONTROL_HOST_URI}power_cap PowerCapEnable
143 ... data=${data}
144 Return From Keyword If ${verify} == ${False}
145 ${setting}= Get DCMI Power Acivation Via REST
146 Should Be True ${setting} == ${0}
147 ... msg=Failed to deactivate power limiting via REST.
148
149
150Get DCMI Power Acivation Via REST
151 [Documentation] Return the system's current DCMI power activation
152 ... state setting using REST interface.
153
154 ${power_activation_setting}= Read Attribute
155 ... ${CONTROL_HOST_URI}power_cap PowerCapEnable
156 [Return] ${power_activation_setting}
157
158
Steven Sombarebfb6622017-09-19 08:51:24 -0500159OCC Tool Upload Setup
160 [Documentation] Upload occtoolp9 to /tmp on the OS.
161
162 ${cmd}= Catenate wget --no-check-certificate
163 ... -O/tmp/occtoolp9 --content-disposition
164 ... https://github.com/open-power/occ/raw/master/src/tools/occtoolp9
165 ... && chmod 777 /tmp/occtoolp9
166 ${output} ${stderr} ${rc}= OS Execute Command ${cmd}