summaryrefslogtreecommitdiff
path: root/openstack_dashboard/test/test_data/heat_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/test/test_data/heat_data.py')
-rw-r--r--openstack_dashboard/test/test_data/heat_data.py617
1 files changed, 0 insertions, 617 deletions
diff --git a/openstack_dashboard/test/test_data/heat_data.py b/openstack_dashboard/test/test_data/heat_data.py
deleted file mode 100644
index 61ea1b9..0000000
--- a/openstack_dashboard/test/test_data/heat_data.py
+++ /dev/null
@@ -1,617 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from heatclient.v1 import resource_types
14from heatclient.v1 import resources
15from heatclient.v1 import services
16from heatclient.v1 import stacks
17from heatclient.v1 import template_versions
18
19from openstack_dashboard.test.test_data import utils
20
21# A slightly hacked up copy of a sample cloudformation template for testing.
22TEMPLATE = """
23{
24"AWSTemplateFormatVersion": "2010-09-09",
25"Description": "AWS CloudFormation Sample Template.",
26"Parameters": {
27"KeyName": {
28"Description": "Name of an EC2 Key Pair to enable SSH access to the instances",
29"Type": "String"
30},
31"InstanceType": {
32"Description": "WebServer EC2 instance type",
33"Type": "String",
34"Default": "m1.small",
35"AllowedValues": [
36"m1.tiny",
37"m1.small",
38"m1.medium",
39"m1.large",
40"m1.xlarge"
41],
42"ConstraintDescription": "must be a valid EC2 instance type."
43},
44"DBName": {
45"Default": "wordpress",
46"Description": "The WordPress database name",
47"Type": "String",
48"MinLength": "1",
49"MaxLength": "64",
50"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
51"ConstraintDescription": "must begin with a letter and..."
52},
53"DBUsername": {
54"Default": "admin",
55"NoEcho": "true",
56"Description": "The WordPress database admin account username",
57"Type": "String",
58"MinLength": "1",
59"MaxLength": "16",
60"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
61"ConstraintDescription": "must begin with a letter and..."
62},
63"DBPassword": {
64"Default": "admin",
65"NoEcho": "true",
66"Description": "The WordPress database admin account password",
67"Type": "String",
68"MinLength": "1",
69"MaxLength": "41",
70"AllowedPattern": "[a-zA-Z0-9]*",
71"ConstraintDescription": "must contain only alphanumeric characters."
72},
73"DBRootPassword": {
74"Default": "admin",
75"NoEcho": "true",
76"Description": "Root password for MySQL",
77"Type": "String",
78"MinLength": "1",
79"MaxLength": "41",
80"AllowedPattern": "[a-zA-Z0-9]*",
81"ConstraintDescription": "must contain only alphanumeric characters."
82},
83"LinuxDistribution": {
84"Default": "F17",
85"Description": "Distribution of choice",
86"Type": "String",
87"AllowedValues": [
88"F18",
89"F17",
90"U10",
91"RHEL-6.1",
92"RHEL-6.2",
93"RHEL-6.3"
94]
95},
96"Network": {
97"Type": "String",
98"CustomConstraint": "neutron.network"
99}
100},
101"Mappings": {
102"AWSInstanceType2Arch": {
103"m1.tiny": {
104"Arch": "32"
105},
106"m1.small": {
107"Arch": "64"
108},
109"m1.medium": {
110"Arch": "64"
111},
112"m1.large": {
113"Arch": "64"
114},
115"m1.xlarge": {
116"Arch": "64"
117}
118},
119"DistroArch2AMI": {
120"F18": {
121"32": "F18-i386-cfntools",
122"64": "F18-x86_64-cfntools"
123},
124"F17": {
125"32": "F17-i386-cfntools",
126"64": "F17-x86_64-cfntools"
127},
128"U10": {
129"32": "U10-i386-cfntools",
130"64": "U10-x86_64-cfntools"
131},
132"RHEL-6.1": {
133"32": "rhel61-i386-cfntools",
134"64": "rhel61-x86_64-cfntools"
135},
136"RHEL-6.2": {
137"32": "rhel62-i386-cfntools",
138"64": "rhel62-x86_64-cfntools"
139},
140"RHEL-6.3": {
141"32": "rhel63-i386-cfntools",
142"64": "rhel63-x86_64-cfntools"
143}
144}
145},
146"Resources": {
147"WikiDatabase": {
148"Type": "AWS::EC2::Instance",
149"Metadata": {
150"AWS::CloudFormation::Init": {
151"config": {
152"packages": {
153"yum": {
154"mysql": [],
155"mysql-server": [],
156"httpd": [],
157"wordpress": []
158}
159},
160"services": {
161"systemd": {
162"mysqld": {
163"enabled": "true",
164"ensureRunning": "true"
165},
166"httpd": {
167"enabled": "true",
168"ensureRunning": "true"
169}
170}
171}
172}
173}
174},
175"Properties": {
176"ImageId": {
177"Fn::FindInMap": [
178"DistroArch2AMI",
179{
180"Ref": "LinuxDistribution"
181},
182{
183"Fn::FindInMap": [
184"AWSInstanceType2Arch",
185{
186"Ref": "InstanceType"
187},
188"Arch"
189]
190}
191]
192},
193"InstanceType": {
194"Ref": "InstanceType"
195},
196"KeyName": {
197"Ref": "KeyName"
198},
199"UserData": {
200"Fn::Base64": {
201"Fn::Join": [
202"",
203[
204"#!/bin/bash -v\\n",
205"/opt/aws/bin/cfn-init\\n"
206]
207]
208}
209}
210}
211}
212},
213"Outputs": {
214"WebsiteURL": {
215"Value": {
216"Fn::Join": [
217"",
218[
219"http://",
220{
221"Fn::GetAtt": [
222"WikiDatabase",
223"PublicIp"
224]
225},
226"/wordpress"
227]
228]
229},
230"Description": "URL for Wordpress wiki"
231}
232}
233}
234"""
235
236VALIDATE = """
237{
238"Description": "AWS CloudFormation Sample Template.",
239"Parameters": {
240"DBUsername": {
241"Type": "String",
242"Description": "The WordPress database admin account username",
243"Default": "admin",
244"MinLength": "1",
245"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
246"NoEcho": "true",
247"MaxLength": "16",
248"ConstraintDescription": "must begin with a letter and..."
249},
250"LinuxDistribution": {
251"Default": "F17",
252"Type": "String",
253"Description": "Distribution of choice",
254"AllowedValues": [
255"F18",
256"F17",
257"U10",
258"RHEL-6.1",
259"RHEL-6.2",
260"RHEL-6.3"
261]
262},
263"DBRootPassword": {
264"Type": "String",
265"Description": "Root password for MySQL",
266"Default": "admin",
267"MinLength": "1",
268"AllowedPattern": "[a-zA-Z0-9]*",
269"NoEcho": "true",
270"MaxLength": "41",
271"ConstraintDescription": "must contain only alphanumeric characters."
272},
273"KeyName": {
274"Type": "String",
275"Description": "Name of an EC2 Key Pair to enable SSH access to the instances"
276},
277"DBName": {
278"Type": "String",
279"Description": "The WordPress database name",
280"Default": "wordpress",
281"MinLength": "1",
282"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
283"MaxLength": "64",
284"ConstraintDescription": "must begin with a letter and..."
285},
286"DBPassword": {
287"Type": "String",
288"Description": "The WordPress database admin account password",
289"Default": "admin",
290"MinLength": "1",
291"AllowedPattern": "[a-zA-Z0-9]*",
292"NoEcho": "true",
293"MaxLength": "41",
294"ConstraintDescription": "must contain only alphanumeric characters."
295},
296"InstanceType": {
297"Default": "m1.small",
298"Type": "String",
299"ConstraintDescription": "must be a valid EC2 instance type.",
300"Description": "WebServer EC2 instance type",
301"AllowedValues": [
302"m1.tiny",
303"m1.small",
304"m1.medium",
305"m1.large",
306"m1.xlarge"
307]
308},
309"Network": {
310"Type": "String",
311"CustomConstraint": "neutron.network"
312}
313}
314}
315"""
316
317ENVIRONMENT = """
318parameters:
319 InstanceType: m1.xsmall
320 db_password: verybadpass
321 KeyName: heat_key
322"""
323
324SNAPSHOT_CREATE = """
325{
326 "status": "IN_PROGRESS",
327 "name": "None",
328 "data": "None",
329 "creation_time": "2016-02-19T07:25:23.494152",
330 "status_reason": "None",
331 "id": "8af90c07-b788-44ee-a8ab-5990197f5e32"
332}
333"""
334
335
336class Environment(object):
337 def __init__(self, data):
338 self.data = data
339
340
341class Template(object):
342 def __init__(self, data, validate):
343 self.data = data
344 self.validate = validate
345
346
347class Snapshot(object):
348 def __init__(self, data):
349 self.data = data
350
351
352def data(TEST):
353 TEST.stacks = utils.TestDataContainer()
354 TEST.stack_templates = utils.TestDataContainer()
355 TEST.stack_environments = utils.TestDataContainer()
356 TEST.stack_snapshot_create = utils.TestDataContainer()
357 TEST.stack_snapshot = utils.TestDataContainer()
358 TEST.resource_types = utils.TestDataContainer()
359 TEST.heat_resources = utils.TestDataContainer()
360 TEST.heat_services = utils.TestDataContainer()
361 TEST.template_versions = utils.TestDataContainer()
362 TEST.template_functions = utils.TestDataContainer()
363
364 # Services
365 service_1 = services.Service(services.ServiceManager(None), {
366 "status": "up",
367 "binary": "heat-engine",
368 "report_interval": 60,
369 "engine_id": "2f7b5a9b-c50b-4b01-8248-f89f5fb338d1",
370 "created_at": "2015-02-06T03:23:32.000000",
371 "hostname": "mrkanag",
372 "updated_at": "2015-02-20T09:49:52.000000",
373 "topic": "engine",
374 "host": "engine-1",
375 "deleted_at": None,
376 "id": "1efd7015-5016-4caa-b5c8-12438af7b100"
377 })
378
379 service_2 = services.Service(services.ServiceManager(None), {
380 "status": "up",
381 "binary": "heat-engine",
382 "report_interval": 60,
383 "engine_id": "2f7b5a9b-c50b-4b01-8248-f89f5fb338d2",
384 "created_at": "2015-02-06T03:23:32.000000",
385 "hostname": "mrkanag",
386 "updated_at": "2015-02-20T09:49:52.000000",
387 "topic": "engine",
388 "host": "engine-2",
389 "deleted_at": None,
390 "id": "1efd7015-5016-4caa-b5c8-12438af7b100"
391 })
392
393 TEST.heat_services.add(service_1)
394 TEST.heat_services.add(service_2)
395
396 # Data return by heatclient.
397 TEST.api_resource_types = utils.TestDataContainer()
398
399 for i in range(10):
400 stack_data = {
401 "description": "No description",
402 "links": [{
403 "href": "http://192.168.1.70:8004/v1/"
404 "051c727ee67040d6a7b7812708485a97/"
405 "stacks/stack-test{0}/"
406 "05b4f39f-ea96-4d91-910c-e758c078a089{0}".format(i),
407 "rel": "self"
408 }],
409 "parameters": {
410 'DBUsername': '******',
411 'InstanceType': 'm1.small',
412 'AWS::StackId': (
413 'arn:openstack:heat::2ce287:stacks/teststack/88553ec'),
414 'DBRootPassword': '******',
415 'AWS::StackName': "teststack{0}".format(i),
416 'DBPassword': '******',
417 'AWS::Region': 'ap-southeast-1',
418 'DBName': u'wordpress'
419 },
420 "stack_status_reason": "Stack successfully created",
421 "stack_name": "stack-test{0}".format(i),
422 "creation_time": "2013-04-22T00:11:39Z",
423 "updated_time": "2013-04-22T00:11:39Z",
424 "stack_status": "CREATE_COMPLETE",
425 "id": "05b4f39f-ea96-4d91-910c-e758c078a089{0}".format(i)
426 }
427 stack = stacks.Stack(stacks.StackManager(None), stack_data)
428 TEST.stacks.add(stack)
429
430 for i in range(10):
431 snapshot_data = {
432 "status": "COMPLETE",
433 "name": 'null',
434 "data": {
435 "files": {},
436 "status": "COMPLETE",
437 "name": "zhao3",
438 "tags": ["a", " 123", " b", " 456"],
439 "stack_user_project_id": "3cba4460875444049a2a7cc5420ccddb",
440 "environment": {
441 "encrypted_param_names": [],
442 "parameter_defaults": {},
443 "event_sinks": [],
444 "parameters": {},
445 "resource_registry": {
446 "resources": {}
447 }
448 },
449 "template": {
450 "heat_template_version": "2013-05-23",
451 "description":
452 "HOT template for Test.",
453 "resources": {
454 "private_subnet": {
455 "type": "OS::Neutron::Subnet",
456 "properties": {
457 "network_id": {"get_resource": "private_net"},
458 "cidr": "172.16.2.0/24",
459 "gateway_ip": "172.16.2.1"
460 }
461 },
462 "private_net": {
463 "type": "OS::Neutron::Net",
464 "properties": {"name": "private-net"}
465 }
466 }
467 },
468 "action": "SNAPSHOT",
469 "project_id": "1acd0026829f4d28bb2eff912d7aad0d",
470 "id": "70650725-bdbd-419f-b53f-5707767bfe0e",
471 "resources": {
472 "private_subnet": {
473 "status": "COMPLETE",
474 "name": "private_subnet",
475 "resource_data": {},
476 "resource_id": "9c7211b3-31c7-41f6-b92a-442ad3f71ef0",
477 "action": "SNAPSHOT",
478 "type": "OS::Neutron::Subnet",
479 "metadata": {}
480 },
481 "private_net": {
482 "status": "COMPLETE",
483 "name": "private_net",
484 "resource_data": {},
485 "resource_id": "ff4fd287-31b2-4d00-bc96-c409bc1db027",
486 "action": "SNAPSHOT",
487 "type": "OS::Neutron::Net",
488 "metadata": {}
489 }
490 }
491 },
492
493 "creation_time": "2016-02-21T04:02:54",
494 "status_reason": "Stack SNAPSHOT completed successfully",
495 "id": "01558a3b-ba05-4427-bbb4-1e4ab71cfca{0}".format(i)
496 }
497 TEST.stack_snapshot.add(snapshot_data)
498
499 TEST.stack_templates.add(Template(TEMPLATE, VALIDATE))
500 TEST.stack_environments.add(Environment(ENVIRONMENT))
501 TEST.stack_snapshot_create.add(Snapshot(SNAPSHOT_CREATE))
502
503 # Resource types list
504 r_type_1 = {
505 "resource_type": "AWS::CloudFormation::Stack",
506 "attributes": {},
507 "properties": {
508 "Parameters": {
509 "description":
510 "The set of parameters passed to this nested stack.",
511 "immutable": False,
512 "required": False,
513 "type": "map",
514 "update_allowed": True},
515 "TemplateURL": {
516 "description": "The URL of a template that specifies"
517 " the stack to be created as a resource.",
518 "immutable": False,
519 "required": True,
520 "type": "string",
521 "update_allowed": True},
522 "TimeoutInMinutes": {
523 "description": "The length of time, in minutes,"
524 " to wait for the nested stack creation.",
525 "immutable": False,
526 "required": False,
527 "type": "number",
528 "update_allowed": True}
529 }
530 }
531
532 r_type_2 = {
533 "resource_type": "OS::Heat::CloudConfig",
534 "attributes": {
535 "config": {
536 "description": "The config value of the software config."}
537 },
538 "properties": {
539 "cloud_config": {
540 "description": "Map representing the cloud-config data"
541 " structure which will be formatted as YAML.",
542 "immutable": False,
543 "required": False,
544 "type": "map",
545 "update_allowed": False}
546 }
547 }
548
549 r_types_list = [r_type_1, r_type_2]
550
551 for rt in r_types_list:
552 r_type = resource_types.ResourceType(
553 resource_types.ResourceTypeManager(None), rt['resource_type'])
554 TEST.resource_types.add(r_type)
555 TEST.api_resource_types.add(rt)
556
557 # Resources
558 resource_1 = resources.Resource(resources.ResourceManager(None), {
559 "logical_resource_id": "my_resource",
560 "physical_resource_id": "7b5e29b1-c94d-402d-b69c-df9ac6dfc0ce",
561 "resource_name": "my_resource",
562 "links": [
563 {
564 "href": "http://192.168.1.70:8004/v1/"
565 "051c727ee67040d6a7b7812708485a97/"
566 "stacks/%s/%s/resources/my_resource" %
567 (TEST.stacks.first().stack_name,
568 TEST.stacks.first().id),
569 "rel": "self"
570 },
571 {
572 "href": "http://192.168.1.70:8004/v1/"
573 "051c727ee67040d6a7b7812708485a97/"
574 "stacks/%s/%s" %
575 (TEST.stacks.first().stack_name,
576 TEST.stacks.first().id),
577 "rel": "stack"
578 }
579 ],
580 "attributes": {
581 "metadata": {}
582 }
583 })
584
585 TEST.heat_resources.add(resource_1)
586
587 # Template versions
588 template_version_1 = template_versions.TemplateVersion(
589 template_versions.TemplateVersionManager(None), {
590 "version": "HeatTemplateFormatVersion.2012-12-12",
591 "type": "cfn"
592 })
593
594 template_version_2 = template_versions.TemplateVersion(
595 template_versions.TemplateVersionManager(None), {
596 "version": "heat_template_version.2013-05-23",
597 "type": "hot"
598 })
599
600 TEST.template_versions.add(template_version_1)
601 TEST.template_versions.add(template_version_2)
602
603 # Template functions
604 template_function_1 = template_versions.TemplateVersion(
605 template_versions.TemplateVersionManager(None), {
606 "functions": "Fn::GetAZs",
607 "description": "A function for retrieving the availability zones."
608 })
609
610 template_function_2 = template_versions.TemplateVersion(
611 template_versions.TemplateVersionManager(None), {
612 "functions": "Fn::Join",
613 "description": "A function for joining strings."
614 })
615
616 TEST.template_functions.add(template_function_1)
617 TEST.template_functions.add(template_function_2)