blob: 74c7aac8350ecb6f14eef948991902b5faddad20 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The interface for interacting with Openstack Heat API.
3Library OpenstackLibrary
4Library RequestsLibrary
5Library UUID
6Library OperatingSystem
7Library HEATUtils
8Library StringTemplater
9Library Collections
10Resource ../global_properties.robot
11Resource ../json_templater.robot
12Resource openstack_common.robot
13
14*** Variables ***
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
18
19
20*** Keywords ***
21Get Openstack Stacks
22 [Documentation] Returns the openstack stacks info
23 [Arguments] ${alias}
24 ${resp}= Internal Get Openstack ${alias} ${GLOBAL_OPENSTACK_HEAT_SERVICE_TYPE} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_HEAT_STACK_PATH}
25 [Return] ${resp.json()}
26
27Get Openstack Stack
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} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_HEAT_STACK_PATH} /${stack_name}
31 [Return] ${resp.json()}
32
33Create 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} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_HEAT_STACK_PATH} data_path= data=${request}
37 [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}
47 Log $request
48 [Return] ${request}
49
50Delete 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} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_HEAT_STACK_PATH} data_path=${data_path}
55 Should Be Equal As Strings 204 ${resp.status_code}
56 [Return] ${resp}
57
58Get Stack Details
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} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_HEAT_STACK_PATH} /${stack_name}
62 ${result}= Stack Info Parse ${resp.json()}
63 [Return] ${result}
64
65Get Stack Template
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} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_HEAT_STACK_PATH} ${data_path}
70 ${template}= Catenate ${resp.json()}
71 [Return] ${template}
72
73Get Stack Resources
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} ${GLOBAL_OPENSTACK_SERVICE_REGION} ${OPENSTACK_HEAT_STACK_PATH} ${data_path}
78 [Return] ${resp.json()}
79
80Wait 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}
86
87Get Deployed Stack
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}
93