blob: 7783060cd71c7ce920c499bcfb5af8eac02251c4 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The private interface for interacting with Openstack. It handles low level stuff like managing the authtoken and Openstack required fields
3
jf986099c63292017-03-09 15:28:42 -05004Library Collections
DR695Hccff30b2017-02-17 18:44:24 -05005Library OpenstackLibrary
6Library RequestsLibrary
jf986099c63292017-03-09 15:28:42 -05007Library UUID
DR695Hccff30b2017-02-17 18:44:24 -05008Resource ../global_properties.robot
9
jf986099c63292017-03-09 15:28:42 -050010*** Variables ***
11#**************** Test Case Variables ******************
12${OPENSTACK_SERVICE_REGION}
13
DR695Hccff30b2017-02-17 18:44:24 -050014*** Keywords ***
15Internal Get Openstack
16 [Documentation] Runs an Openstack Get Request and returns the response
jf986099c63292017-03-09 15:28:42 -050017 [Arguments] ${alias} ${service_type} ${url_ext} ${data_path}=
18 ${region}= Get Openstack Region
19 ${resp}= Internal Get Openstack With Region ${alias} ${service_type} ${region} ${url_ext} ${data_path}
20 [Return] ${resp}
21
22Internal Get Openstack With Region
23 [Documentation] Runs an Openstack Get Request and returns the response
24 [Arguments] ${alias} ${service_type} ${region} ${url_ext} ${data_path}=
DR695Hccff30b2017-02-17 18:44:24 -050025 Log Internal Get Openstack values alias=${alias} service_type=${service_type} region=${region} url_ext=${url_ext} data_path=${data_path}
26 ${url}= Get Openstack Service Url ${alias} ${service_type} ${region}
27 ${uuid}= Generate UUID
28 ${session_alias}= Catenate openstack-${uuid}
jf986099c63292017-03-09 15:28:42 -050029 ${session}= Create Session ${session_alias} ${url}${url_ext} verify=True
DR695Hccff30b2017-02-17 18:44:24 -050030 ${token}= Get Openstack Token ${alias}
31 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} X-Auth-Token=${token}
32 ${resp}= Get Request ${session_alias} ${data_path} headers=${headers}
jf986099c63292017-03-09 15:28:42 -050033 Log Received response from openstack ${resp.text}
DR695Hccff30b2017-02-17 18:44:24 -050034 [Return] ${resp}
35
36Internal Post Openstack
37 [Documentation] Runs an Openstack Post Response and returns the response
jf986099c63292017-03-09 15:28:42 -050038 [Arguments] ${alias} ${service_type} ${url_ext} ${data_path}= ${data}=
39 ${region}= Get Openstack Region
DR695Hccff30b2017-02-17 18:44:24 -050040 Log Internal Post Openstack values alias=${alias} service_type=${service_type} region=${region} url_ext=${url_ext} data_path=${data_path}
41 ${url}= Get Openstack Service Url ${alias} ${service_type} ${region}
42 ${uuid}= Generate UUID
43 ${session_alias}= Catenate openstack-${uuid}
jf986099c63292017-03-09 15:28:42 -050044 ${session}= Create Session ${session_alias} ${url}${url_ext} verify=True
DR695Hccff30b2017-02-17 18:44:24 -050045 ${token}= Get Openstack Token ${alias}
46 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} X-Auth-Token=${token}
47 ${resp}= Post Request ${session_alias} ${data_path} data=${data} headers=${headers}
48 Log Received response from openstack ${resp.text}
49 [Return] ${resp}
50
51Internal Delete Openstack
52 [Documentation] Runs an Openstack Delete Request and returns the response
jf986099c63292017-03-09 15:28:42 -050053 [Arguments] ${alias} ${service_type} ${url_ext} ${data_path}=
54 ${region}= Get Openstack Region
DR695Hccff30b2017-02-17 18:44:24 -050055 Log Internal Post Openstack values alias=${alias} service_type=${service_type} region=${region} url_ext=${url_ext} data_path=${data_path}
56 ${url}= Get Openstack Service Url ${alias} ${service_type} ${region}
57 ${uuid}= Generate UUID
58 ${session_alias}= Catenate openstack-${uuid}
59 ${session}= Create Session ${session_alias} ${url}${url_ext} verify=True
60 ${token}= Get Openstack Token ${alias}
61 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} X-Auth-Token=${token}
62 ${resp}= Delete Request ${session_alias} ${data_path} headers=${headers}
63 Log Received response from openstack ${resp.text}
jf986099c63292017-03-09 15:28:42 -050064 [Return] ${resp}
65
66Get Openstack Region
67 [Documentation] Returns the current openstack region test variable
68 ... Defaults to the openstack region of the Robot VM
69 Return From Keyword If len('${OPENSTACK_SERVICE_REGION}') > 0 ${OPENSTACK_SERVICE_REGION}
Jerry Flood028e1852017-03-16 16:44:17 -040070 Set Test Variable ${OPENSTACK_SERVICE_REGION} ${GLOBAL_INJECTED_REGION}
jf986099c63292017-03-09 15:28:42 -050071 Log Setting OPENSTACK_SERVICE_REGION=${OPENSTACK_SERVICE_REGION}
72 [Return] ${OPENSTACK_SERVICE_REGION}
73
74Set Openstack Region Test Variable
75 [Documentation] Sets the openstack service region of the current test case
76 ... To be used to override the service region of the Robot VM (default)
77 [Arguments] ${openstack_service_region}
78 Set Test Variable ${OPENSTACK_SERVICE_REGION} ${openstack_service_region}
79