blob: 0cb38c22036a24d40940da5690c65e3d57ea5a4c [file] [log] [blame]
Jon Perritt4a5c8492015-02-03 13:13:59 -07001package stacks
2
3import (
4 "fmt"
5 "net/http"
6 "testing"
Jon Perritt9cd3d382015-02-04 15:49:41 -07007 "time"
Jon Perritt4a5c8492015-02-03 13:13:59 -07008
9 "github.com/rackspace/gophercloud"
10 th "github.com/rackspace/gophercloud/testhelper"
11 fake "github.com/rackspace/gophercloud/testhelper/client"
12)
13
14// CreateExpected represents the expected object from a Create request.
15var CreateExpected = &CreatedStack{
16 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
17 Links: []gophercloud.Link{
18 gophercloud.Link{
19 Href: "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
20 Rel: "self",
21 },
22 },
23}
24
25// CreateOutput represents the response body from a Create request.
26const CreateOutput = `
27{
28 "stack": {
29 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
30 "links": [
31 {
32 "href": "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
33 "rel": "self"
34 }
35 ]
36 }
37}`
38
39// HandleCreateSuccessfully creates an HTTP handler at `/stacks` on the test handler mux
40// that responds with a `Create` response.
41func HandleCreateSuccessfully(t *testing.T, output string) {
42 th.Mux.HandleFunc("/stacks", func(w http.ResponseWriter, r *http.Request) {
43 th.TestMethod(t, r, "POST")
44 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
45 th.TestHeader(t, r, "Accept", "application/json")
46 w.WriteHeader(http.StatusCreated)
47 fmt.Fprintf(w, output)
48 })
49}
Jon Perritt9cd3d382015-02-04 15:49:41 -070050
51// ListExpected represents the expected object from a List request.
52var ListExpected = []ListedStack{
53 ListedStack{
54 Description: "Simple template to test heat commands",
55 Links: []gophercloud.Link{
56 gophercloud.Link{
57 Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
58 Rel: "self",
59 },
60 },
61 StatusReason: "Stack CREATE completed successfully",
62 Name: "postman_stack",
63 CreationTime: time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC),
64 Status: "CREATE_COMPLETE",
65 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
Pratik Mallya827c03e2015-09-17 00:10:47 -050066 Tags: []string{"rackspace", "atx"},
Jon Perritt9cd3d382015-02-04 15:49:41 -070067 },
68 ListedStack{
69 Description: "Simple template to test heat commands",
70 Links: []gophercloud.Link{
71 gophercloud.Link{
72 Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada",
73 Rel: "self",
74 },
75 },
76 StatusReason: "Stack successfully updated",
77 Name: "gophercloud-test-stack-2",
78 CreationTime: time.Date(2014, 12, 11, 17, 39, 16, 0, time.UTC),
79 UpdatedTime: time.Date(2014, 12, 11, 17, 40, 37, 0, time.UTC),
80 Status: "UPDATE_COMPLETE",
81 ID: "db6977b2-27aa-4775-9ae7-6213212d4ada",
Pratik Mallya827c03e2015-09-17 00:10:47 -050082 Tags: []string{"sfo", "satx"},
Jon Perritt9cd3d382015-02-04 15:49:41 -070083 },
84}
85
86// FullListOutput represents the response body from a List request without a marker.
87const FullListOutput = `
88{
89 "stacks": [
90 {
91 "description": "Simple template to test heat commands",
92 "links": [
93 {
94 "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
95 "rel": "self"
96 }
97 ],
98 "stack_status_reason": "Stack CREATE completed successfully",
99 "stack_name": "postman_stack",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500100 "creation_time": "2015-02-03T20:07:39",
Jon Perritt9cd3d382015-02-04 15:49:41 -0700101 "updated_time": null,
102 "stack_status": "CREATE_COMPLETE",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500103 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
104 "tags": ["rackspace", "atx"]
Jon Perritt9cd3d382015-02-04 15:49:41 -0700105 },
106 {
107 "description": "Simple template to test heat commands",
108 "links": [
109 {
110 "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada",
111 "rel": "self"
112 }
113 ],
114 "stack_status_reason": "Stack successfully updated",
115 "stack_name": "gophercloud-test-stack-2",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500116 "creation_time": "2014-12-11T17:39:16",
117 "updated_time": "2014-12-11T17:40:37",
Jon Perritt9cd3d382015-02-04 15:49:41 -0700118 "stack_status": "UPDATE_COMPLETE",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500119 "id": "db6977b2-27aa-4775-9ae7-6213212d4ada",
120 "tags": ["sfo", "satx"]
Jon Perritt9cd3d382015-02-04 15:49:41 -0700121 }
122 ]
123}
124`
125
126// HandleListSuccessfully creates an HTTP handler at `/stacks` on the test handler mux
127// that responds with a `List` response.
128func HandleListSuccessfully(t *testing.T, output string) {
129 th.Mux.HandleFunc("/stacks", func(w http.ResponseWriter, r *http.Request) {
130 th.TestMethod(t, r, "GET")
131 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
132 th.TestHeader(t, r, "Accept", "application/json")
133
134 w.Header().Set("Content-Type", "application/json")
135 r.ParseForm()
136 marker := r.Form.Get("marker")
137 switch marker {
138 case "":
139 fmt.Fprintf(w, output)
140 case "db6977b2-27aa-4775-9ae7-6213212d4ada":
141 fmt.Fprintf(w, `[]`)
142 default:
143 t.Fatalf("Unexpected marker: [%s]", marker)
144 }
145 })
146}
Jon Perritt7726e492015-02-04 17:54:28 -0700147
148// GetExpected represents the expected object from a Get request.
149var GetExpected = &RetrievedStack{
150 DisableRollback: true,
151 Description: "Simple template to test heat commands",
152 Parameters: map[string]string{
153 "flavor": "m1.tiny",
154 "OS::stack_name": "postman_stack",
155 "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
156 },
157 StatusReason: "Stack CREATE completed successfully",
158 Name: "postman_stack",
159 Outputs: []map[string]interface{}{},
160 CreationTime: time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC),
161 Links: []gophercloud.Link{
162 gophercloud.Link{
163 Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
164 Rel: "self",
165 },
166 },
167 Capabilities: []interface{}{},
168 NotificationTopics: []interface{}{},
169 Status: "CREATE_COMPLETE",
170 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
171 TemplateDescription: "Simple template to test heat commands",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500172 Tags: []string{"rackspace", "atx"},
Jon Perritt7726e492015-02-04 17:54:28 -0700173}
174
175// GetOutput represents the response body from a Get request.
176const GetOutput = `
177{
178 "stack": {
179 "disable_rollback": true,
180 "description": "Simple template to test heat commands",
181 "parameters": {
182 "flavor": "m1.tiny",
183 "OS::stack_name": "postman_stack",
184 "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87"
185 },
186 "stack_status_reason": "Stack CREATE completed successfully",
187 "stack_name": "postman_stack",
188 "outputs": [],
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500189 "creation_time": "2015-02-03T20:07:39",
Jon Perritt7726e492015-02-04 17:54:28 -0700190 "links": [
191 {
192 "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
193 "rel": "self"
194 }
195 ],
196 "capabilities": [],
197 "notification_topics": [],
198 "timeout_mins": null,
199 "stack_status": "CREATE_COMPLETE",
200 "updated_time": null,
201 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500202 "template_description": "Simple template to test heat commands",
203 "tags": ["rackspace", "atx"]
Jon Perritt7726e492015-02-04 17:54:28 -0700204 }
205}
206`
207
208// HandleGetSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87`
209// on the test handler mux that responds with a `Get` response.
210func HandleGetSuccessfully(t *testing.T, output string) {
211 th.Mux.HandleFunc("/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87", func(w http.ResponseWriter, r *http.Request) {
212 th.TestMethod(t, r, "GET")
213 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
214 th.TestHeader(t, r, "Accept", "application/json")
215
216 w.Header().Set("Content-Type", "application/json")
217 w.WriteHeader(http.StatusOK)
218 fmt.Fprintf(w, output)
219 })
220}
221
222// HandleUpdateSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87`
223// on the test handler mux that responds with an `Update` response.
224func HandleUpdateSuccessfully(t *testing.T) {
225 th.Mux.HandleFunc("/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada", func(w http.ResponseWriter, r *http.Request) {
226 th.TestMethod(t, r, "PUT")
227 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
228 th.TestHeader(t, r, "Accept", "application/json")
229
230 w.Header().Set("Content-Type", "application/json")
231 w.WriteHeader(http.StatusAccepted)
232 })
233}
Jon Perritta433dd92015-02-04 18:04:13 -0700234
235// HandleDeleteSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87`
Jon Perritt9209df42015-02-05 12:55:33 -0700236// on the test handler mux that responds with a `Delete` response.
Jon Perritta433dd92015-02-04 18:04:13 -0700237func HandleDeleteSuccessfully(t *testing.T) {
238 th.Mux.HandleFunc("/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada", func(w http.ResponseWriter, r *http.Request) {
239 th.TestMethod(t, r, "DELETE")
240 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
241 th.TestHeader(t, r, "Accept", "application/json")
242
243 w.Header().Set("Content-Type", "application/json")
244 w.WriteHeader(http.StatusNoContent)
245 })
246}
Jon Perritt37f97742015-02-04 18:55:05 -0700247
248// GetExpected represents the expected object from a Get request.
249var PreviewExpected = &PreviewedStack{
250 DisableRollback: true,
251 Description: "Simple template to test heat commands",
252 Parameters: map[string]string{
253 "flavor": "m1.tiny",
254 "OS::stack_name": "postman_stack",
255 "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
256 },
Jon Perritt37f97742015-02-04 18:55:05 -0700257 Name: "postman_stack",
258 CreationTime: time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC),
259 Links: []gophercloud.Link{
260 gophercloud.Link{
261 Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
262 Rel: "self",
263 },
264 },
265 Capabilities: []interface{}{},
266 NotificationTopics: []interface{}{},
Jon Perritt37f97742015-02-04 18:55:05 -0700267 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
268 TemplateDescription: "Simple template to test heat commands",
269}
270
271// HandlePreviewSuccessfully creates an HTTP handler at `/stacks/preview`
Jon Perritt9209df42015-02-05 12:55:33 -0700272// on the test handler mux that responds with a `Preview` response.
Jon Perritt37f97742015-02-04 18:55:05 -0700273func HandlePreviewSuccessfully(t *testing.T, output string) {
274 th.Mux.HandleFunc("/stacks/preview", func(w http.ResponseWriter, r *http.Request) {
275 th.TestMethod(t, r, "POST")
276 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
277 th.TestHeader(t, r, "Accept", "application/json")
278
279 w.Header().Set("Content-Type", "application/json")
280 w.WriteHeader(http.StatusOK)
281 fmt.Fprintf(w, output)
282 })
283}
Jon Perritt9209df42015-02-05 12:55:33 -0700284
285// AbandonExpected represents the expected object from an Abandon request.
286var AbandonExpected = &AbandonedStack{
287 Status: "COMPLETE",
288 Name: "postman_stack",
Jon Perritt6ec27cf2015-02-09 12:51:41 -0700289 Template: map[string]interface{}{
290 "heat_template_version": "2013-05-23",
291 "description": "Simple template to test heat commands",
292 "parameters": map[string]interface{}{
293 "flavor": map[string]interface{}{
294 "default": "m1.tiny",
295 "type": "string",
296 },
297 },
298 "resources": map[string]interface{}{
299 "hello_world": map[string]interface{}{
300 "type": "OS::Nova::Server",
301 "properties": map[string]interface{}{
302 "key_name": "heat_key",
303 "flavor": map[string]interface{}{
304 "get_param": "flavor",
305 },
306 "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
307 "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n",
308 },
309 },
310 },
311 },
Jon Perritt9209df42015-02-05 12:55:33 -0700312 Action: "CREATE",
313 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
314 Resources: map[string]interface{}{
315 "hello_world": map[string]interface{}{
316 "status": "COMPLETE",
317 "name": "hello_world",
318 "resource_id": "8a310d36-46fc-436f-8be4-37a696b8ac63",
319 "action": "CREATE",
320 "type": "OS::Nova::Server",
321 },
322 },
Pratik Mallya827c03e2015-09-17 00:10:47 -0500323 Files: map[string]string{
324 "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml": "heat_template_version: 2014-10-16\nparameters:\n flavor:\n type: string\n description: Flavor for the server to be created\n default: 4353\n hidden: true\nresources:\n test_server:\n type: \"OS::Nova::Server\"\n properties:\n name: test-server\n flavor: 2 GB General Purpose v1\n image: Debian 7 (Wheezy) (PVHVM)\n",
325 },
326 StackUserProjectID: "897686",
327 ProjectID: "897686",
328 Environment: map[string]interface{}{
329 "encrypted_param_names": make([]map[string]interface{}, 0),
330 "parameter_defaults": make(map[string]interface{}),
331 "parameters": make(map[string]interface{}),
332 "resource_registry": map[string]interface{}{
333 "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml": "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml",
334 "resources": make(map[string]interface{}),
335 },
336 },
Jon Perritt9209df42015-02-05 12:55:33 -0700337}
338
339// AbandonOutput represents the response body from an Abandon request.
340const AbandonOutput = `
341{
342 "status": "COMPLETE",
343 "name": "postman_stack",
344 "template": {
345 "heat_template_version": "2013-05-23",
346 "description": "Simple template to test heat commands",
347 "parameters": {
348 "flavor": {
349 "default": "m1.tiny",
350 "type": "string"
351 }
352 },
353 "resources": {
354 "hello_world": {
355 "type": "OS::Nova::Server",
356 "properties": {
357 "key_name": "heat_key",
358 "flavor": {
359 "get_param": "flavor"
360 },
361 "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
362 "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
363 }
364 }
365 }
366 },
367 "action": "CREATE",
368 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
369 "resources": {
370 "hello_world": {
371 "status": "COMPLETE",
372 "name": "hello_world",
373 "resource_id": "8a310d36-46fc-436f-8be4-37a696b8ac63",
374 "action": "CREATE",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500375 "type": "OS::Nova::Server"
Jon Perritt9209df42015-02-05 12:55:33 -0700376 }
Pratik Mallya827c03e2015-09-17 00:10:47 -0500377 },
378 "files": {
379 "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml": "heat_template_version: 2014-10-16\nparameters:\n flavor:\n type: string\n description: Flavor for the server to be created\n default: 4353\n hidden: true\nresources:\n test_server:\n type: \"OS::Nova::Server\"\n properties:\n name: test-server\n flavor: 2 GB General Purpose v1\n image: Debian 7 (Wheezy) (PVHVM)\n"
380},
381 "environment": {
382 "encrypted_param_names": [],
383 "parameter_defaults": {},
384 "parameters": {},
385 "resource_registry": {
386 "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml": "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml",
387 "resources": {}
388 }
389 },
390 "stack_user_project_id": "897686",
391 "project_id": "897686"
Jon Perritt9209df42015-02-05 12:55:33 -0700392}`
393
394// HandleAbandonSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87/abandon`
395// on the test handler mux that responds with an `Abandon` response.
Pratik Mallya827c03e2015-09-17 00:10:47 -0500396func HandleAbandonSuccessfully(t *testing.T, output string) {
397 th.Mux.HandleFunc("/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c8/abandon", func(w http.ResponseWriter, r *http.Request) {
Jon Perritt9209df42015-02-05 12:55:33 -0700398 th.TestMethod(t, r, "DELETE")
399 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
400 th.TestHeader(t, r, "Accept", "application/json")
401
402 w.Header().Set("Content-Type", "application/json")
403 w.WriteHeader(http.StatusOK)
Pratik Mallya827c03e2015-09-17 00:10:47 -0500404 fmt.Fprintf(w, output)
Jon Perritt9209df42015-02-05 12:55:33 -0700405 })
406}
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500407
408const ValidJSONTemplate = `
409{
410 "heat_template_version": "2014-10-16",
411 "parameters": {
412 "flavor": {
413 "default": 4353,
414 "description": "Flavor for the server to be created",
415 "hidden": true,
416 "type": "string"
417 }
418 },
419 "resources": {
420 "test_server": {
421 "properties": {
422 "flavor": "2 GB General Purpose v1",
423 "image": "Debian 7 (Wheezy) (PVHVM)",
424 "name": "test-server"
425 },
426 "type": "OS::Nova::Server"
427 }
428 }
429}
430`
431
432var ValidJSONTemplateParsed = map[string]interface{}{
433 "heat_template_version": "2014-10-16",
434 "parameters": map[string]interface{}{
435 "flavor": map[string]interface{}{
436 "default": 4353,
437 "description": "Flavor for the server to be created",
438 "hidden": true,
439 "type": "string",
440 },
441 },
442 "resources": map[string]interface{}{
443 "test_server": map[string]interface{}{
444 "properties": map[string]interface{}{
445 "flavor": "2 GB General Purpose v1",
446 "image": "Debian 7 (Wheezy) (PVHVM)",
447 "name": "test-server",
448 },
449 "type": "OS::Nova::Server",
450 },
451 },
452}
453
454const ValidYAMLTemplate = `
455heat_template_version: 2014-10-16
456parameters:
457 flavor:
458 type: string
459 description: Flavor for the server to be created
460 default: 4353
461 hidden: true
462resources:
463 test_server:
464 type: "OS::Nova::Server"
465 properties:
466 name: test-server
467 flavor: 2 GB General Purpose v1
468 image: Debian 7 (Wheezy) (PVHVM)
469`
470
471const InvalidTemplateNoVersion = `
472parameters:
473 flavor:
474 type: string
475 description: Flavor for the server to be created
476 default: 4353
477 hidden: true
478resources:
479 test_server:
480 type: "OS::Nova::Server"
481 properties:
482 name: test-server
483 flavor: 2 GB General Purpose v1
484 image: Debian 7 (Wheezy) (PVHVM)
485`
486
487const ValidJSONEnvironment = `
488{
489 "parameters": {
490 "user_key": "userkey"
491 },
492 "resource_registry": {
493 "My::WP::Server": "file:///home/shardy/git/heat-templates/hot/F18/WordPress_Native.yaml",
494 "OS::Quantum*": "OS::Neutron*",
495 "AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml",
496 "OS::Metering::Alarm": "OS::Ceilometer::Alarm",
497 "AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml",
498 "resources": {
499 "my_db_server": {
500 "OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml"
501 },
502 "my_server": {
503 "OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
504 "hooks": "pre-create"
505 },
506 "nested_stack": {
507 "nested_resource": {
508 "hooks": "pre-update"
509 },
510 "another_resource": {
511 "hooks": [
512 "pre-create",
513 "pre-update"
514 ]
515 }
516 }
517 }
518 }
519}
520`
521
522var ValidJSONEnvironmentParsed = map[string]interface{}{
523 "parameters": map[string]interface{}{
524 "user_key": "userkey",
525 },
526 "resource_registry": map[string]interface{}{
527 "My::WP::Server": "file:///home/shardy/git/heat-templates/hot/F18/WordPress_Native.yaml",
528 "OS::Quantum*": "OS::Neutron*",
529 "AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml",
530 "OS::Metering::Alarm": "OS::Ceilometer::Alarm",
531 "AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml",
532 "resources": map[string]interface{}{
533 "my_db_server": map[string]interface{}{
534 "OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
535 },
536 "my_server": map[string]interface{}{
537 "OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
538 "hooks": "pre-create",
539 },
540 "nested_stack": map[string]interface{}{
541 "nested_resource": map[string]interface{}{
542 "hooks": "pre-update",
543 },
544 "another_resource": map[string]interface{}{
545 "hooks": []interface{}{
546 "pre-create",
547 "pre-update",
548 },
549 },
550 },
551 },
552 },
553}
554
555const ValidYAMLEnvironment = `
556parameters:
557 user_key: userkey
558resource_registry:
559 My::WP::Server: file:///home/shardy/git/heat-templates/hot/F18/WordPress_Native.yaml
560 # allow older templates with Quantum in them.
561 "OS::Quantum*": "OS::Neutron*"
562 # Choose your implementation of AWS::CloudWatch::Alarm
563 "AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml"
564 #"AWS::CloudWatch::Alarm": "OS::Heat::CWLiteAlarm"
565 "OS::Metering::Alarm": "OS::Ceilometer::Alarm"
566 "AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml"
567 resources:
568 my_db_server:
569 "OS::DBInstance": file:///home/mine/all_my_cool_templates/db.yaml
570 my_server:
571 "OS::DBInstance": file:///home/mine/all_my_cool_templates/db.yaml
572 hooks: pre-create
573 nested_stack:
574 nested_resource:
575 hooks: pre-update
576 another_resource:
577 hooks: [pre-create, pre-update]
578`
579
580const InvalidEnvironment = `
581parameters:
582 flavor:
583 type: string
584 description: Flavor for the server to be created
585 default: 4353
586 hidden: true
587resources:
588 test_server:
589 type: "OS::Nova::Server"
590 properties:
591 name: test-server
592 flavor: 2 GB General Purpose v1
593 image: Debian 7 (Wheezy) (PVHVM)
594parameter_defaults:
595 KeyName: heat_key
596`