blob: e6ec504b70ec93dbe622a575ccd444fcef581626 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
jf986099c63292017-03-09 15:28:42 -05002Documentation The interface for interacting with Openstack Heat API.
DR695Hccff30b2017-02-17 18:44:24 -05003Library OpenstackLibrary
4Library RequestsLibrary
DR695Hccff30b2017-02-17 18:44:24 -05005Library OperatingSystem
6Library HEATUtils
7Library StringTemplater
8Library Collections
9Resource ../global_properties.robot
10Resource ../json_templater.robot
11Resource openstack_common.robot
12
13*** Variables ***
jf986099c63292017-03-09 15:28:42 -050014${OPENSTACK_HEAT_API_VERSION} /v1
DR695Hccff30b2017-02-17 18:44:24 -050015${OPENSTACK_HEAT_STACK_PATH} /stacks
16${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} robot/assets/templates/heat_add_stack.template
17
18
19*** Keywords ***
20Get Openstack Stacks
21 [Documentation] Returns the openstack stacks info
22 [Arguments] ${alias}
jf986099c63292017-03-09 15:28:42 -050023 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH}
DR695Hccff30b2017-02-17 18:44:24 -050024 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050025
DR695Hccff30b2017-02-17 18:44:24 -050026Get Openstack Stack
27 [Documentation] Returns the openstack stacks info for the given stack name
jf986099c63292017-03-09 15:28:42 -050028 [Arguments] ${alias} ${stack_name}
29 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} /${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -050030 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050031
DR695Hccff30b2017-02-17 18:44:24 -050032Create Openstack Stack
33 [Documentation] Takes an openstack heat yaml and returns the created stack
34 [Arguments] ${alias} ${request}
jf986099c63292017-03-09 15:28:42 -050035 ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} data_path= data=${request}
DR695Hccff30b2017-02-17 18:44:24 -050036 [Return] ${resp.json()}
37
38Make 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}
jf986099c63292017-03-09 15:28:42 -050046 Log $request
DR695Hccff30b2017-02-17 18:44:24 -050047 [Return] ${request}
48
49Delete Openstack Stack
50 [Documentation] Deletes and Openstack Stack for the passed name and id
jf986099c63292017-03-09 15:28:42 -050051 [Arguments] ${alias} ${stack_name} ${stack_id}
DR695Hccff30b2017-02-17 18:44:24 -050052 ${data_path}= Catenate /${stack_name}/${stack_id}
jf986099c63292017-03-09 15:28:42 -050053 ${resp}= Internal Delete Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} data_path=${data_path}
DR695Hccff30b2017-02-17 18:44:24 -050054 Should Be Equal As Strings 204 ${resp.status_code}
55 [Return] ${resp}
56
57Get Stack Details
jf986099c63292017-03-09 15:28:42 -050058 [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()}
DR695Hccff30b2017-02-17 18:44:24 -050062 [Return] ${result}
63
64Get Stack Template
jf986099c63292017-03-09 15:28:42 -050065 [Documentation] Gets all of the template information of an existing Openstack Stack
66 [Arguments] ${alias} ${stack_name} ${stack_id}
DR695Hccff30b2017-02-17 18:44:24 -050067 ${data_path}= Catenate /${stack_name}/${stack_id}/template
jf986099c63292017-03-09 15:28:42 -050068 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} ${data_path}
DR695Hccff30b2017-02-17 18:44:24 -050069 ${template}= Catenate ${resp.json()}
70 [Return] ${template}
jf986099c63292017-03-09 15:28:42 -050071
DR695Hccff30b2017-02-17 18:44:24 -050072Get Stack Resources
jf986099c63292017-03-09 15:28:42 -050073 [Documentation] Gets all of the resources of an existing Openstack Stack
74 [Arguments] ${alias} ${stack_name} ${stack_id}
DR695Hccff30b2017-02-17 18:44:24 -050075 ${data_path}= Catenate /${stack_name}/${stack_id}/resources
jf986099c63292017-03-09 15:28:42 -050076 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} ${data_path}
DR695Hccff30b2017-02-17 18:44:24 -050077 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050078
DR695Hccff30b2017-02-17 18:44:24 -050079Wait for Stack to Be Deployed
Jerry Floodf67ce0e2017-03-20 16:59:23 -040080 [Arguments] ${alias} ${stack_name} ${timeout}=${GLOBAL_OPENSTACK_STACK_DEPLOYMENT_TIMEOUT}
jf986099c63292017-03-09 15:28:42 -050081 ${stack_info}= Wait Until Keyword Succeeds ${timeout} 30 sec Get Deployed Stack ${alias} ${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -050082 ${status}= Get From Dictionary ${stack_info} stack_status
83 Should Be Equal ${status} CREATE_COMPLETE
84 [Return] ${stack_info}
jf986099c63292017-03-09 15:28:42 -050085
DR695Hccff30b2017-02-17 18:44:24 -050086Get Deployed Stack
jf986099c63292017-03-09 15:28:42 -050087 [Arguments] ${alias} ${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -050088 ${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
jf986099c63292017-03-09 15:28:42 -050091 [Return] ${stack_info}