DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 2 | Documentation The interface for interacting with Openstack Heat API. |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 3 | Library OpenstackLibrary |
| 4 | Library RequestsLibrary |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 5 | Library UUID |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 6 | Library OperatingSystem |
| 7 | Library HEATUtils |
| 8 | Library StringTemplater |
| 9 | Library Collections |
| 10 | Resource ../global_properties.robot |
| 11 | Resource ../json_templater.robot |
| 12 | Resource openstack_common.robot |
| 13 | |
| 14 | *** Variables *** |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 15 | ${OPENSTACK_HEAT_API_VERSION} /v1 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 16 | ${OPENSTACK_HEAT_STACK_PATH} /stacks |
| 17 | ${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} robot/assets/templates/heat_add_stack.template |
| 18 | |
| 19 | |
| 20 | *** Keywords *** |
| 21 | Get Openstack Stacks |
| 22 | [Documentation] Returns the openstack stacks info |
| 23 | [Arguments] ${alias} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 24 | ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 25 | [Return] ${resp.json()} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 26 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 27 | Get Openstack Stack |
| 28 | [Documentation] Returns the openstack stacks info for the given stack name |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 29 | [Arguments] ${alias} ${stack_name} |
| 30 | ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} /${stack_name} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 31 | [Return] ${resp.json()} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 32 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 33 | Create Openstack Stack |
| 34 | [Documentation] Takes an openstack heat yaml and returns the created stack |
| 35 | [Arguments] ${alias} ${request} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 36 | ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} data_path= data=${request} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 37 | [Return] ${resp.json()} |
| 38 | |
| 39 | Make Add Stack Request |
| 40 | [Documentation] Makes a JSON Add Stack Request from YAML template and env files |
| 41 | [Arguments] ${name} ${template} ${env} |
| 42 | ${templatedata}= Template Yaml To Json ${template} |
| 43 | ${envdata}= Env Yaml To Json ${env} |
| 44 | ${dict}= Create Dictionary template=${templatedata} parameters=${envdata} stack_name=${name} |
| 45 | ${resp}= OperatingSystem.Get File ${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} |
| 46 | ${request}= Template String ${resp} ${dict} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 47 | Log $request |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 48 | [Return] ${request} |
| 49 | |
| 50 | Delete Openstack Stack |
| 51 | [Documentation] Deletes and Openstack Stack for the passed name and id |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 52 | [Arguments] ${alias} ${stack_name} ${stack_id} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 53 | ${data_path}= Catenate /${stack_name}/${stack_id} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 54 | ${resp}= Internal Delete Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} data_path=${data_path} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 55 | Should Be Equal As Strings 204 ${resp.status_code} |
| 56 | [Return] ${resp} |
| 57 | |
| 58 | Get Stack Details |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 59 | [Documentation] Gets all of the information necessary for tearing down an existing Openstack Stack |
| 60 | [Arguments] ${alias} ${stack_name} |
| 61 | ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} /${stack_name} |
| 62 | ${result}= Stack Info Parse ${resp.json()} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 63 | [Return] ${result} |
| 64 | |
| 65 | Get Stack Template |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 66 | [Documentation] Gets all of the template information of an existing Openstack Stack |
| 67 | [Arguments] ${alias} ${stack_name} ${stack_id} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 68 | ${data_path}= Catenate /${stack_name}/${stack_id}/template |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 69 | ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} ${data_path} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 70 | ${template}= Catenate ${resp.json()} |
| 71 | [Return] ${template} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 72 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 73 | Get Stack Resources |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 74 | [Documentation] Gets all of the resources of an existing Openstack Stack |
| 75 | [Arguments] ${alias} ${stack_name} ${stack_id} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 76 | ${data_path}= Catenate /${stack_name}/${stack_id}/resources |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 77 | ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} ${data_path} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 78 | [Return] ${resp.json()} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 79 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 80 | Wait for Stack to Be Deployed |
Jerry Flood | f67ce0e | 2017-03-20 16:59:23 -0400 | [diff] [blame] | 81 | [Arguments] ${alias} ${stack_name} ${timeout}=${GLOBAL_OPENSTACK_STACK_DEPLOYMENT_TIMEOUT} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 82 | ${stack_info}= Wait Until Keyword Succeeds ${timeout} 30 sec Get Deployed Stack ${alias} ${stack_name} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 83 | ${status}= Get From Dictionary ${stack_info} stack_status |
| 84 | Should Be Equal ${status} CREATE_COMPLETE |
| 85 | [Return] ${stack_info} |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 86 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 87 | Get Deployed Stack |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 88 | [Arguments] ${alias} ${stack_name} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 89 | ${stack_info}= Get Stack Details ${alias} ${stack_name} |
| 90 | ${status}= Get From Dictionary ${stack_info} stack_status |
| 91 | Should Not Be Equal ${status} CREATE_IN_PROGRESS |
jf9860 | 99c6329 | 2017-03-09 15:28:42 -0500 | [diff] [blame] | 92 | [Return] ${stack_info} |