blob: 6a5cdaa16945bcc6507b08728c698ae4e972d6bd [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Library Collections
3Library String
4Library RequestsLibrary.RequestsKeywords
5Library OperatingSystem
Sandhya Somashekar839a0c22019-01-31 05:05:43 -06006Resource resource.robot
George Keishingeaa73b72018-07-30 09:30:16 -05007Library disable_warning_urllib.py
Michael Walshad66c952018-10-04 15:12:47 -05008Library utils.py
Steven Sombarb3489242018-12-13 15:59:02 -06009Library gen_misc.py
Sridevi Ramesheadeef02019-01-17 08:56:18 -060010Library var_funcs.py
George Keishingeaa73b72018-07-30 09:30:16 -050011Resource rest_response_code.robot
Chris Austenb29d2e82016-06-07 12:25:35 -050012
13*** Variables ***
Michael Walsha6723f22016-11-22 11:12:01 -060014# Assign default value to QUIET for programs which may not define it.
15${QUIET} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -050016
Sridevi Ramesheadeef02019-01-17 08:56:18 -060017${XAUTH_TOKEN} ${EMPTY}
18
Chris Austenb29d2e82016-06-07 12:25:35 -050019*** Keywords ***
20OpenBMC Get Request
manasarm604b8cd2018-01-29 12:14:20 +053021 [Documentation] Do REST GET request and return the result.
22 # Example result data:
23 # Response code:200, Content:{
24 # "data": [
25 # "/xyz/openbmc_project/state/host0",
26 # "/xyz/openbmc_project/state/chassis0",
27 # "/xyz/openbmc_project/state/bmc0"
28 # ],
29 # "message": "200 OK",
30 # "status": "ok"
31 # }
George Keishing41c44cf2017-11-15 08:02:59 -060032 [Arguments] ${uri} ${timeout}=30 ${quiet}=${QUIET} &{kwargs}
manasarm604b8cd2018-01-29 12:14:20 +053033 # Description of argument(s):
34 # uri The URI to establish connection with
35 # (e.g. '/xyz/openbmc_project/software/').
36 # timeout Timeout in seconds to establish connection with URI.
37 # quiet If enabled, turns off logging to console.
38 # kwargs Any additional arguments to be passed directly to the
39 # Get Request call. For example, the caller might
40 # set kwargs as follows:
41 # ${kwargs}= Create Dictionary allow_redirect=${True}.
Michael Walshf00edee2016-12-09 14:10:26 -060042
Sridevi Ramesheadeef02019-01-17 08:56:18 -060043 Initialize OpenBMC ${timeout} quiet=${quiet}
44
Chris Austenb29d2e82016-06-07 12:25:35 -050045 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
Sridevi Ramesheadeef02019-01-17 08:56:18 -060046 ${headers}= Create Dictionary Content-Type=application/octet-stream
47 ... X-Auth-Token=${XAUTH_TOKEN} Accept=application/octet-stream
48 Set To Dictionary ${kwargs} headers ${headers}
Michael Walsha6723f22016-11-22 11:12:01 -060049 Run Keyword If '${quiet}' == '${0}' Log Request method=Get
50 ... base_uri=${base_uri} args=&{kwargs}
Michael Walsha6723f22016-11-22 11:12:01 -060051 ${ret}= Get Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
52 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
George Keishing08540c02017-07-19 09:42:50 -050053 Delete All Sessions
Chris Austenb29d2e82016-06-07 12:25:35 -050054 [Return] ${ret}
55
56OpenBMC Post Request
manasarm604b8cd2018-01-29 12:14:20 +053057 [Documentation] Do REST POST request and return the result.
58 # Example result data:
59 # <Response [200]>
Michael Walsha6723f22016-11-22 11:12:01 -060060 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
manasarm604b8cd2018-01-29 12:14:20 +053061 # Description of argument(s):
62 # uri The URI to establish connection with
63 # (e.g. '/xyz/openbmc_project/software/').
64 # timeout Timeout in seconds to establish connection with URI.
65 # quiet If enabled, turns off logging to console.
66 # kwargs Any additional arguments to be passed directly to the
67 # Post Request call. For example, the caller might
68 # set kwargs as follows:
69 # ${kwargs}= Create Dictionary allow_redirect=${True}.
Michael Walsha6723f22016-11-22 11:12:01 -060070
Michael Walshf00edee2016-12-09 14:10:26 -060071 Initialize OpenBMC ${timeout} quiet=${quiet}
Chris Austenb29d2e82016-06-07 12:25:35 -050072 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
Sridevi Ramesheadeef02019-01-17 08:56:18 -060073 ${headers}= Create Dictionary Content-Type=application/json
74 ... X-Auth-Token=${XAUTH_TOKEN}
Chris Austenb29d2e82016-06-07 12:25:35 -050075 set to dictionary ${kwargs} headers ${headers}
Michael Walsha6723f22016-11-22 11:12:01 -060076 Run Keyword If '${quiet}' == '${0}' Log Request method=Post
77 ... base_uri=${base_uri} args=&{kwargs}
Michael Walsha6723f22016-11-22 11:12:01 -060078 ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
79 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
George Keishing08540c02017-07-19 09:42:50 -050080 Delete All Sessions
Chris Austenb29d2e82016-06-07 12:25:35 -050081 [Return] ${ret}
82
83OpenBMC Put Request
manasarm604b8cd2018-01-29 12:14:20 +053084 [Documentation] Do REST PUT request on the resource identified by the URI.
Rahul Maheshwari79c12942016-10-17 09:39:17 -050085 [Arguments] ${uri} ${timeout}=10 &{kwargs}
manasarm604b8cd2018-01-29 12:14:20 +053086 # Description of argument(s):
87 # uri The URI to establish connection with
88 # (e.g. '/xyz/openbmc_project/software/').
89 # timeout Timeout in seconds to establish connection with URI.
90 # kwargs Arguments passed to the REST call.
91 # kwargs Any additional arguments to be passed directly to the
92 # Put Request call. For example, the caller might
93 # set kwargs as follows:
94 # ${kwargs}= Create Dictionary allow_redirect=${True}.
Michael Walshf00edee2016-12-09 14:10:26 -060095
96 Initialize OpenBMC ${timeout}
Chris Austenb29d2e82016-06-07 12:25:35 -050097 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
98 ${headers}= Create Dictionary Content-Type=application/json
Sridevi Ramesheadeef02019-01-17 08:56:18 -060099 ... X-Auth-Token=${XAUTH_TOKEN}
Chris Austenb29d2e82016-06-07 12:25:35 -0500100 set to dictionary ${kwargs} headers ${headers}
101 Log Request method=Put base_uri=${base_uri} args=&{kwargs}
Michael Walsha6723f22016-11-22 11:12:01 -0600102 ${ret}= Put Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
Chris Austenb29d2e82016-06-07 12:25:35 -0500103 Log Response ${ret}
George Keishing08540c02017-07-19 09:42:50 -0500104 Delete All Sessions
Chris Austenb29d2e82016-06-07 12:25:35 -0500105 [Return] ${ret}
106
107OpenBMC Delete Request
manasarm604b8cd2018-01-29 12:14:20 +0530108 [Documentation] Do REST request to delete the resource identified by the
109 ... URI.
Rahul Maheshwari79c12942016-10-17 09:39:17 -0500110 [Arguments] ${uri} ${timeout}=10 &{kwargs}
manasarm604b8cd2018-01-29 12:14:20 +0530111 # Description of argument(s):
112 # uri The URI to establish connection with
113 # (e.g. '/xyz/openbmc_project/software/').
114 # timeout Timeout in seconds to establish connection with URI.
115 # kwargs Any additional arguments to be passed directly to the
116 # Delete Request call. For example, the caller might
117 # set kwargs as follows:
118 # ${kwargs}= Create Dictionary allow_redirect=${True}.
Michael Walshf00edee2016-12-09 14:10:26 -0600119
120 Initialize OpenBMC ${timeout}
Chris Austenb29d2e82016-06-07 12:25:35 -0500121 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600122 ${headers}= Create Dictionary Content-Type=application/json
123 ... X-Auth-Token=${XAUTH_TOKEN}
124 Set To Dictionary ${kwargs} headers ${headers}
125 Log Request method=Delete base_uri=${base_uri} args=&{kwargs}
George Keishing0e7c3a02017-04-17 05:01:14 -0500126 ${ret}= Delete Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
Chris Austenb29d2e82016-06-07 12:25:35 -0500127 Log Response ${ret}
George Keishing08540c02017-07-19 09:42:50 -0500128 Delete All Sessions
Chris Austenb29d2e82016-06-07 12:25:35 -0500129 [Return] ${ret}
130
131Initialize OpenBMC
manasarm604b8cd2018-01-29 12:14:20 +0530132 [Documentation] Do a REST login connection within specified time.
George Keishing1cdc6dd2017-04-24 15:31:03 -0500133 [Arguments] ${timeout}=20 ${quiet}=${1}
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600134 ... ${rest_username}=${REST_USERNAME}
135 ... ${rest_password}=${REST_PASSWORD}
Michael Walshf00edee2016-12-09 14:10:26 -0600136
George Keishing1cdc6dd2017-04-24 15:31:03 -0500137 # Description of argument(s):
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600138 # timeout REST login attempt time out.
139 # quiet Suppress console log if set.
140 # rest_username The REST username.
141 # rest_password The REST password.
142
143 ${bmcweb_status}= Run Keyword And Return Status BMC Web Login Request
144 ... ${timeout} ${rest_username} ${rest_password}
145
146 Return From Keyword If ${bmcweb_status} == ${True}
George Keishing1cdc6dd2017-04-24 15:31:03 -0500147
148 # TODO : Task to revert this changes openbmc/openbmc-test-automation#532
149 # This will retry at 20 second interval.
150 Wait Until Keyword Succeeds 40 sec 20 sec
151 ... Post Login Request ${timeout} ${quiet}
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600152 ... ${rest_username} ${rest_password}
153
154
155BMC Web Login Request
156 [Documentation] Do BMC web-based login.
157 [Arguments] ${timeout}=20 ${rest_username}=${REST_USERNAME}
158 ... ${rest_password}=${REST_PASSWORD}
159
160 # Description of argument(s):
161 # timeout REST login attempt time out.
162 # rest_username The REST username.
163 # rest_password The REST password.
164
165 Create Session openbmc ${AUTH_URI} timeout=${timeout}
166
167 ${headers}= Create Dictionary Content-Type=application/json
168 @{credentials}= Create List ${rest_username} ${rest_password}
169 ${data}= Create Dictionary data=@{credentials}
170 ${resp}= Post Request openbmc /login data=${data} headers=${headers}
171 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
172
173 ${processed_token_data}=
174 ... Evaluate re.split(r'[;,]', '${resp.headers["Set-Cookie"]}') modules=re
175 ${result}= Key Value List To Dict ${processed_token_data} delim==
176
177 # Example result data:
178 # 'XSRF-TOKEN=hQuOyDJFEIbrN4aOg2CT; Secure,
179 # SESSION=c4wloTiETumSxPI9nLeg; Secure; HttpOnly'
180 Set Global Variable ${XAUTH_TOKEN} ${result['session']}
181
George Keishing1cdc6dd2017-04-24 15:31:03 -0500182
183Post Login Request
manasarm604b8cd2018-01-29 12:14:20 +0530184 [Documentation] Do REST login request.
George Keishing1cdc6dd2017-04-24 15:31:03 -0500185 [Arguments] ${timeout}=20 ${quiet}=${1}
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600186 ... ${rest_username}=${REST_USERNAME}
187 ... ${rest_password}=${REST_PASSWORD}
George Keishing1cdc6dd2017-04-24 15:31:03 -0500188
189 # Description of argument(s):
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600190 # timeout REST login attempt time out.
191 # quiet Suppress console log if set.
192 # rest_username The REST username.
193 # rest_password The REST password.
George Keishing1cdc6dd2017-04-24 15:31:03 -0500194
195 Create Session openbmc ${AUTH_URI} timeout=${timeout} max_retries=3
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600196
Michael Walsha6723f22016-11-22 11:12:01 -0600197 ${headers}= Create Dictionary Content-Type=application/json
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600198 @{credentials}= Create List ${rest_username} ${rest_password}
Michael Walsha6723f22016-11-22 11:12:01 -0600199 ${data}= create dictionary data=@{credentials}
Michael Walshf00edee2016-12-09 14:10:26 -0600200 ${status} ${resp}= Run Keyword And Ignore Error Post Request openbmc
201 ... /login data=${data} headers=${headers}
202
203 Should Be Equal ${status} PASS msg=${resp}
204 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Chris Austenb29d2e82016-06-07 12:25:35 -0500205
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600206
George Keishinge8225522017-03-31 09:21:13 -0500207Log Out OpenBMC
manasarm604b8cd2018-01-29 12:14:20 +0530208 [Documentation] Log out of the openbmc REST session.
George Keishinge8225522017-03-31 09:21:13 -0500209
210 ${headers}= Create Dictionary Content-Type=application/json
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600211 ... X-Auth-Token=${XAUTH_TOKEN}
George Keishinge8225522017-03-31 09:21:13 -0500212 ${data}= Create dictionary data=@{EMPTY}
213
214 # If there is no active sesion it will throw the following exception
215 # "Non-existing index or alias 'openbmc'"
216 ${resp}= Post Request openbmc
217 ... /logout data=${data} headers=${headers}
218
219 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
220 ... msg=${resp}
221
Chris Austenb29d2e82016-06-07 12:25:35 -0500222Log Request
manasarm604b8cd2018-01-29 12:14:20 +0530223 [Documentation] Log the specific REST URI, method name on the console.
Chris Austenb29d2e82016-06-07 12:25:35 -0500224 [Arguments] &{kwargs}
Michael Walsha6723f22016-11-22 11:12:01 -0600225 ${msg}= Catenate SEPARATOR= URI: ${AUTH_URI} ${kwargs["base_uri"]}
226 ... , method: ${kwargs["method"]} , args: ${kwargs["args"]}
Chris Austenb29d2e82016-06-07 12:25:35 -0500227 Logging ${msg} console=True
228
229Log Response
manasarm604b8cd2018-01-29 12:14:20 +0530230 [Documentation] Log the response code on the console.
Chris Austenb29d2e82016-06-07 12:25:35 -0500231 [Arguments] ${resp}
Michael Walsha6723f22016-11-22 11:12:01 -0600232 ${msg}= Catenate SEPARATOR= Response code: ${resp.status_code}
233 ... , Content: ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500234 Logging ${msg} console=True
235
236Logging
manasarm604b8cd2018-01-29 12:14:20 +0530237 [Documentation] Log the specified message on the console.
Chris Austenb29d2e82016-06-07 12:25:35 -0500238 [Arguments] ${msg} ${console}=default False
239 Log ${msg} console=True
240
241Read Attribute
manasarm604b8cd2018-01-29 12:14:20 +0530242 [Documentation] Retrieve attribute value from URI and return result.
243 # Example result data for the attribute 'FieldModeEnabled' in
244 # "/xyz/openbmc_project/software/attr/" :
245 # 0
Gunnar Mills38032802016-12-12 13:43:40 -0600246 [Arguments] ${uri} ${attr} ${timeout}=10 ${quiet}=${QUIET}
manasarmc505e382018-02-05 14:05:48 +0530247 ... ${expected_value}=${EMPTY}
manasarm604b8cd2018-01-29 12:14:20 +0530248 # Description of argument(s):
249 # uri URI of the object that the attribute lives on
250 # (e.g. '/xyz/openbmc_project/software/').
251 # attr Name of the attribute (e.g. 'FieldModeEnabled').
252 # timeout Timeout for the REST call.
253 # quiet If enabled, turns off logging to console.
manasarmc505e382018-02-05 14:05:48 +0530254 # expected_value If this argument is not empty, the retrieved value
255 # must match this value.
manasarm604b8cd2018-01-29 12:14:20 +0530256
Steven Sombarb3489242018-12-13 15:59:02 -0600257 # Make sure uri ends with slash.
258 ${uri}= Add Trailing Slash ${uri}
259
260 ${resp}= OpenBMC Get Request ${uri}attr/${attr} timeout=${timeout}
Michael Walsha6723f22016-11-22 11:12:01 -0600261 ... quiet=${quiet}
Michael Walsh9cd61932017-01-17 16:11:02 -0600262 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Chris Austenb29d2e82016-06-07 12:25:35 -0500263 ${content}= To Json ${resp.content}
manasarmc505e382018-02-05 14:05:48 +0530264 Run Keyword If '${expected_value}' != '${EMPTY}'
265 ... Should Be Equal As Strings ${expected_value} ${content["data"]}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600266 [Return] ${content["data"]}
Chris Austenb29d2e82016-06-07 12:25:35 -0500267
Charles Paul Hoferf45e5ee2017-10-04 12:15:48 -0500268
Chris Austenb29d2e82016-06-07 12:25:35 -0500269Write Attribute
Charles Paul Hoferf45e5ee2017-10-04 12:15:48 -0500270 [Documentation] Write a D-Bus attribute with REST.
271 [Arguments] ${uri} ${attr} ${timeout}=10 ${verify}=${FALSE}
272 ... ${expected_value}=${EMPTY} &{kwargs}
273
274 # Description of argument(s):
275 # uri URI of the object that the attribute lives on
276 # (e.g. '/xyz/openbmc_project/software/').
277 # attr Name of the attribute (e.g. 'FieldModeEnabled').
278 # timeout Timeout for the REST call.
279 # verify If set to ${TRUE}, the attribute will be read back to
280 # ensure that its value is set to ${verify_attr}.
281 # expected_value Only used if verify is set to ${TRUE}. The value that
282 # ${attr} should be set to. This defaults to
283 # ${kwargs['data']. There are cases where the caller
284 # expects some other value in which case this value can
285 # be explicitly specified.
286 # kwargs Arguments passed to the REST call. This should always
287 # contain the value to set the property to at the 'data'
288 # key (e.g. data={"data": 1}).
289
George Keishingdf3e65f2018-12-18 13:06:56 -0600290 # Make sure uri ends with slash.
291 ${uri}= Add Trailing Slash ${uri}
292
Charles Paul Hoferf45e5ee2017-10-04 12:15:48 -0500293 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
George Keishingdf3e65f2018-12-18 13:06:56 -0600294 ${resp}= Openbmc Put Request ${base_uri}attr/${attr}
Michael Walsha6723f22016-11-22 11:12:01 -0600295 ... timeout=${timeout} &{kwargs}
Charles Paul Hoferf45e5ee2017-10-04 12:15:48 -0500296 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
297
298 # Verify the attribute was set correctly if the caller requested it.
299 Return From Keyword If ${verify} == ${FALSE}
300
301 ${expected_value}= Set Variable If '${expected_value}' == '${EMPTY}'
Charles Paul Hofer00401e72017-10-31 11:42:30 -0500302 ... ${kwargs['data']['data']} ${expected_value}
Charles Paul Hoferf45e5ee2017-10-04 12:15:48 -0500303 ${value}= Read Attribute ${uri} ${attr}
304 Should Be Equal ${value} ${expected_value}
305
Chris Austenb29d2e82016-06-07 12:25:35 -0500306Read Properties
manasarm604b8cd2018-01-29 12:14:20 +0530307 [Documentation] Read data part of the URI object and return result.
308 # Example result data:
309 # [u'/xyz/openbmc_project/software/cf7bf9d5',
310 # u'/xyz/openbmc_project/software/5ecb8b2c',
311 # u'/xyz/openbmc_project/software/active',
312 # u'/xyz/openbmc_project/software/functional']
George Keishing335f5362017-06-30 15:11:20 -0500313 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET}
manasarm604b8cd2018-01-29 12:14:20 +0530314 # Description of argument(s):
315 # uri URI of the object
316 # (e.g. '/xyz/openbmc_project/software/').
317 # timeout Timeout for the REST call.
318 # quiet If enabled, turns off logging to console.
319
George Keishing335f5362017-06-30 15:11:20 -0500320 ${resp}= OpenBMC Get Request ${uri} timeout=${timeout} quiet=${quiet}
321 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Michael Walshad66c952018-10-04 15:12:47 -0500322 ${content}= To Json Ordered ${resp.content}
323
George Keishing335f5362017-06-30 15:11:20 -0500324 [Return] ${content["data"]}
Chris Austenb29d2e82016-06-07 12:25:35 -0500325
326Call Method
manasarm604b8cd2018-01-29 12:14:20 +0530327 [Documentation] Invoke the specific REST service method.
Gunnar Mills38032802016-12-12 13:43:40 -0600328 [Arguments] ${uri} ${method} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
manasarm604b8cd2018-01-29 12:14:20 +0530329 # Description of arguments:
330 # uri The URI to establish connection with
331 # (e.g. '/xyz/openbmc_project/software/').
332 # timeout Timeout in seconds to establish connection with URI.
333 # quiet If enabled, turns off logging to console.
334 # kwargs Arguments passed to the REST call.
Michael Walsha6723f22016-11-22 11:12:01 -0600335
Chris Austenb29d2e82016-06-07 12:25:35 -0500336 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
George Keishing5c231a82019-02-05 09:02:04 -0600337 ${resp}= OpenBmc Post Request ${base_uri}action/${method}
Michael Walsha6723f22016-11-22 11:12:01 -0600338 ... timeout=${timeout} quiet=${quiet} &{kwargs}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600339 [Return] ${resp}
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500340
Sushil Singh47f80132019-08-27 04:53:24 -0500341
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500342Upload Image To BMC
Sushil Singh47f80132019-08-27 04:53:24 -0500343 [Documentation] Upload image to BMC via REST and return status code.
344 [Arguments] ${uri} ${timeout}=10 ${quiet}=${1}
345 ... ${valid_status_codes}=[${HTTP_OK}] &{kwargs}
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500346
347 # Description of argument(s):
Sushil Singh47f80132019-08-27 04:53:24 -0500348 # uri URI for uploading image via REST e.g.
349 # "/upload/image".
350 # timeout Time allocated for the REST command to
351 # return status (specified in Robot
352 # Framework Time Format e.g. "3 mins").
353 # quiet If enabled, turns off logging to console.
354 # valid_status_codes A list of status codes that are valid for
355 # the REST post command. This can be
356 # specified as a string the evaluates to a
357 # python object (e.g. [${HTTP_OK}]).
358 # kwargs A dictionary keys/values to be passed
359 # directly to Post Request.
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500360
361 Initialize OpenBMC ${timeout} quiet=${quiet}
362 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
363 ${headers}= Create Dictionary Content-Type=application/octet-stream
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600364 ... X-Auth-Token=${XAUTH_TOKEN} Accept=application/octet-stream
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500365 Set To Dictionary ${kwargs} headers ${headers}
366 Run Keyword If '${quiet}' == '${0}' Log Request method=Post
367 ... base_uri=${base_uri} args=&{kwargs}
368 ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
369 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
Sushil Singh47f80132019-08-27 04:53:24 -0500370 Valid Value ret.status_code ${valid_status_codes}
George Keishing08540c02017-07-19 09:42:50 -0500371 Delete All Sessions
Sushil Singh47f80132019-08-27 04:53:24 -0500372
373 [Return] ${ret.status_code}
374