Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library Collections |
| 3 | Library String |
| 4 | Library RequestsLibrary.RequestsKeywords |
| 5 | Library OperatingSystem |
| 6 | Resource ../lib/resource.txt |
| 7 | Library ../lib/disable_warning_urllib.py |
| 8 | |
| 9 | *** Variables *** |
| 10 | # Response codes |
| 11 | ${HTTP_CONTINUE} 100 |
| 12 | ${HTTP_SWITCHING_PROTOCOLS} 101 |
| 13 | ${HTTP_PROCESSING} 102 |
| 14 | ${HTTP_OK} 200 |
| 15 | ${HTTP_CREATED} 201 |
| 16 | ${HTTP_ACCEPTED} 202 |
| 17 | ${HTTP_NON_AUTHORITATIVE_INFORMATION} 203 |
| 18 | ${HTTP_NO_CONTENT} 204 |
| 19 | ${HTTP_RESET_CONTENT} 205 |
| 20 | ${HTTP_PARTIAL_CONTENT} 206 |
| 21 | ${HTTP_MULTI_STATUS} 207 |
| 22 | ${HTTP_IM_USED} 226 |
| 23 | ${HTTP_MULTIPLE_CHOICES} 300 |
| 24 | ${HTTP_MOVED_PERMANENTLY} 301 |
| 25 | ${HTTP_FOUND} 302 |
| 26 | ${HTTP_SEE_OTHER} 303 |
| 27 | ${HTTP_NOT_MODIFIED} 304 |
| 28 | ${HTTP_USE_PROXY} 305 |
| 29 | ${HTTP_TEMPORARY_REDIRECT} 307 |
| 30 | ${HTTP_BAD_REQUEST} 400 |
| 31 | ${HTTP_UNAUTHORIZED} 401 |
| 32 | ${HTTP_PAYMENT_REQUIRED} 402 |
| 33 | ${HTTP_FORBIDDEN} 403 |
| 34 | ${HTTP_NOT_FOUND} 404 |
| 35 | ${HTTP_METHOD_NOT_ALLOWED} 405 |
| 36 | ${HTTP_NOT_ACCEPTABLE} 406 |
| 37 | ${HTTP_PROXY_AUTHENTICATION_REQUIRED} 407 |
| 38 | ${HTTP_REQUEST_TIMEOUT} 408 |
| 39 | ${HTTP_CONFLICT} 409 |
| 40 | ${HTTP_GONE} 410 |
| 41 | ${HTTP_LENGTH_REQUIRED} 411 |
| 42 | ${HTTP_PRECONDITION_FAILED} 412 |
| 43 | ${HTTP_REQUEST_ENTITY_TOO_LARGE} 413 |
| 44 | ${HTTP_REQUEST_URI_TOO_LONG} 414 |
| 45 | ${HTTP_UNSUPPORTED_MEDIA_TYPE} 415 |
| 46 | ${HTTP_REQUESTED_RANGE_NOT_SATISFIABLE} 416 |
| 47 | ${HTTP_EXPECTATION_FAILED} 417 |
| 48 | ${HTTP_UNPROCESSABLE_ENTITY} 422 |
| 49 | ${HTTP_LOCKED} 423 |
| 50 | ${HTTP_FAILED_DEPENDENCY} 424 |
| 51 | ${HTTP_UPGRADE_REQUIRED} 426 |
| 52 | ${HTTP_INTERNAL_SERVER_ERROR} 500 |
| 53 | ${HTTP_NOT_IMPLEMENTED} 501 |
| 54 | ${HTTP_BAD_GATEWAY} 502 |
| 55 | ${HTTP_SERVICE_UNAVAILABLE} 503 |
| 56 | ${HTTP_GATEWAY_TIMEOUT} 504 |
| 57 | ${HTTP_HTTP_VERSION_NOT_SUPPORTED} 505 |
| 58 | ${HTTP_INSUFFICIENT_STORAGE} 507 |
| 59 | ${HTTP_NOT_EXTENDED} 510 |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 60 | # Assign default value to QUIET for programs which may not define it. |
| 61 | ${QUIET} ${0} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 62 | |
| 63 | *** Keywords *** |
| 64 | OpenBMC Get Request |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 65 | [Documentation] Do REST GET request and return the result. |
| 66 | # Example result data: |
| 67 | # Response code:200, Content:{ |
| 68 | # "data": [ |
| 69 | # "/xyz/openbmc_project/state/host0", |
| 70 | # "/xyz/openbmc_project/state/chassis0", |
| 71 | # "/xyz/openbmc_project/state/bmc0" |
| 72 | # ], |
| 73 | # "message": "200 OK", |
| 74 | # "status": "ok" |
| 75 | # } |
George Keishing | 41c44cf | 2017-11-15 08:02:59 -0600 | [diff] [blame] | 76 | [Arguments] ${uri} ${timeout}=30 ${quiet}=${QUIET} &{kwargs} |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 77 | # Description of argument(s): |
| 78 | # uri The URI to establish connection with |
| 79 | # (e.g. '/xyz/openbmc_project/software/'). |
| 80 | # timeout Timeout in seconds to establish connection with URI. |
| 81 | # quiet If enabled, turns off logging to console. |
| 82 | # kwargs Any additional arguments to be passed directly to the |
| 83 | # Get Request call. For example, the caller might |
| 84 | # set kwargs as follows: |
| 85 | # ${kwargs}= Create Dictionary allow_redirect=${True}. |
Michael Walsh | f00edee | 2016-12-09 14:10:26 -0600 | [diff] [blame] | 86 | |
| 87 | Initialize OpenBMC ${timeout} quiet=${quiet} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 88 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 89 | Run Keyword If '${quiet}' == '${0}' Log Request method=Get |
| 90 | ... base_uri=${base_uri} args=&{kwargs} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 91 | ${ret}= Get Request openbmc ${base_uri} &{kwargs} timeout=${timeout} |
| 92 | Run Keyword If '${quiet}' == '${0}' Log Response ${ret} |
George Keishing | 08540c0 | 2017-07-19 09:42:50 -0500 | [diff] [blame] | 93 | Delete All Sessions |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 94 | [Return] ${ret} |
| 95 | |
| 96 | OpenBMC Post Request |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 97 | [Documentation] Do REST POST request and return the result. |
| 98 | # Example result data: |
| 99 | # <Response [200]> |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 100 | [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs} |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 101 | # Description of argument(s): |
| 102 | # uri The URI to establish connection with |
| 103 | # (e.g. '/xyz/openbmc_project/software/'). |
| 104 | # timeout Timeout in seconds to establish connection with URI. |
| 105 | # quiet If enabled, turns off logging to console. |
| 106 | # kwargs Any additional arguments to be passed directly to the |
| 107 | # Post Request call. For example, the caller might |
| 108 | # set kwargs as follows: |
| 109 | # ${kwargs}= Create Dictionary allow_redirect=${True}. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 110 | |
Michael Walsh | f00edee | 2016-12-09 14:10:26 -0600 | [diff] [blame] | 111 | Initialize OpenBMC ${timeout} quiet=${quiet} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 112 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
| 113 | ${headers}= Create Dictionary Content-Type=application/json |
| 114 | set to dictionary ${kwargs} headers ${headers} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 115 | Run Keyword If '${quiet}' == '${0}' Log Request method=Post |
| 116 | ... base_uri=${base_uri} args=&{kwargs} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 117 | ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout} |
| 118 | Run Keyword If '${quiet}' == '${0}' Log Response ${ret} |
George Keishing | 08540c0 | 2017-07-19 09:42:50 -0500 | [diff] [blame] | 119 | Delete All Sessions |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 120 | [Return] ${ret} |
| 121 | |
| 122 | OpenBMC Put Request |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 123 | [Documentation] Do REST PUT request on the resource identified by the URI. |
Rahul Maheshwari | 79c1294 | 2016-10-17 09:39:17 -0500 | [diff] [blame] | 124 | [Arguments] ${uri} ${timeout}=10 &{kwargs} |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 125 | # Description of argument(s): |
| 126 | # uri The URI to establish connection with |
| 127 | # (e.g. '/xyz/openbmc_project/software/'). |
| 128 | # timeout Timeout in seconds to establish connection with URI. |
| 129 | # kwargs Arguments passed to the REST call. |
| 130 | # kwargs Any additional arguments to be passed directly to the |
| 131 | # Put Request call. For example, the caller might |
| 132 | # set kwargs as follows: |
| 133 | # ${kwargs}= Create Dictionary allow_redirect=${True}. |
Michael Walsh | f00edee | 2016-12-09 14:10:26 -0600 | [diff] [blame] | 134 | |
| 135 | Initialize OpenBMC ${timeout} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 136 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
| 137 | ${headers}= Create Dictionary Content-Type=application/json |
| 138 | set to dictionary ${kwargs} headers ${headers} |
| 139 | Log Request method=Put base_uri=${base_uri} args=&{kwargs} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 140 | ${ret}= Put Request openbmc ${base_uri} &{kwargs} timeout=${timeout} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 141 | Log Response ${ret} |
George Keishing | 08540c0 | 2017-07-19 09:42:50 -0500 | [diff] [blame] | 142 | Delete All Sessions |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 143 | [Return] ${ret} |
| 144 | |
| 145 | OpenBMC Delete Request |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 146 | [Documentation] Do REST request to delete the resource identified by the |
| 147 | ... URI. |
Rahul Maheshwari | 79c1294 | 2016-10-17 09:39:17 -0500 | [diff] [blame] | 148 | [Arguments] ${uri} ${timeout}=10 &{kwargs} |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 149 | # Description of argument(s): |
| 150 | # uri The URI to establish connection with |
| 151 | # (e.g. '/xyz/openbmc_project/software/'). |
| 152 | # timeout Timeout in seconds to establish connection with URI. |
| 153 | # kwargs Any additional arguments to be passed directly to the |
| 154 | # Delete Request call. For example, the caller might |
| 155 | # set kwargs as follows: |
| 156 | # ${kwargs}= Create Dictionary allow_redirect=${True}. |
Michael Walsh | f00edee | 2016-12-09 14:10:26 -0600 | [diff] [blame] | 157 | |
| 158 | Initialize OpenBMC ${timeout} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 159 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
| 160 | Log Request method=Delete base_uri=${base_uri} args=&{kwargs} |
George Keishing | 0e7c3a0 | 2017-04-17 05:01:14 -0500 | [diff] [blame] | 161 | ${ret}= Delete Request openbmc ${base_uri} &{kwargs} timeout=${timeout} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 162 | Log Response ${ret} |
George Keishing | 08540c0 | 2017-07-19 09:42:50 -0500 | [diff] [blame] | 163 | Delete All Sessions |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 164 | [Return] ${ret} |
| 165 | |
| 166 | Initialize OpenBMC |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 167 | [Documentation] Do a REST login connection within specified time. |
George Keishing | 1cdc6dd | 2017-04-24 15:31:03 -0500 | [diff] [blame] | 168 | [Arguments] ${timeout}=20 ${quiet}=${1} |
George Keishing | f133167 | 2018-01-18 05:19:02 -0600 | [diff] [blame] | 169 | ... ${OPENBMC_USERNAME}=${OPENBMC_USERNAME} |
| 170 | ... ${OPENBMC_PASSWORD}=${OPENBMC_PASSWORD} |
Michael Walsh | f00edee | 2016-12-09 14:10:26 -0600 | [diff] [blame] | 171 | |
George Keishing | 1cdc6dd | 2017-04-24 15:31:03 -0500 | [diff] [blame] | 172 | # Description of argument(s): |
| 173 | # timeout REST login attempt time out. |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 174 | # quiet Suppress console log if set. |
George Keishing | 1cdc6dd | 2017-04-24 15:31:03 -0500 | [diff] [blame] | 175 | |
| 176 | # TODO : Task to revert this changes openbmc/openbmc-test-automation#532 |
| 177 | # This will retry at 20 second interval. |
| 178 | Wait Until Keyword Succeeds 40 sec 20 sec |
| 179 | ... Post Login Request ${timeout} ${quiet} |
George Keishing | f133167 | 2018-01-18 05:19:02 -0600 | [diff] [blame] | 180 | ... ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
George Keishing | 1cdc6dd | 2017-04-24 15:31:03 -0500 | [diff] [blame] | 181 | |
| 182 | Post Login Request |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 183 | [Documentation] Do REST login request. |
George Keishing | 1cdc6dd | 2017-04-24 15:31:03 -0500 | [diff] [blame] | 184 | [Arguments] ${timeout}=20 ${quiet}=${1} |
George Keishing | f133167 | 2018-01-18 05:19:02 -0600 | [diff] [blame] | 185 | ... ${OPENBMC_USERNAME}=${OPENBMC_USERNAME} |
| 186 | ... ${OPENBMC_PASSWORD}=${OPENBMC_PASSWORD} |
George Keishing | 1cdc6dd | 2017-04-24 15:31:03 -0500 | [diff] [blame] | 187 | |
| 188 | # Description of argument(s): |
| 189 | # timeout REST login attempt time out. |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 190 | # quiet Suppress console log if set. |
George Keishing | 1cdc6dd | 2017-04-24 15:31:03 -0500 | [diff] [blame] | 191 | |
| 192 | Create Session openbmc ${AUTH_URI} timeout=${timeout} max_retries=3 |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 193 | ${headers}= Create Dictionary Content-Type=application/json |
| 194 | @{credentials}= Create List ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 195 | ${data}= create dictionary data=@{credentials} |
Michael Walsh | f00edee | 2016-12-09 14:10:26 -0600 | [diff] [blame] | 196 | ${status} ${resp}= Run Keyword And Ignore Error Post Request openbmc |
| 197 | ... /login data=${data} headers=${headers} |
| 198 | |
| 199 | Should Be Equal ${status} PASS msg=${resp} |
| 200 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 201 | |
George Keishing | e822552 | 2017-03-31 09:21:13 -0500 | [diff] [blame] | 202 | Log Out OpenBMC |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 203 | [Documentation] Log out of the openbmc REST session. |
George Keishing | e822552 | 2017-03-31 09:21:13 -0500 | [diff] [blame] | 204 | |
| 205 | ${headers}= Create Dictionary Content-Type=application/json |
| 206 | ${data}= Create dictionary data=@{EMPTY} |
| 207 | |
| 208 | # If there is no active sesion it will throw the following exception |
| 209 | # "Non-existing index or alias 'openbmc'" |
| 210 | ${resp}= Post Request openbmc |
| 211 | ... /logout data=${data} headers=${headers} |
| 212 | |
| 213 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 214 | ... msg=${resp} |
| 215 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 216 | Log Request |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 217 | [Documentation] Log the specific REST URI, method name on the console. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 218 | [Arguments] &{kwargs} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 219 | ${msg}= Catenate SEPARATOR= URI: ${AUTH_URI} ${kwargs["base_uri"]} |
| 220 | ... , method: ${kwargs["method"]} , args: ${kwargs["args"]} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 221 | Logging ${msg} console=True |
| 222 | |
| 223 | Log Response |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 224 | [Documentation] Log the response code on the console. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 225 | [Arguments] ${resp} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 226 | ${msg}= Catenate SEPARATOR= Response code: ${resp.status_code} |
| 227 | ... , Content: ${resp.content} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 228 | Logging ${msg} console=True |
| 229 | |
| 230 | Logging |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 231 | [Documentation] Log the specified message on the console. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 232 | [Arguments] ${msg} ${console}=default False |
| 233 | Log ${msg} console=True |
| 234 | |
| 235 | Read Attribute |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 236 | [Documentation] Retrieve attribute value from URI and return result. |
| 237 | # Example result data for the attribute 'FieldModeEnabled' in |
| 238 | # "/xyz/openbmc_project/software/attr/" : |
| 239 | # 0 |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 240 | [Arguments] ${uri} ${attr} ${timeout}=10 ${quiet}=${QUIET} |
manasarm | c505e38 | 2018-02-05 14:05:48 +0530 | [diff] [blame] | 241 | ... ${expected_value}=${EMPTY} |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 242 | # Description of argument(s): |
| 243 | # uri URI of the object that the attribute lives on |
| 244 | # (e.g. '/xyz/openbmc_project/software/'). |
| 245 | # attr Name of the attribute (e.g. 'FieldModeEnabled'). |
| 246 | # timeout Timeout for the REST call. |
| 247 | # quiet If enabled, turns off logging to console. |
manasarm | c505e38 | 2018-02-05 14:05:48 +0530 | [diff] [blame] | 248 | # expected_value If this argument is not empty, the retrieved value |
| 249 | # must match this value. |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 250 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 251 | ${resp}= OpenBMC Get Request ${uri}/attr/${attr} timeout=${timeout} |
| 252 | ... quiet=${quiet} |
Michael Walsh | 9cd6193 | 2017-01-17 16:11:02 -0600 | [diff] [blame] | 253 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 254 | ${content}= To Json ${resp.content} |
manasarm | c505e38 | 2018-02-05 14:05:48 +0530 | [diff] [blame] | 255 | Run Keyword If '${expected_value}' != '${EMPTY}' |
| 256 | ... Should Be Equal As Strings ${expected_value} ${content["data"]} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 257 | [Return] ${content["data"]} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 258 | |
Charles Paul Hofer | f45e5ee | 2017-10-04 12:15:48 -0500 | [diff] [blame] | 259 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 260 | Write Attribute |
Charles Paul Hofer | f45e5ee | 2017-10-04 12:15:48 -0500 | [diff] [blame] | 261 | [Documentation] Write a D-Bus attribute with REST. |
| 262 | [Arguments] ${uri} ${attr} ${timeout}=10 ${verify}=${FALSE} |
| 263 | ... ${expected_value}=${EMPTY} &{kwargs} |
| 264 | |
| 265 | # Description of argument(s): |
| 266 | # uri URI of the object that the attribute lives on |
| 267 | # (e.g. '/xyz/openbmc_project/software/'). |
| 268 | # attr Name of the attribute (e.g. 'FieldModeEnabled'). |
| 269 | # timeout Timeout for the REST call. |
| 270 | # verify If set to ${TRUE}, the attribute will be read back to |
| 271 | # ensure that its value is set to ${verify_attr}. |
| 272 | # expected_value Only used if verify is set to ${TRUE}. The value that |
| 273 | # ${attr} should be set to. This defaults to |
| 274 | # ${kwargs['data']. There are cases where the caller |
| 275 | # expects some other value in which case this value can |
| 276 | # be explicitly specified. |
| 277 | # kwargs Arguments passed to the REST call. This should always |
| 278 | # contain the value to set the property to at the 'data' |
| 279 | # key (e.g. data={"data": 1}). |
| 280 | |
| 281 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
| 282 | ${resp}= Openbmc Put Request ${base_uri}/attr/${attr} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 283 | ... timeout=${timeout} &{kwargs} |
Charles Paul Hofer | f45e5ee | 2017-10-04 12:15:48 -0500 | [diff] [blame] | 284 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 285 | |
| 286 | # Verify the attribute was set correctly if the caller requested it. |
| 287 | Return From Keyword If ${verify} == ${FALSE} |
| 288 | |
| 289 | ${expected_value}= Set Variable If '${expected_value}' == '${EMPTY}' |
Charles Paul Hofer | 00401e7 | 2017-10-31 11:42:30 -0500 | [diff] [blame] | 290 | ... ${kwargs['data']['data']} ${expected_value} |
Charles Paul Hofer | f45e5ee | 2017-10-04 12:15:48 -0500 | [diff] [blame] | 291 | ${value}= Read Attribute ${uri} ${attr} |
| 292 | Should Be Equal ${value} ${expected_value} |
| 293 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 294 | Read Properties |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 295 | [Documentation] Read data part of the URI object and return result. |
| 296 | # Example result data: |
| 297 | # [u'/xyz/openbmc_project/software/cf7bf9d5', |
| 298 | # u'/xyz/openbmc_project/software/5ecb8b2c', |
| 299 | # u'/xyz/openbmc_project/software/active', |
| 300 | # u'/xyz/openbmc_project/software/functional'] |
George Keishing | 335f536 | 2017-06-30 15:11:20 -0500 | [diff] [blame] | 301 | [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 302 | # Description of argument(s): |
| 303 | # uri URI of the object |
| 304 | # (e.g. '/xyz/openbmc_project/software/'). |
| 305 | # timeout Timeout for the REST call. |
| 306 | # quiet If enabled, turns off logging to console. |
| 307 | |
George Keishing | 335f536 | 2017-06-30 15:11:20 -0500 | [diff] [blame] | 308 | ${resp}= OpenBMC Get Request ${uri} timeout=${timeout} quiet=${quiet} |
| 309 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 310 | ${content}= To Json ${resp.content} |
| 311 | [Return] ${content["data"]} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 312 | |
| 313 | Call Method |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 314 | [Documentation] Invoke the specific REST service method. |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 315 | [Arguments] ${uri} ${method} ${timeout}=10 ${quiet}=${QUIET} &{kwargs} |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 316 | # Description of arguments: |
| 317 | # uri The URI to establish connection with |
| 318 | # (e.g. '/xyz/openbmc_project/software/'). |
| 319 | # timeout Timeout in seconds to establish connection with URI. |
| 320 | # quiet If enabled, turns off logging to console. |
| 321 | # kwargs Arguments passed to the REST call. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 322 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 323 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 324 | ${resp}= OpenBmc Post Request ${base_uri}/action/${method} |
| 325 | ... timeout=${timeout} quiet=${quiet} &{kwargs} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 326 | [Return] ${resp} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 327 | |
| 328 | Upload Image To BMC |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 329 | [Documentation] Upload image to BMC device using REST POST operation. |
George Keishing | ad9a880 | 2017-08-08 12:41:48 -0500 | [diff] [blame] | 330 | [Arguments] ${uri} ${timeout}=10 ${quiet}=${1} &{kwargs} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 331 | |
| 332 | # Description of argument(s): |
| 333 | # uri URI for uploading image via REST e.g. "/upload/image". |
| 334 | # timeout Time allocated for the REST command to return status |
| 335 | # (specified in Robot Framework Time Format e.g. "3 mins"). |
manasarm | 604b8cd | 2018-01-29 12:14:20 +0530 | [diff] [blame] | 336 | # quiet If enabled, turns off logging to console. |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 337 | # kwargs A dictionary keys/values to be passed directly to |
| 338 | # Post Request. |
| 339 | |
| 340 | Initialize OpenBMC ${timeout} quiet=${quiet} |
| 341 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
| 342 | ${headers}= Create Dictionary Content-Type=application/octet-stream |
| 343 | ... Accept=application/octet-stream |
| 344 | Set To Dictionary ${kwargs} headers ${headers} |
| 345 | Run Keyword If '${quiet}' == '${0}' Log Request method=Post |
| 346 | ... base_uri=${base_uri} args=&{kwargs} |
| 347 | ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout} |
| 348 | Run Keyword If '${quiet}' == '${0}' Log Response ${ret} |
| 349 | Should Be Equal As Strings ${ret.status_code} ${HTTP_OK} |
George Keishing | 08540c0 | 2017-07-19 09:42:50 -0500 | [diff] [blame] | 350 | Delete All Sessions |