blob: 4126cf6a7cafdee1989108878cdb64f4886044bb [file] [log] [blame]
Keith Byrnebda48592016-03-23 11:37:08 +00001// +build fixtures
2
Jon Perritt4a5c8492015-02-03 13:13:59 -07003package stacks
4
5import (
6 "fmt"
7 "net/http"
8 "testing"
Jon Perritt9cd3d382015-02-04 15:49:41 -07009 "time"
Jon Perritt4a5c8492015-02-03 13:13:59 -070010
Jon Perritt27249f42016-02-18 10:35:59 -060011 "github.com/gophercloud/gophercloud"
12 th "github.com/gophercloud/gophercloud/testhelper"
13 fake "github.com/gophercloud/gophercloud/testhelper/client"
Jon Perritt4a5c8492015-02-03 13:13:59 -070014)
15
16// CreateExpected represents the expected object from a Create request.
17var CreateExpected = &CreatedStack{
18 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
19 Links: []gophercloud.Link{
20 gophercloud.Link{
21 Href: "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
22 Rel: "self",
23 },
24 },
25}
26
27// CreateOutput represents the response body from a Create request.
28const CreateOutput = `
29{
30 "stack": {
31 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
32 "links": [
33 {
34 "href": "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
35 "rel": "self"
36 }
37 ]
38 }
39}`
40
41// HandleCreateSuccessfully creates an HTTP handler at `/stacks` on the test handler mux
42// that responds with a `Create` response.
43func HandleCreateSuccessfully(t *testing.T, output string) {
44 th.Mux.HandleFunc("/stacks", func(w http.ResponseWriter, r *http.Request) {
45 th.TestMethod(t, r, "POST")
46 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
47 th.TestHeader(t, r, "Accept", "application/json")
48 w.WriteHeader(http.StatusCreated)
49 fmt.Fprintf(w, output)
50 })
51}
Jon Perritt9cd3d382015-02-04 15:49:41 -070052
53// ListExpected represents the expected object from a List request.
54var ListExpected = []ListedStack{
55 ListedStack{
56 Description: "Simple template to test heat commands",
57 Links: []gophercloud.Link{
58 gophercloud.Link{
59 Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
60 Rel: "self",
61 },
62 },
63 StatusReason: "Stack CREATE completed successfully",
64 Name: "postman_stack",
Jon Perritt3c166472016-02-25 03:07:41 -060065 CreationTime: gophercloud.JSONRFC3339NoZ(time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC)),
Jon Perritt9cd3d382015-02-04 15:49:41 -070066 Status: "CREATE_COMPLETE",
67 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
Pratik Mallya827c03e2015-09-17 00:10:47 -050068 Tags: []string{"rackspace", "atx"},
Jon Perritt9cd3d382015-02-04 15:49:41 -070069 },
70 ListedStack{
71 Description: "Simple template to test heat commands",
72 Links: []gophercloud.Link{
73 gophercloud.Link{
74 Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada",
75 Rel: "self",
76 },
77 },
78 StatusReason: "Stack successfully updated",
79 Name: "gophercloud-test-stack-2",
Jon Perritt3c166472016-02-25 03:07:41 -060080 CreationTime: gophercloud.JSONRFC3339NoZ(time.Date(2014, 12, 11, 17, 39, 16, 0, time.UTC)),
81 UpdatedTime: gophercloud.JSONRFC3339NoZ(time.Date(2014, 12, 11, 17, 40, 37, 0, time.UTC)),
Jon Perritt9cd3d382015-02-04 15:49:41 -070082 Status: "UPDATE_COMPLETE",
83 ID: "db6977b2-27aa-4775-9ae7-6213212d4ada",
Pratik Mallya827c03e2015-09-17 00:10:47 -050084 Tags: []string{"sfo", "satx"},
Jon Perritt9cd3d382015-02-04 15:49:41 -070085 },
86}
87
88// FullListOutput represents the response body from a List request without a marker.
89const FullListOutput = `
90{
91 "stacks": [
92 {
93 "description": "Simple template to test heat commands",
94 "links": [
95 {
96 "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
97 "rel": "self"
98 }
99 ],
100 "stack_status_reason": "Stack CREATE completed successfully",
101 "stack_name": "postman_stack",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500102 "creation_time": "2015-02-03T20:07:39",
Jon Perritt9cd3d382015-02-04 15:49:41 -0700103 "updated_time": null,
104 "stack_status": "CREATE_COMPLETE",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500105 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
106 "tags": ["rackspace", "atx"]
Jon Perritt9cd3d382015-02-04 15:49:41 -0700107 },
108 {
109 "description": "Simple template to test heat commands",
110 "links": [
111 {
112 "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada",
113 "rel": "self"
114 }
115 ],
116 "stack_status_reason": "Stack successfully updated",
117 "stack_name": "gophercloud-test-stack-2",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500118 "creation_time": "2014-12-11T17:39:16",
119 "updated_time": "2014-12-11T17:40:37",
Jon Perritt9cd3d382015-02-04 15:49:41 -0700120 "stack_status": "UPDATE_COMPLETE",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500121 "id": "db6977b2-27aa-4775-9ae7-6213212d4ada",
122 "tags": ["sfo", "satx"]
Jon Perritt9cd3d382015-02-04 15:49:41 -0700123 }
124 ]
125}
126`
127
128// HandleListSuccessfully creates an HTTP handler at `/stacks` on the test handler mux
129// that responds with a `List` response.
130func HandleListSuccessfully(t *testing.T, output string) {
131 th.Mux.HandleFunc("/stacks", func(w http.ResponseWriter, r *http.Request) {
132 th.TestMethod(t, r, "GET")
133 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
134 th.TestHeader(t, r, "Accept", "application/json")
135
136 w.Header().Set("Content-Type", "application/json")
137 r.ParseForm()
138 marker := r.Form.Get("marker")
139 switch marker {
140 case "":
141 fmt.Fprintf(w, output)
142 case "db6977b2-27aa-4775-9ae7-6213212d4ada":
143 fmt.Fprintf(w, `[]`)
144 default:
145 t.Fatalf("Unexpected marker: [%s]", marker)
146 }
147 })
148}
Jon Perritt7726e492015-02-04 17:54:28 -0700149
150// GetExpected represents the expected object from a Get request.
151var GetExpected = &RetrievedStack{
152 DisableRollback: true,
153 Description: "Simple template to test heat commands",
154 Parameters: map[string]string{
155 "flavor": "m1.tiny",
156 "OS::stack_name": "postman_stack",
157 "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
158 },
159 StatusReason: "Stack CREATE completed successfully",
160 Name: "postman_stack",
161 Outputs: []map[string]interface{}{},
Jon Perritt3c166472016-02-25 03:07:41 -0600162 CreationTime: gophercloud.JSONRFC3339NoZ(time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC)),
Jon Perritt7726e492015-02-04 17:54:28 -0700163 Links: []gophercloud.Link{
164 gophercloud.Link{
165 Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
166 Rel: "self",
167 },
168 },
169 Capabilities: []interface{}{},
170 NotificationTopics: []interface{}{},
171 Status: "CREATE_COMPLETE",
172 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
173 TemplateDescription: "Simple template to test heat commands",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500174 Tags: []string{"rackspace", "atx"},
Jon Perritt7726e492015-02-04 17:54:28 -0700175}
176
177// GetOutput represents the response body from a Get request.
178const GetOutput = `
179{
180 "stack": {
181 "disable_rollback": true,
182 "description": "Simple template to test heat commands",
183 "parameters": {
184 "flavor": "m1.tiny",
185 "OS::stack_name": "postman_stack",
186 "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87"
187 },
188 "stack_status_reason": "Stack CREATE completed successfully",
189 "stack_name": "postman_stack",
190 "outputs": [],
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500191 "creation_time": "2015-02-03T20:07:39",
Jon Perritt7726e492015-02-04 17:54:28 -0700192 "links": [
193 {
194 "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
195 "rel": "self"
196 }
197 ],
198 "capabilities": [],
199 "notification_topics": [],
200 "timeout_mins": null,
201 "stack_status": "CREATE_COMPLETE",
202 "updated_time": null,
203 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500204 "template_description": "Simple template to test heat commands",
205 "tags": ["rackspace", "atx"]
Jon Perritt7726e492015-02-04 17:54:28 -0700206 }
207}
208`
209
210// HandleGetSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87`
211// on the test handler mux that responds with a `Get` response.
212func HandleGetSuccessfully(t *testing.T, output string) {
213 th.Mux.HandleFunc("/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87", func(w http.ResponseWriter, r *http.Request) {
214 th.TestMethod(t, r, "GET")
215 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
216 th.TestHeader(t, r, "Accept", "application/json")
217
218 w.Header().Set("Content-Type", "application/json")
219 w.WriteHeader(http.StatusOK)
220 fmt.Fprintf(w, output)
221 })
222}
223
224// HandleUpdateSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87`
225// on the test handler mux that responds with an `Update` response.
226func HandleUpdateSuccessfully(t *testing.T) {
227 th.Mux.HandleFunc("/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada", func(w http.ResponseWriter, r *http.Request) {
228 th.TestMethod(t, r, "PUT")
229 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
230 th.TestHeader(t, r, "Accept", "application/json")
231
232 w.Header().Set("Content-Type", "application/json")
233 w.WriteHeader(http.StatusAccepted)
234 })
235}
Jon Perritta433dd92015-02-04 18:04:13 -0700236
237// HandleDeleteSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87`
Jon Perritt9209df42015-02-05 12:55:33 -0700238// on the test handler mux that responds with a `Delete` response.
Jon Perritta433dd92015-02-04 18:04:13 -0700239func HandleDeleteSuccessfully(t *testing.T) {
240 th.Mux.HandleFunc("/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada", func(w http.ResponseWriter, r *http.Request) {
241 th.TestMethod(t, r, "DELETE")
242 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
243 th.TestHeader(t, r, "Accept", "application/json")
244
245 w.Header().Set("Content-Type", "application/json")
246 w.WriteHeader(http.StatusNoContent)
247 })
248}
Jon Perritt37f97742015-02-04 18:55:05 -0700249
250// GetExpected represents the expected object from a Get request.
251var PreviewExpected = &PreviewedStack{
252 DisableRollback: true,
253 Description: "Simple template to test heat commands",
254 Parameters: map[string]string{
255 "flavor": "m1.tiny",
256 "OS::stack_name": "postman_stack",
257 "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
258 },
Jon Perritt37f97742015-02-04 18:55:05 -0700259 Name: "postman_stack",
Jon Perritt3c166472016-02-25 03:07:41 -0600260 CreationTime: gophercloud.JSONRFC3339NoZ(time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC)),
Jon Perritt37f97742015-02-04 18:55:05 -0700261 Links: []gophercloud.Link{
262 gophercloud.Link{
263 Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
264 Rel: "self",
265 },
266 },
267 Capabilities: []interface{}{},
268 NotificationTopics: []interface{}{},
Jon Perritt37f97742015-02-04 18:55:05 -0700269 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
270 TemplateDescription: "Simple template to test heat commands",
271}
272
273// HandlePreviewSuccessfully creates an HTTP handler at `/stacks/preview`
Jon Perritt9209df42015-02-05 12:55:33 -0700274// on the test handler mux that responds with a `Preview` response.
Jon Perritt37f97742015-02-04 18:55:05 -0700275func HandlePreviewSuccessfully(t *testing.T, output string) {
276 th.Mux.HandleFunc("/stacks/preview", func(w http.ResponseWriter, r *http.Request) {
277 th.TestMethod(t, r, "POST")
278 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
279 th.TestHeader(t, r, "Accept", "application/json")
280
281 w.Header().Set("Content-Type", "application/json")
282 w.WriteHeader(http.StatusOK)
283 fmt.Fprintf(w, output)
284 })
285}
Jon Perritt9209df42015-02-05 12:55:33 -0700286
287// AbandonExpected represents the expected object from an Abandon request.
288var AbandonExpected = &AbandonedStack{
289 Status: "COMPLETE",
290 Name: "postman_stack",
Jon Perritt6ec27cf2015-02-09 12:51:41 -0700291 Template: map[string]interface{}{
292 "heat_template_version": "2013-05-23",
293 "description": "Simple template to test heat commands",
294 "parameters": map[string]interface{}{
295 "flavor": map[string]interface{}{
296 "default": "m1.tiny",
297 "type": "string",
298 },
299 },
300 "resources": map[string]interface{}{
301 "hello_world": map[string]interface{}{
302 "type": "OS::Nova::Server",
303 "properties": map[string]interface{}{
304 "key_name": "heat_key",
305 "flavor": map[string]interface{}{
306 "get_param": "flavor",
307 },
308 "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
309 "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n",
310 },
311 },
312 },
313 },
Jon Perritt9209df42015-02-05 12:55:33 -0700314 Action: "CREATE",
315 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
316 Resources: map[string]interface{}{
317 "hello_world": map[string]interface{}{
318 "status": "COMPLETE",
319 "name": "hello_world",
320 "resource_id": "8a310d36-46fc-436f-8be4-37a696b8ac63",
321 "action": "CREATE",
322 "type": "OS::Nova::Server",
323 },
324 },
Pratik Mallya827c03e2015-09-17 00:10:47 -0500325 Files: map[string]string{
326 "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",
327 },
328 StackUserProjectID: "897686",
329 ProjectID: "897686",
330 Environment: map[string]interface{}{
331 "encrypted_param_names": make([]map[string]interface{}, 0),
332 "parameter_defaults": make(map[string]interface{}),
333 "parameters": make(map[string]interface{}),
334 "resource_registry": map[string]interface{}{
335 "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml": "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml",
336 "resources": make(map[string]interface{}),
337 },
338 },
Jon Perritt9209df42015-02-05 12:55:33 -0700339}
340
341// AbandonOutput represents the response body from an Abandon request.
342const AbandonOutput = `
343{
344 "status": "COMPLETE",
345 "name": "postman_stack",
346 "template": {
347 "heat_template_version": "2013-05-23",
348 "description": "Simple template to test heat commands",
349 "parameters": {
350 "flavor": {
351 "default": "m1.tiny",
352 "type": "string"
353 }
354 },
355 "resources": {
356 "hello_world": {
357 "type": "OS::Nova::Server",
358 "properties": {
359 "key_name": "heat_key",
360 "flavor": {
361 "get_param": "flavor"
362 },
363 "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
364 "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
365 }
366 }
367 }
368 },
369 "action": "CREATE",
370 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
371 "resources": {
372 "hello_world": {
373 "status": "COMPLETE",
374 "name": "hello_world",
375 "resource_id": "8a310d36-46fc-436f-8be4-37a696b8ac63",
376 "action": "CREATE",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500377 "type": "OS::Nova::Server"
Jon Perritt9209df42015-02-05 12:55:33 -0700378 }
Pratik Mallya827c03e2015-09-17 00:10:47 -0500379 },
380 "files": {
381 "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"
382},
383 "environment": {
384 "encrypted_param_names": [],
385 "parameter_defaults": {},
386 "parameters": {},
387 "resource_registry": {
388 "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml": "file:///Users/prat8228/go/src/github.com/rackspace/rack/my_nova.yaml",
389 "resources": {}
390 }
391 },
392 "stack_user_project_id": "897686",
393 "project_id": "897686"
Jon Perritt9209df42015-02-05 12:55:33 -0700394}`
395
396// HandleAbandonSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87/abandon`
397// on the test handler mux that responds with an `Abandon` response.
Pratik Mallya827c03e2015-09-17 00:10:47 -0500398func HandleAbandonSuccessfully(t *testing.T, output string) {
399 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 -0700400 th.TestMethod(t, r, "DELETE")
401 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
402 th.TestHeader(t, r, "Accept", "application/json")
403
404 w.Header().Set("Content-Type", "application/json")
405 w.WriteHeader(http.StatusOK)
Pratik Mallya827c03e2015-09-17 00:10:47 -0500406 fmt.Fprintf(w, output)
Jon Perritt9209df42015-02-05 12:55:33 -0700407 })
408}
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500409
Pratik Mallya3de347f2015-09-22 12:25:59 -0500410// ValidJSONTemplate is a valid OpenStack Heat template in JSON format
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500411const ValidJSONTemplate = `
412{
413 "heat_template_version": "2014-10-16",
414 "parameters": {
415 "flavor": {
416 "default": 4353,
417 "description": "Flavor for the server to be created",
418 "hidden": true,
419 "type": "string"
420 }
421 },
422 "resources": {
423 "test_server": {
424 "properties": {
425 "flavor": "2 GB General Purpose v1",
426 "image": "Debian 7 (Wheezy) (PVHVM)",
427 "name": "test-server"
428 },
429 "type": "OS::Nova::Server"
430 }
431 }
432}
433`
434
Pratik Mallya3de347f2015-09-22 12:25:59 -0500435// ValidJSONTemplateParsed is the expected parsed version of ValidJSONTemplate
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500436var ValidJSONTemplateParsed = map[string]interface{}{
437 "heat_template_version": "2014-10-16",
438 "parameters": map[string]interface{}{
439 "flavor": map[string]interface{}{
440 "default": 4353,
441 "description": "Flavor for the server to be created",
442 "hidden": true,
443 "type": "string",
444 },
445 },
446 "resources": map[string]interface{}{
447 "test_server": map[string]interface{}{
448 "properties": map[string]interface{}{
449 "flavor": "2 GB General Purpose v1",
450 "image": "Debian 7 (Wheezy) (PVHVM)",
451 "name": "test-server",
452 },
453 "type": "OS::Nova::Server",
454 },
455 },
456}
457
Pratik Mallya3de347f2015-09-22 12:25:59 -0500458// ValidYAMLTemplate is a valid OpenStack Heat template in YAML format
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500459const ValidYAMLTemplate = `
460heat_template_version: 2014-10-16
461parameters:
462 flavor:
463 type: string
464 description: Flavor for the server to be created
465 default: 4353
466 hidden: true
467resources:
468 test_server:
469 type: "OS::Nova::Server"
470 properties:
471 name: test-server
472 flavor: 2 GB General Purpose v1
473 image: Debian 7 (Wheezy) (PVHVM)
474`
475
Pratik Mallya3de347f2015-09-22 12:25:59 -0500476// InvalidTemplateNoVersion is an invalid template as it has no `version` section
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500477const InvalidTemplateNoVersion = `
478parameters:
479 flavor:
480 type: string
481 description: Flavor for the server to be created
482 default: 4353
483 hidden: true
484resources:
485 test_server:
486 type: "OS::Nova::Server"
487 properties:
488 name: test-server
489 flavor: 2 GB General Purpose v1
490 image: Debian 7 (Wheezy) (PVHVM)
491`
492
Pratik Mallya3de347f2015-09-22 12:25:59 -0500493// ValidJSONEnvironment is a valid environment for a stack in JSON format
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500494const ValidJSONEnvironment = `
495{
496 "parameters": {
497 "user_key": "userkey"
498 },
499 "resource_registry": {
500 "My::WP::Server": "file:///home/shardy/git/heat-templates/hot/F18/WordPress_Native.yaml",
501 "OS::Quantum*": "OS::Neutron*",
502 "AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml",
503 "OS::Metering::Alarm": "OS::Ceilometer::Alarm",
504 "AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml",
505 "resources": {
506 "my_db_server": {
507 "OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml"
508 },
509 "my_server": {
510 "OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
511 "hooks": "pre-create"
512 },
513 "nested_stack": {
514 "nested_resource": {
515 "hooks": "pre-update"
516 },
517 "another_resource": {
518 "hooks": [
519 "pre-create",
520 "pre-update"
521 ]
522 }
523 }
524 }
525 }
526}
527`
528
Pratik Mallya3de347f2015-09-22 12:25:59 -0500529// ValidJSONEnvironmentParsed is the expected parsed version of ValidJSONEnvironment
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500530var ValidJSONEnvironmentParsed = map[string]interface{}{
531 "parameters": map[string]interface{}{
532 "user_key": "userkey",
533 },
534 "resource_registry": map[string]interface{}{
535 "My::WP::Server": "file:///home/shardy/git/heat-templates/hot/F18/WordPress_Native.yaml",
536 "OS::Quantum*": "OS::Neutron*",
537 "AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml",
538 "OS::Metering::Alarm": "OS::Ceilometer::Alarm",
539 "AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml",
540 "resources": map[string]interface{}{
541 "my_db_server": map[string]interface{}{
542 "OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
543 },
544 "my_server": map[string]interface{}{
545 "OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
546 "hooks": "pre-create",
547 },
548 "nested_stack": map[string]interface{}{
549 "nested_resource": map[string]interface{}{
550 "hooks": "pre-update",
551 },
552 "another_resource": map[string]interface{}{
553 "hooks": []interface{}{
554 "pre-create",
555 "pre-update",
556 },
557 },
558 },
559 },
560 },
561}
562
Pratik Mallya3de347f2015-09-22 12:25:59 -0500563// ValidYAMLEnvironment is a valid environment for a stack in YAML format
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500564const ValidYAMLEnvironment = `
565parameters:
566 user_key: userkey
567resource_registry:
568 My::WP::Server: file:///home/shardy/git/heat-templates/hot/F18/WordPress_Native.yaml
569 # allow older templates with Quantum in them.
570 "OS::Quantum*": "OS::Neutron*"
571 # Choose your implementation of AWS::CloudWatch::Alarm
572 "AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml"
573 #"AWS::CloudWatch::Alarm": "OS::Heat::CWLiteAlarm"
574 "OS::Metering::Alarm": "OS::Ceilometer::Alarm"
575 "AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml"
576 resources:
577 my_db_server:
578 "OS::DBInstance": file:///home/mine/all_my_cool_templates/db.yaml
579 my_server:
580 "OS::DBInstance": file:///home/mine/all_my_cool_templates/db.yaml
581 hooks: pre-create
582 nested_stack:
583 nested_resource:
584 hooks: pre-update
585 another_resource:
586 hooks: [pre-create, pre-update]
587`
588
Pratik Mallya3de347f2015-09-22 12:25:59 -0500589// InvalidEnvironment is an invalid environment as it has an extra section called `resources`
Pratik Mallya5fddb2a2015-09-14 14:04:49 -0500590const InvalidEnvironment = `
591parameters:
592 flavor:
593 type: string
594 description: Flavor for the server to be created
595 default: 4353
596 hidden: true
597resources:
598 test_server:
599 type: "OS::Nova::Server"
600 properties:
601 name: test-server
602 flavor: 2 GB General Purpose v1
603 image: Debian 7 (Wheezy) (PVHVM)
604parameter_defaults:
605 KeyName: heat_key
606`