Move heat templates from openecom to onap
[demo.git] / heat / vLB / base_vlb_openstack.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 vLoadBalancer/vDNS demo app for ONAP
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   vlb_image_name:
37     type: string
38     label: Image name or ID
39     description: Image to be used for compute instance
40   vlb_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   vlb_private_net_id:
49     type: string
50     label: vLoadBalancer private network name or ID
51     description: Private network that connects vLoadBalancer with vDNSs
52   onap_private_net_id:
53     type: string
54     label: ECOMP management network name or ID
55     description: Private network that connects ONAP component and the VNF
56   onap_private_subnet_id:
57     type: string
58     label: ECOMP management sub-network name or ID
59     description: Private sub-network that connects ONAP component and the VNF
60   vlb_private_net_cidr:
61     type: string
62     label: vLoadBalancer private network CIDR
63     description: The CIDR of the vLoadBalancer 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   vlb_private_ip_0:
69     type: string
70     label: vLoadBalancer private IP address towards the private network
71     description: Private IP address that is assigned to the vLoadBalancer to communicate with the vDNSs
72   vlb_private_ip_1:
73     type: string
74     label: vLoadBalancer private IP address towards the ONAP management network
75     description: Private IP address that is assigned to the vLoadBalancer 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 vLoadBalancer
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   vlb_name_0:
85     type: string
86     label: vLoadBalancer name
87     description: Name of the vLoadBalancer
88   vdns_name_0:
89     type: string
90     label: vDNS name
91     description: Name of the vDNS
92   vnf_id:
93     type: string
94     label: VNF ID
95     description: The VNF ID is provided by ONAP
96   vf_module_id:
97     type: string
98     label: vFirewall module ID
99     description: The vLoadBalancer Module ID is provided by ONAP
100   dcae_collector_ip:
101     type: string
102     label: DCAE collector IP address
103     description: IP address of the DCAE collector
104   dcae_collector_port:
105     type: string
106     label: DCAE collector port
107     description: Port of the DCAE collector
108   key_name:
109     type: string
110     label: Key pair name
111     description: Public/Private key pair name
112   pub_key:
113     type: string
114     label: Public key
115     description: Public key to be installed on the compute instance
116   repo_url_blob:
117     type: string
118     label: Repository URL
119     description: URL of the repository that hosts the demo packages
120   repo_url_artifacts:
121     type: string
122     label: Repository URL
123     description: URL of the repository that hosts the demo packages
124   demo_artifacts_version:
125     type: string
126     label: Artifacts version used in demo vnfs
127     description: Artifacts (jar, tar.gz) version used in demo vnfs
128   install_script_version:
129     type: string
130     label: Installation script version number
131     description: Version number of the scripts that install the vFW demo app
132   cloud_env:
133     type: string
134     label: Cloud environment
135     description: Cloud environment (e.g., openstack, rackspace)
136
137 #############
138 #           #
139 # RESOURCES #
140 #           #
141 #############
142
143 resources:
144
145   random-str:
146     type: OS::Heat::RandomString
147     properties:
148       length: 4
149
150   my_keypair:
151     type: OS::Nova::KeyPair
152     properties:
153       name: 
154         str_replace:
155           template: base_rand
156           params:
157             base: { get_param: key_name }
158             rand: { get_resource: random-str }  
159       public_key: { get_param: pub_key }
160       save_private_key: false
161
162   vlb_private_network:
163     type: OS::Neutron::Net
164     properties:
165       name: { get_param: vlb_private_net_id }
166
167   vlb_private_subnet:
168     type: OS::Neutron::Subnet
169     properties:
170       name: { get_param: vlb_private_net_id }
171       network_id: { get_resource: vlb_private_network }
172       cidr: { get_param: vlb_private_net_cidr }
173
174   vlb_private_0_port:
175     type: OS::Neutron::Port
176     properties:
177       network: { get_resource: vlb_private_network }
178       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vlb_private_ip_0 }}]
179
180   vlb_private_1_port:
181     type: OS::Neutron::Port
182     properties:
183       network: { get_param: onap_private_net_id }
184       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_private_ip_1 }}]
185
186   vlb_0:
187     type: OS::Nova::Server
188     properties:
189       image: { get_param: vlb_image_name }
190       flavor: { get_param: vlb_flavor_name }
191       name: { get_param: vlb_name_0 }
192       key_name: { get_resource: my_keypair }
193       networks:
194         - network: { get_param: public_net_id }
195         - port: { get_resource: vlb_private_0_port }
196         - port: { get_resource: vlb_private_1_port }
197       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
198       user_data_format: RAW
199       user_data:
200         str_replace:
201           params:
202             __dcae_collector_ip__: { get_param: dcae_collector_ip }
203             __dcae_collector_port__: { get_param: dcae_collector_port }
204             __local_private_ipaddr__: { get_param: vlb_private_ip_0 }
205             __oam_private_ipaddr__: { get_param: vlb_private_ip_1 }
206             __repo_url_blob__: { get_param: repo_url_blob }
207             __repo_url_artifacts__: { get_param: repo_url_artifacts }
208             __demo_artifacts_version__: { get_param: demo_artifacts_version }
209             __install_script_version__: { get_param: install_script_version }
210             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
211             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
212             __cloud_env__: { get_param: cloud_env }
213           template: |
214             #!/bin/bash
215
216             # Create configuration files
217             mkdir /opt/config
218             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
219             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
220             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
221             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
222             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
223             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
224             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
225             echo "__install_script_version__" > /opt/config/install_script_version.txt
226             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
227             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
228             echo "__cloud_env__" > /opt/config/cloud_env.txt
229
230             # Download and run install script
231             curl -k __repo_url_blob__/org.onap.demo/vnfs/vlb/__install_script_version__/v_lb_install.sh -o /opt/v_lb_install.sh
232             cd /opt
233             chmod +x v_lb_install.sh
234             ./v_lb_install.sh
235
236
237   vdns_private_0_port:
238     type: OS::Neutron::Port
239     properties:
240       network: { get_resource: vlb_private_network }
241       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vdns_private_ip_0 }}]
242
243   vdns_private_1_port:
244     type: OS::Neutron::Port
245     properties:
246       network: { get_param: onap_private_net_id }
247       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]
248
249   vdns_0:
250     type: OS::Nova::Server
251     properties:
252       image: { get_param: vlb_image_name }
253       flavor: { get_param: vlb_flavor_name }
254       name: { get_param: vdns_name_0 }
255       key_name: { get_resource: my_keypair }
256       networks:
257         - network: { get_param: public_net_id }
258         - port: { get_resource: vdns_private_0_port }
259         - port: { get_resource: vdns_private_1_port }
260       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
261       user_data_format: RAW
262       user_data:
263         str_replace:
264           params:
265             __lb_oam_int__: { get_param: vlb_private_ip_1 }
266             __lb_private_ipaddr__: { get_param: vlb_private_ip_0 }
267             __local_private_ipaddr__: { get_param: vdns_private_ip_0 }
268             __oam_private_ipaddr__: { get_param: vdns_private_ip_1 }
269             __repo_url_blob__: { get_param: repo_url_blob }
270             __repo_url_artifacts__: { get_param: repo_url_artifacts }
271             __demo_artifacts_version__: { get_param: demo_artifacts_version }
272             __install_script_version__: { get_param: install_script_version }
273             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
274             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
275             __cloud_env__: { get_param: cloud_env }
276           template: |
277             #!/bin/bash
278
279             # Create configuration files
280             mkdir /opt/config
281             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
282             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
283             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
284             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
285             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
286             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
287             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
288             echo "__install_script_version__" > /opt/config/install_script_version.txt
289             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
290             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
291             echo "__cloud_env__" > /opt/config/cloud_env.txt
292
293             # Download and run install script
294             curl -k __repo_url_blob__/org.onap.demo/vnfs/vlb/__install_script_version__/v_dns_install.sh -o /opt/v_dns_install.sh
295             cd /opt
296             chmod +x v_dns_install.sh
297             ./v_dns_install.sh