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