Move heat templates from openecom to onap
[demo.git] / heat / vCPE / infra / base_vcpe_infra_rackspace.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4
5 #
6 # Copyright 2017 AT&T Intellectual Property. All rights reserved.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #        http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 #==================LICENSE_END============================================
20 #
21 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 #
23 ##########################################################################
24
25 heat_template_version: 2013-05-23
26
27 description: Heat template to deploy vCPE Infrastructue emlements (vAAA, vDHCP, vDNS_DHCP) for ONAP
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   vcpe_image_name:
37     type: string
38     label: Image name or ID
39     description: Image to be used for compute instance
40   vcpe_flavor_name:
41     type: string
42     label: Flavor
43     description: Type of instance (flavor) to be used
44   public_net_id:
45     type: string
46     label: Public network name or ID
47     description: Public network that enables remote connection to VNF
48   vaaa_private_net_id:
49     type: string
50     label: vAAA private network name or ID
51     description: Private network that connects vAAA with vDNSs
52   onap_private_net_id:
53     type: string
54     label: ONAP management network name or ID
55     description: Private network that connects ONAP components and the VNF
56   onap_private_subnet_id:
57     type: string
58     label: ONAP management sub-network name or ID
59     description: Private sub-network that connects ONAP components and the VNF
60   vaaa_private_net_cidr:
61     type: string
62     label: vAAA private network CIDR
63     description: The CIDR of the vAAA private network
64   onap_private_net_cidr:
65     type: string
66     label: ONAP private network CIDR
67     description: The CIDR of the protected private network
68   vaaa_private_ip_0:
69     type: string
70     label: vAAA private IP address towards the private network
71     description: Private IP address that is assigned to the vAAA to communicate with the vCPE components 
72   vaaa_private_ip_1:
73     type: string
74     label: vAAA private IP address towards the ONAP management network
75     description: Private IP address that is assigned to the vAAA to communicate with ONAP components
76   vdns_private_ip_0:
77     type: string
78     label: vDNS private IP address towards the private network
79     description: Private IP address that is assigned to the vDNS to communicate with the vCPE components
80   vdns_private_ip_1:
81     type: string
82     label: vDNS private IP address towards the ONAP management network
83     description: Private IP address that is assigned to the vDNS to communicate with ONAP components
84   vdhcp_private_ip_0:
85     type: string
86     label: vDHCP  private IP address towards the private network
87     description: Private IP address that is assigned to the vDHCP to communicate with the vCPE components
88   vdhcp_private_ip_1:
89     type: string
90     label: vDNS private IP address towards the ONAP management network
91     description: Private IP address that is assigned to the vDHCP to communicate with ONAP components
92   vaaa_name_0:
93     type: string
94     label: vAAA name
95     description: Name of the vAAA
96   vdns_name_0:
97     type: string
98     label: vDNS name
99     description: Name of the vDNS
100   vdhcp_name_0:
101     type: string
102     label: vDHCP name
103     description: Name of the vDHCP
104   vnf_id:
105     type: string
106     label: VNF ID
107     description: The VNF ID is provided by ONAP
108   vf_module_id:
109     type: string
110     label: vFirewall module ID
111     description: The vAAA Module ID is provided by ONAP
112   dcae_collector_ip:
113     type: string
114     label: DCAE collector IP address
115     description: IP address of the DCAE collector
116   dcae_collector_port:
117     type: string
118     label: DCAE collector port
119     description: Port of the DCAE collector
120   key_name:
121     type: string
122     label: Key pair name
123     description: Public/Private key pair name
124   pub_key:
125     type: string
126     label: Public key
127     description: Public key to be installed on the compute instance
128   repo_url_blob:
129     type: string
130     label: Repository URL
131     description: URL of the repository that hosts the demo packages
132   repo_url_artifacts:
133     type: string
134     label: Repository URL
135     description: URL of the repository that hosts the demo packages
136   install_script_version:
137     type: string
138     label: Installation script version number
139     description: Version number of the scripts that install the vFW demo app
140   demo_artifacts_version:
141     type: string
142     label: Artifacts version used in demo vnfs
143     description: Artifacts (jar, tar.gz) version used in demo vnfs
144   cloud_env:
145     type: string
146     label: Cloud environment
147     description: Cloud environment (e.g., openstack, rackspace)
148
149 #############
150 #           #
151 # RESOURCES #
152 #           #
153 #############
154
155 resources:
156
157   random-str:
158     type: OS::Heat::RandomString
159     properties:
160       length: 4
161
162   my_keypair:
163     type: OS::Nova::KeyPair
164     properties:
165       name:
166         str_replace:
167           template: base_rand
168           params:
169             base: { get_param: key_name }
170             rand: { get_resource: random-str }
171       public_key: { get_param: pub_key }
172       save_private_key: false
173
174   vaaa_private_network:
175     type: OS::Neutron::Net
176     properties:
177       name: { get_param: vaaa_private_net_id }
178
179   vaaa_private_subnet:
180     type: OS::Neutron::Subnet
181     properties:
182       name: { get_param: vaaa_private_net_id }
183       network_id: { get_resource: vaaa_private_network }
184       cidr: { get_param: vaaa_private_net_cidr }
185
186   # Virtual Load Balancer Instantiation
187   vaaa_private_0_port:
188     type: OS::Neutron::Port
189     properties:
190       network: { get_resource: vaaa_private_network }
191       fixed_ips: [{"subnet": { get_resource: vaaa_private_subnet }, "ip_address": { get_param: vaaa_private_ip_0 }}]
192
193   vaaa_private_1_port:
194     type: OS::Neutron::Port
195     properties:
196       network: { get_param: onap_private_net_id }
197       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vaaa_private_ip_1 }}]
198
199   vaaa_0:
200     type: OS::Nova::Server
201     properties:
202       image: { get_param: vcpe_image_name }
203       flavor: { get_param: vcpe_flavor_name }
204       name: { get_param: vaaa_name_0 }
205       key_name: { get_resource: my_keypair }
206       networks:
207         - network: { get_param: public_net_id }
208         - port: { get_resource: vaaa_private_0_port }
209         - port: { get_resource: vaaa_private_1_port }
210       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
211       user_data_format: RAW
212       user_data:
213         str_replace:
214           params:
215             __dcae_collector_ip__: { get_param: dcae_collector_ip }
216             __dcae_collector_port__: { get_param: dcae_collector_port }
217             __local_private_ipaddr__: { get_param: vaaa_private_ip_0 }
218             __repo_url_blob__ : { get_param: repo_url_blob }
219             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
220             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
221             __install_script_version__ : { get_param: install_script_version }
222             __cloud_env__ : { get_param: cloud_env }
223           template: |
224             #!/bin/bash
225
226             # Create configuration files
227             mkdir /opt/config
228             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
229             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
230             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
231             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
232             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
233             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
234             echo "__install_script_version__" > /opt/config/install_script_version.txt
235             echo "__cloud_env__" > /opt/config/cloud_env.txt
236
237             # Download and run install script
238             curl -k __repo_url_blob__/org.onap.demo/vnfs/vaaa/__install_script_version__/v_aaa_install.sh -o /opt/v_aaa_install.sh
239             cd /opt
240             chmod +x v_aaa_install.sh
241             ./v_aaa_install.sh
242
243
244   # Virtual DNS Instantiation
245   vdns_private_0_port:
246     type: OS::Neutron::Port
247     properties:
248       network: { get_resource: vaaa_private_network }
249       fixed_ips: [{"subnet": { get_resource: vaaa_private_subnet }, "ip_address": { get_param: vdns_private_ip_0 }}]
250
251   vdns_private_1_port:
252     type: OS::Neutron::Port
253     properties:
254       network: { get_param: onap_private_net_id }
255       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]
256
257   vdns_0:
258     type: OS::Nova::Server
259     properties:
260       image: { get_param: vcpe_image_name }
261       flavor: { get_param: vcpe_flavor_name }
262       name: { get_param: vdns_name_0 }
263       key_name: { get_resource: my_keypair }
264       networks:
265         - network: { get_param: public_net_id }
266         - port: { get_resource: vdns_private_0_port }
267         - port: { get_resource: vdns_private_1_port }
268       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
269       user_data_format: RAW
270       user_data:
271         str_replace:
272           params:
273             __lb_oam_int__ : { get_param: vaaa_private_ip_1 }
274             __lb_private_ipaddr__: { get_param: vaaa_private_ip_0 }
275             __local_private_ipaddr__: { get_param: vdns_private_ip_0 }
276             __repo_url_blob__ : { get_param: repo_url_blob }
277             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
278             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
279             __install_script_version__ : { get_param: install_script_version }
280             __cloud_env__ : { get_param: cloud_env }
281           template: |
282             #!/bin/bash
283
284             # Create configuration files
285             mkdir /opt/config
286             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
287             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
288             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
289             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
290             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
291             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
292             echo "__install_script_version__" > /opt/config/install_script_version.txt
293             echo "__cloud_env__" > /opt/config/cloud_env.txt
294
295             # Download and run install script
296             curl -k __repo_url_blob__/org.onap.demo/vnfs/vdns/__install_script_version__/v_dns_install.sh -o /opt/v_dns_install.sh
297             cd /opt
298             chmod +x v_dns_install.sh
299             ./v_dns_install.sh
300
301
302   # Virtual DHCP Instantiation
303   vdhcp_private_0_port:
304     type: OS::Neutron::Port
305     properties:
306       network: { get_resource: vaaa_private_network }
307       fixed_ips: [{"subnet": { get_resource: vaaa_private_subnet }, "ip_address": { get_param: vdhcp_private_ip_0 }}]
308
309   vdhcp_private_1_port:
310     type: OS::Neutron::Port
311     properties:
312       network: { get_param: onap_private_net_id }
313       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdhcp_private_ip_1 }}]
314
315   vdhcp_0:
316     type: OS::Nova::Server
317     properties:
318       image: { get_param: vcpe_image_name }
319       flavor: { get_param: vcpe_flavor_name }
320       name: { get_param: vdhcp_name_0 }
321       key_name: { get_resource: my_keypair }
322       networks:
323         - network: { get_param: public_net_id }
324         - port: { get_resource: vdhcp_private_0_port }
325         - port: { get_resource: vdhcp_private_1_port }
326       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
327       user_data_format: RAW
328       user_data:
329         str_replace:
330           params:
331             __lb_oam_int__ : { get_param: vaaa_private_ip_1 }
332             __lb_private_ipaddr__: { get_param: vaaa_private_ip_0 }
333             __local_private_ipaddr__: { get_param: vdhcp_private_ip_0 }
334             __repo_url_blob__ : { get_param: repo_url_blob }
335             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
336             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
337             __install_script_version__ : { get_param: install_script_version }
338             __cloud_env__ : { get_param: cloud_env }
339           template: |
340             #!/bin/bash
341
342             # Create configuration files
343             mkdir /opt/config
344             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
345             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
346             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
347             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
348             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
349             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
350             echo "__install_script_version__" > /opt/config/install_script_version.txt
351             echo "__cloud_env__" > /opt/config/cloud_env.txt
352
353             # Download and run install script
354             curl -k __repo_url_blob__/org.onap.demo/vnfs/vdhcp/__install_script_version__/v_dhcp_install.sh -o /opt/v_dhcp_install.sh
355             cd /opt
356             chmod +x v_dhcp_install.sh
357             ./v_dhcp_install.sh