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