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