bc8affd1a2a3fa4e5202115a50daf4192e0d90f0
[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   vlb_private_net_id_for_floating:
53     type: string
54     label: vLoadBalancer private network name or ID
55     description: Private network that connects vLoadBalancer with the public OpenStack network using floating IP
56   onap_private_net_id:
57     type: string
58     label: ECOMP management network name or ID
59     description: Private network that connects ONAP component and the VNF
60   onap_private_subnet_id:
61     type: string
62     label: ECOMP management sub-network name or ID
63     description: Private sub-network that connects ONAP component and the VNF
64   vlb_private_net_cidr:
65     type: string
66     label: vLoadBalancer private network CIDR
67     description: The CIDR of the vLoadBalancer private network
68   vlb_private_net_cidr_for_floating:
69     type: string
70     label: vLoadBalancer private network CIDR
71     description: The CIDR of the vLoadBalancer private network that connects vLoadBalancer with the public OpenStack network using floating IP
72   onap_private_net_cidr:
73     type: string
74     label: ONAP private network CIDR
75     description: The CIDR of the protected private network
76   vlb_private_ip_0:
77     type: string
78     label: vLoadBalancer private IP address towards the private network
79     description: Private IP address that is assigned to the vLoadBalancer to communicate with the vDNSs
80   vlb_private_ip_1:
81     type: string
82     label: vLoadBalancer private IP address towards the ONAP management network
83     description: Private IP address that is assigned to the vLoadBalancer to communicate with ONAP components
84   vlb_private_ip_2_for_floating:
85     type: string
86     label: vLoadBalancer private IP address towards the OpenStack public network via floating IP
87     description: vLoadBalancer private IP address towards the OpenStack public network via floating IP
88   vdns_private_ip_0:
89     type: string
90     label: vDNS private IP address towards the private network
91     description: Private IP address that is assigned to the vDNS to communicate with the vLoadBalancer
92   vdns_private_ip_1:
93     type: string
94     label: vDNS private IP address towards the ONAP management network
95     description: Private IP address that is assigned to the vDNS to communicate with ONAP components
96   vlb_name_0:
97     type: string
98     label: vLoadBalancer name
99     description: Name of the vLoadBalancer
100   vdns_name_0:
101     type: string
102     label: vDNS name
103     description: Name of the vDNS
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 vLoadBalancer 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   demo_artifacts_version:
137     type: string
138     label: Artifacts version used in demo vnfs
139     description: Artifacts (jar, tar.gz) version used in demo vnfs
140   install_script_version:
141     type: string
142     label: Installation script version number
143     description: Version number of the scripts that install the vFW demo app
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   vlb_private_network:
175     type: OS::Neutron::Net
176     properties:
177       name: { get_param: vlb_private_net_id }
178
179   vlb_private_subnet:
180     type: OS::Neutron::Subnet
181     properties:
182       name: { get_param: vlb_private_net_id }
183       network_id: { get_resource: vlb_private_network }
184       cidr: { get_param: vlb_private_net_cidr }
185       
186   vlb_private_network_for_floating:
187     type: OS::Neutron::Net
188     properties:
189       name: { get_param: vlb_private_net_id_for_floating }
190
191   vlb_private_subnet_for_floating:
192     type: OS::Neutron::Subnet
193     properties:
194       name: { get_param: vlb_private_net_id_for_floating }
195       network_id: { get_resource: vlb_private_network_for_floating }
196       cidr: { get_param: vlb_private_net_cidr_for_floating }
197
198   vlb_private_0_port:
199     type: OS::Neutron::Port
200     properties:
201       network: { get_resource: vlb_private_network }
202       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vlb_private_ip_0 }}]
203
204   vlb_private_1_port:
205     type: OS::Neutron::Port
206     properties:
207       network: { get_param: onap_private_net_id }
208       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_private_ip_1 }}]
209       
210   vlb_private_2_port_for_floating:
211     type: OS::Neutron::Port
212     properties:
213       network: { get_param: onap_private_net_id }
214       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_private_ip_2_for_floating }}]
215   
216   vlb_floating_ip:
217     type: OS::Neutron::FloatingIP
218     properties:
219       floating_network_id: { get_param: public_net_id }
220       port_id: { get_resource: vlb_private_2_port_for_floating }
221
222   vlb_0:
223     type: OS::Nova::Server
224     properties:
225       image: { get_param: vlb_image_name }
226       flavor: { get_param: vlb_flavor_name }
227       name: { get_param: vlb_name_0 }
228       key_name: { get_resource: my_keypair }
229       networks:
230         - port: { get_resource: vlb_private_2_port_for_floating }
231         - port: { get_resource: vlb_private_0_port }
232         - port: { get_resource: vlb_private_1_port }
233       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
234       user_data_format: RAW
235       user_data:
236         str_replace:
237           params:
238             __dcae_collector_ip__: { get_param: dcae_collector_ip }
239             __dcae_collector_port__: { get_param: dcae_collector_port }
240             __local_private_ipaddr__: { get_param: vlb_private_ip_0 }
241             __oam_private_ipaddr__: { get_param: vlb_private_ip_1 }
242             __repo_url_blob__ : { get_param: repo_url_blob }
243             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
244             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
245             __install_script_version__ : { get_param: install_script_version }
246             __cloud_env__ : { get_param: cloud_env }
247           template: |
248             #!/bin/bash
249
250             # Create configuration files
251             mkdir /opt/config
252             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
253             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
254             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
255             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
256             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
257             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
258             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
259             echo "__install_script_version__" > /opt/config/install_script_version.txt
260             echo "__cloud_env__" > /opt/config/cloud_env.txt
261
262             # Download and run install script
263             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vlb/__install_script_version__/v_lb_install.sh -o /opt/v_lb_install.sh
264             cd /opt
265             chmod +x v_lb_install.sh
266             ./v_lb_install.sh
267
268
269   vdns_private_0_port:
270     type: OS::Neutron::Port
271     properties:
272       network: { get_resource: vlb_private_network }
273       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vdns_private_ip_0 }}]
274
275   vdns_private_1_port:
276     type: OS::Neutron::Port
277     properties:
278       network: { get_param: onap_private_net_id }
279       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]
280
281   vdns_floating_ip:
282     type: OS::Neutron::FloatingIP
283     properties:
284       floating_network_id: { get_param: public_net_id }
285       port_id: { get_resource: vdns_private_1_port }
286
287   vdns_0:
288     type: OS::Nova::Server
289     properties:
290       image: { get_param: vlb_image_name }
291       flavor: { get_param: vlb_flavor_name }
292       name: { get_param: vdns_name_0 }
293       key_name: { get_resource: my_keypair }
294       networks:
295         - port: { get_resource: vdns_private_1_port }
296         - port: { get_resource: vdns_private_0_port }
297       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
298       user_data_format: RAW
299       user_data:
300         str_replace:
301           params:
302             __lb_oam_int__ : { get_param: vlb_private_ip_1 }
303             __lb_private_ipaddr__: { get_param: vlb_private_ip_0 }
304             __local_private_ipaddr__: { get_param: vdns_private_ip_0 }
305             __repo_url_blob__ : { get_param: repo_url_blob }
306             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
307             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
308             __install_script_version__ : { get_param: install_script_version }
309             __cloud_env__ : { get_param: cloud_env }
310           template: |
311             #!/bin/bash
312
313             # Create configuration files
314             mkdir /opt/config
315             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
316             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
317             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
318             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
319             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
320             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
321             echo "__install_script_version__" > /opt/config/install_script_version.txt
322             echo "__cloud_env__" > /opt/config/cloud_env.txt
323
324             # Download and run install script
325             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vlb/__install_script_version__/v_dns_install.sh -o /opt/v_dns_install.sh
326             cd /opt
327             chmod +x v_dns_install.sh
328             ./v_dns_install.sh