DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation The private interface for interacting with Openstack. It handles low level stuff like managing the authtoken and Openstack required fields |
| 3 | |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 4 | Library Collections |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 5 | Library OpenstackLibrary |
| 6 | Library RequestsLibrary |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 7 | Library UUID |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 8 | Resource ../global_properties.robot |
| 9 | |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 10 | *** Variables *** |
| 11 | #**************** Test Case Variables ****************** |
| 12 | ${OPENSTACK_SERVICE_REGION} |
| 13 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 14 | *** Keywords *** |
| 15 | Internal Get Openstack |
| 16 | [Documentation] Runs an Openstack Get Request and returns the response |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 17 | [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 | |
| 22 | Internal 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}= |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 25 | 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} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 29 | ${session}= Create Session ${session_alias} ${url}${url_ext} verify=True |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 30 | ${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} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 33 | Log Received response from openstack ${resp.text} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 34 | [Return] ${resp} |
| 35 | |
| 36 | Internal Post Openstack |
| 37 | [Documentation] Runs an Openstack Post Response and returns the response |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 38 | [Arguments] ${alias} ${service_type} ${url_ext} ${data_path}= ${data}= |
| 39 | ${region}= Get Openstack Region |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 40 | 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} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 44 | ${session}= Create Session ${session_alias} ${url}${url_ext} verify=True |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 45 | ${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 | |
| 51 | Internal Delete Openstack |
| 52 | [Documentation] Runs an Openstack Delete Request and returns the response |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 53 | [Arguments] ${alias} ${service_type} ${url_ext} ${data_path}= |
| 54 | ${region}= Get Openstack Region |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 55 | 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} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 64 | [Return] ${resp} |
| 65 | |
| 66 | Get 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 Flood | 028e185 | 2017-03-16 16:44:17 -0400 | [diff] [blame] | 70 | Set Test Variable ${OPENSTACK_SERVICE_REGION} ${GLOBAL_INJECTED_REGION} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 71 | Log Setting OPENSTACK_SERVICE_REGION=${OPENSTACK_SERVICE_REGION} |
| 72 | [Return] ${OPENSTACK_SERVICE_REGION} |
| 73 | |
| 74 | Set 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 | |