blob: b23cb758b1acf22361bdbfba1608df186f5758a6 [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
jf986099c63292017-03-09 15:28:42 -05005Library UUID
DR695Hccff30b2017-02-17 18:44:24 -05006Library OperatingSystem
7Library HEATUtils
8Library StringTemplater
9Library Collections
10Resource ../global_properties.robot
11Resource ../json_templater.robot
12Resource openstack_common.robot
13
14*** Variables ***
jf986099c63292017-03-09 15:28:42 -050015${OPENSTACK_HEAT_API_VERSION} /v1
DR695Hccff30b2017-02-17 18:44:24 -050016${OPENSTACK_HEAT_STACK_PATH} /stacks
17${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} robot/assets/templates/heat_add_stack.template
18
19
20*** Keywords ***
21Get Openstack Stacks
22 [Documentation] Returns the openstack stacks info
23 [Arguments] ${alias}
jf986099c63292017-03-09 15:28:42 -050024 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH}
DR695Hccff30b2017-02-17 18:44:24 -050025 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050026
DR695Hccff30b2017-02-17 18:44:24 -050027Get Openstack Stack
28 [Documentation] Returns the openstack stacks info for the given stack name
jf986099c63292017-03-09 15:28:42 -050029 [Arguments] ${alias} ${stack_name}
30 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} /${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -050031 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050032
DR695Hccff30b2017-02-17 18:44:24 -050033Create Openstack Stack
34 [Documentation] Takes an openstack heat yaml and returns the created stack
35 [Arguments] ${alias} ${request}
jf986099c63292017-03-09 15:28:42 -050036 ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} data_path= data=${request}
DR695Hccff30b2017-02-17 18:44:24 -050037 [Return] ${resp.json()}
38
39Make 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}
jf986099c63292017-03-09 15:28:42 -050047 Log $request
DR695Hccff30b2017-02-17 18:44:24 -050048 [Return] ${request}
49
50Delete Openstack Stack
51 [Documentation] Deletes and Openstack Stack for the passed name and id
jf986099c63292017-03-09 15:28:42 -050052 [Arguments] ${alias} ${stack_name} ${stack_id}
DR695Hccff30b2017-02-17 18:44:24 -050053 ${data_path}= Catenate /${stack_name}/${stack_id}
jf986099c63292017-03-09 15:28:42 -050054 ${resp}= Internal Delete Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} data_path=${data_path}
DR695Hccff30b2017-02-17 18:44:24 -050055 Should Be Equal As Strings 204 ${resp.status_code}
56 [Return] ${resp}
57
58Get Stack Details
jf986099c63292017-03-09 15:28:42 -050059 [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()}
DR695Hccff30b2017-02-17 18:44:24 -050063 [Return] ${result}
64
65Get Stack Template
jf986099c63292017-03-09 15:28:42 -050066 [Documentation] Gets all of the template information of an existing Openstack Stack
67 [Arguments] ${alias} ${stack_name} ${stack_id}
DR695Hccff30b2017-02-17 18:44:24 -050068 ${data_path}= Catenate /${stack_name}/${stack_id}/template
jf986099c63292017-03-09 15:28:42 -050069 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} ${data_path}
DR695Hccff30b2017-02-17 18:44:24 -050070 ${template}= Catenate ${resp.json()}
71 [Return] ${template}
jf986099c63292017-03-09 15:28:42 -050072
DR695Hccff30b2017-02-17 18:44:24 -050073Get Stack Resources
jf986099c63292017-03-09 15:28:42 -050074 [Documentation] Gets all of the resources of an existing Openstack Stack
75 [Arguments] ${alias} ${stack_name} ${stack_id}
DR695Hccff30b2017-02-17 18:44:24 -050076 ${data_path}= Catenate /${stack_name}/${stack_id}/resources
jf986099c63292017-03-09 15:28:42 -050077 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} ${data_path}
DR695Hccff30b2017-02-17 18:44:24 -050078 [Return] ${resp.json()}
jf986099c63292017-03-09 15:28:42 -050079
DR695Hccff30b2017-02-17 18:44:24 -050080Wait for Stack to Be Deployed
Jerry Floodf67ce0e2017-03-20 16:59:23 -040081 [Arguments] ${alias} ${stack_name} ${timeout}=${GLOBAL_OPENSTACK_STACK_DEPLOYMENT_TIMEOUT}
jf986099c63292017-03-09 15:28:42 -050082 ${stack_info}= Wait Until Keyword Succeeds ${timeout} 30 sec Get Deployed Stack ${alias} ${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -050083 ${status}= Get From Dictionary ${stack_info} stack_status
84 Should Be Equal ${status} CREATE_COMPLETE
85 [Return] ${stack_info}
jf986099c63292017-03-09 15:28:42 -050086
DR695Hccff30b2017-02-17 18:44:24 -050087Get Deployed Stack
jf986099c63292017-03-09 15:28:42 -050088 [Arguments] ${alias} ${stack_name}
DR695Hccff30b2017-02-17 18:44:24 -050089 ${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
jf986099c63292017-03-09 15:28:42 -050092 [Return] ${stack_info}