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