Pass flavor metadata into heat template
[snaps.git] / snaps / openstack / tests / heat / floating_ip_heat_template.yaml
1 ##############################################################################
2 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
3 #                    and others.  All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 ##############################################################################
17 heat_template_version: 2015-04-30
18
19 description: >
20   Sample template with two VMs instantiated against different images and
21   flavors on the same network and the first one has a floating IP
22
23 parameters:
24   image1_name:
25     type: string
26     label: Image ID for first VM
27     description: Image name to be used for first instance
28     default: image_1
29   image2_name:
30     type: string
31     label: Image ID for second VM
32     description: Image name to be used for second instance
33     default: image_2
34   flavor1_name:
35     type: string
36     label: Instance Flavor for first VM
37     description: Flavor name for the first instance
38     default: m1.small
39   flavor2_name:
40     type: string
41     label: Instance Flavor for second VM
42     description: Flavor name for the second instance
43     default: m1.med
44   flavor_extra_specs:
45     type: json
46     description: Instance Flavor extra specs
47     default: {}
48   net_name:
49     type: string
50     label: Test network name
51     description: The name of the stack's network
52     default: test_net
53   subnet_name:
54     type: string
55     label: Test subnet name
56     description: The name of the stack's subnet
57     default: test_subnet
58   router_name:
59     type: string
60     label: Test router name
61     description: The name of the stack's router
62     default: mgmt_router
63   keypair_name:
64     type: string
65     label: Keypair name
66     description: The name of the stack's keypair
67     default: keypair_name
68   security_group_name:
69     type: string
70     label: Security Group name
71     description: The name of the stack's security group
72     default: security_group_name
73   inst1_name:
74     type: string
75     label: First VM name
76     description: The name of the first VM to be spawned
77     default: test_vm1
78   inst2_name:
79     type: string
80     label: Second VM name
81     description: The name of the second VM to be spawned
82     default: test_vm2
83   external_net_name:
84     type: string
85     description: Name of the external network which management network will connect to
86     default: external
87
88 resources:
89   flavor1:
90     type: OS::Nova::Flavor
91     properties:
92       ram: 1024
93       vcpus: 2
94       disk: 2
95       extra_specs: { get_param: flavor_extra_specs }
96   flavor2:
97     type: OS::Nova::Flavor
98     properties:
99       ram: 1024
100       vcpus: 2
101       disk: 2
102       extra_specs: { get_param: flavor_extra_specs }
103
104   network:
105     type: OS::Neutron::Net
106     properties:
107       name: { get_param: net_name }
108
109   subnet:
110     type: OS::Neutron::Subnet
111     properties:
112       name: { get_param: subnet_name }
113       ip_version: 4
114       cidr: 10.1.2.0/24
115       network: { get_resource: network }
116
117   management_router:
118     type: OS::Neutron::Router
119     properties:
120       name: { get_param: router_name }
121       external_gateway_info:
122         network: { get_param: external_net_name }
123
124   management_router_interface:
125     type: OS::Neutron::RouterInterface
126     properties:
127       router: { get_resource: management_router }
128       subnet: { get_resource: subnet }
129
130   server_security_group:
131     type: OS::Neutron::SecurityGroup
132     properties:
133       description: Add security group rules for server
134       name: { get_param: security_group_name }
135       rules:
136         - remote_ip_prefix: 0.0.0.0/0
137           protocol: tcp
138           port_range_min: 22
139           port_range_max: 22
140         - remote_ip_prefix: 0.0.0.0/0
141           protocol: icmp
142
143   floating_ip:
144     type: OS::Neutron::FloatingIP
145     properties:
146       floating_network: { get_param: external_net_name }
147
148   floating_ip_association:
149     type: OS::Neutron::FloatingIPAssociation
150     properties:
151       floatingip_id: { get_resource: floating_ip }
152       port_id: {get_resource: port1}
153
154   keypair:
155     type: OS::Nova::KeyPair
156     properties:
157       name: { get_param: keypair_name }
158       save_private_key: True
159
160   port1:
161     type: OS::Neutron::Port
162     properties:
163       network: { get_resource: network }
164       security_groups: [{ get_resource: server_security_group }]
165       fixed_ips:
166         - subnet_id: { get_resource: subnet }
167
168   vm1:
169     type: OS::Nova::Server
170     depends_on: [subnet, keypair, flavor1, port1]
171     properties:
172       name: { get_param: inst1_name }
173       image: { get_param: image1_name }
174       flavor: { get_resource: flavor1 }
175       key_name: {get_resource: keypair}
176       networks:
177         - port: { get_resource: port1 }
178
179   vm2:
180     type: OS::Nova::Server
181     depends_on: [subnet, keypair, flavor2]
182     properties:
183       name: { get_param: inst2_name }
184       image: { get_param: image2_name }
185       flavor: { get_resource: flavor2 }
186       key_name: {get_resource: keypair}
187       networks:
188         - network: { get_resource: network }
189
190 outputs:
191   private_key:
192     description: "SSH Private Key"
193     value: { get_attr: [ keypair, private_key ]}