2 Documentation The interface for interacting with Openstack Heat API.
3 Library OpenstackLibrary
4 Library RequestsLibrary
6 Library OperatingSystem
8 Library StringTemplater
10 Resource ../global_properties.robot
11 Resource ../json_templater.robot
12 Resource openstack_common.robot
15 ${OPENSTACK_HEAT_API_VERSION} /v1
16 ${OPENSTACK_HEAT_STACK_PATH} /stacks
17 ${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} robot/assets/templates/heat_add_stack.template
22 [Documentation] Returns the openstack stacks info
24 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH}
25 [Return] ${resp.json()}
28 [Documentation] Returns the openstack stacks info for the given stack name
29 [Arguments] ${alias} ${stack_name}
30 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} /${stack_name}
31 [Return] ${resp.json()}
33 Create Openstack Stack
34 [Documentation] Takes an openstack heat yaml and returns the created stack
35 [Arguments] ${alias} ${request}
36 ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} data_path= data=${request}
37 [Return] ${resp.json()}
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}
50 Delete Openstack Stack
51 [Documentation] Deletes and Openstack Stack for the passed name and id
52 [Arguments] ${alias} ${stack_name} ${stack_id}
53 ${data_path}= Catenate /${stack_name}/${stack_id}
54 ${resp}= Internal Delete Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} data_path=${data_path}
55 Should Be Equal As Strings 204 ${resp.status_code}
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()}
66 [Documentation] Gets all of the template information of an existing Openstack Stack
67 [Arguments] ${alias} ${stack_name} ${stack_id}
68 ${data_path}= Catenate /${stack_name}/${stack_id}/template
69 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} ${data_path}
70 ${template}= Catenate ${resp.json()}
74 [Documentation] Gets all of the resources of an existing Openstack Stack
75 [Arguments] ${alias} ${stack_name} ${stack_id}
76 ${data_path}= Catenate /${stack_name}/${stack_id}/resources
77 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${OPENSTACK_HEAT_STACK_PATH} ${data_path}
78 [Return] ${resp.json()}
80 Wait for Stack to Be Deployed
81 [Arguments] ${alias} ${stack_name} ${timeout}=600s
82 ${stack_info}= Wait Until Keyword Succeeds ${timeout} 30 sec Get Deployed Stack ${alias} ${stack_name}
83 ${status}= Get From Dictionary ${stack_info} stack_status
84 Should Be Equal ${status} CREATE_COMPLETE
85 [Return] ${stack_info}
88 [Arguments] ${alias} ${stack_name}
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
92 [Return] ${stack_info}