Redfish POST request keyword
Change-Id: I6fd5aa3a5ba5abf2c5a2adc2d144333bc2c1d0fc
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/redfish_client.robot b/lib/redfish_client.robot
index 7b2d81e..513d121 100644
--- a/lib/redfish_client.robot
+++ b/lib/redfish_client.robot
@@ -64,7 +64,7 @@
# resp_check By default check the response status and return JSON.
# timeout Timeout in seconds to establish connection with URI.
- ${base_uri} = Catenate SEPARATOR= ${REDFISH_BASE_URI} ${uri_suffix}
+ ${uri} = Catenate SEPARATOR= ${REDFISH_BASE_URI} ${uri_suffix}
# Create session, token list [vIP8IxCQlQ, Nq9l7fgP8FFeFg3QgCpr].
${id_auth_list} = Create List ${session_id} ${xauth_token}
@@ -81,7 +81,7 @@
... X-Auth-Token=${xauth_token}
${resp}= Get Request
- ... openbmc ${base_uri} headers=${headers} timeout=${timeout}
+ ... openbmc ${uri} headers=${headers} timeout=${timeout}
Return From Keyword If ${resp_check} == ${0} ${resp}
@@ -91,6 +91,41 @@
[Return] ${content}
+Redfish Post Request
+ [Documentation] Do redfish POST request.
+ [Arguments] ${uri_suffix}
+ ... &{kwargs}
+ ... ${timeout}=30
+
+ # Description of argument(s):
+ # uri_suffix The URI to establish connection with
+ # (e.g. '/Systems/1/Actions/ComputerSystem.Reset').
+ # kwargs Any additional arguments to be passed directly to the
+ # Post Request. For example, the caller might
+ # set kwargs as follows:
+ # ${kwargs}= Create Dictionary allow_redirect=${True}.
+ # timeout Timeout in seconds to establish connection with URI.
+
+ ${uri}= Catenate SEPARATOR= ${REDFISH_BASE_URI} ${uri_suffix}
+ # Set session and auth token variable.
+ ${session_id} ${xauth_token}= Redfish Login Request
+
+ # Set session URI path.
+ ${session_uri}=
+ ... Catenate SEPARATOR= ${REDFISH_SESSION_URI} ${session_id}
+
+ # Example: "X-Auth-Token: 3la1JUf1vY4yN2dNOwun"
+ ${headers}= Create Dictionary Content-Type=application/json
+ ... X-Auth-Token=${xauth_token}
+
+ ${resp}= Post Request
+ ... openbmc ${uri} &{kwargs} headers=${headers} timeout=${timeout}
+
+ Redfish Delete Request ${session_uri} ${xauth_token}
+
+ Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
+
+
Redfish Delete Request
[Documentation] Delete the resource identified by the URI.
[Arguments] ${uri_suffix}
@@ -105,7 +140,7 @@
# timeout Timeout in seconds to establish connection with URI.
# resp_check By default check the response status.
- ${base_uri} = Catenate SEPARATOR= ${REDFISH_BASE_URI} ${uri_suffix}
+ ${uri} = Catenate SEPARATOR= ${REDFISH_BASE_URI} ${uri_suffix}
# Example: "X-Auth-Token: 3la1JUf1vY4yN2dNOwun"
${headers} = Create Dictionary Content-Type=application/json
@@ -113,7 +148,7 @@
# Delete server session.
${resp}= Delete Request openbmc
- ... ${base_uri} headers=${headers} timeout=${timeout}
+ ... ${uri} headers=${headers} timeout=${timeout}
Return From Keyword If ${resp_check} == ${0} ${resp}