672c44c95eb588d31dff9b2a9de5bb2cbade1186
[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 #      network_id: { get_param: onap_private_net_id }
197 #      cidr: { get_param: vlb_private_net_cidr_for_floating }
198       
199 #  router_interface:
200 #    type: OS::Neutron::RouterInterface
201 #    properties:
202 #      router_id: d6f7a5c3-8bae-4171-aebd-c53a8c85b2ee
203 #      subnet_id: { get_resource: vlb_private_subnet_for_floating }
204 #      subnet_id: { get_param: onap_private_subnet_id }
205
206   vlb_private_0_port:
207     type: OS::Neutron::Port
208     properties:
209       network: { get_resource: vlb_private_network }
210       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vlb_private_ip_0 }}]
211
212   vlb_private_1_port:
213     type: OS::Neutron::Port
214     properties:
215       network: { get_param: onap_private_net_id }
216       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_private_ip_1 }}]
217       
218 #  vlb_private_2_port_for_floating:
219 #    type: OS::Neutron::Port
220 #    properties:
221 #      network: { get_param: onap_private_net_id }
222 #      fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_private_ip_2_for_floating }}]
223   
224 #  vlb_floating_ip:
225 #    type: OS::Neutron::FloatingIP
226 #    properties:
227 #      floating_network_id: { get_param: public_net_id }
228 #      port_id: { get_resource: vlb_private_1_port }
229 #      port_id: { get_resource: vlb_private_2_port_for_floating }
230
231   vlb_0:
232     type: OS::Nova::Server
233     properties:
234       image: { get_param: vlb_image_name }
235       flavor: { get_param: vlb_flavor_name }
236       name: { get_param: vlb_name_0 }
237       key_name: { get_resource: my_keypair }
238       networks:
239 #        - port: { get_resource: vlb_private_2_port_for_floating }
240 #        - port: { get_resource: vlb_private_0_port }
241 #        - port: { get_resource: vlb_private_1_port }
242         - network: { get_param: public_net_id }
243         - port: { get_resource: vlb_private_0_port }
244         - port: { get_resource: vlb_private_1_port }
245       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
246       user_data_format: RAW
247       user_data:
248         str_replace:
249           params:
250             __dcae_collector_ip__: { get_param: dcae_collector_ip }
251             __dcae_collector_port__: { get_param: dcae_collector_port }
252             #__local_public_ipaddr__: { get_attr: [vlb_floating_ip, floating_ip_address] }
253             __local_private_ipaddr__: { get_param: vlb_private_ip_0 }
254             __oam_private_ipaddr__: { get_param: vlb_private_ip_1 }
255             __repo_url_blob__ : { get_param: repo_url_blob }
256             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
257             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
258             __install_script_version__ : { get_param: install_script_version }
259             __cloud_env__ : { get_param: cloud_env }
260           template: |
261             #!/bin/bash
262
263             # Create configuration files
264             mkdir /opt/config
265             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
266             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
267             #echo "__local_public_ipaddr__" > /opt/config/local_public_ipaddr.txt
268             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
269             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
270             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
271             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
272             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
273             echo "__install_script_version__" > /opt/config/install_script_version.txt
274             echo "__cloud_env__" > /opt/config/cloud_env.txt
275
276             # Download and run install script
277             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vlb/__install_script_version__/v_lb_install.sh -o /opt/v_lb_install.sh
278             cd /opt
279             chmod +x v_lb_install.sh
280             ./v_lb_install.sh
281
282
283   vdns_private_0_port:
284     type: OS::Neutron::Port
285     properties:
286       network: { get_resource: vlb_private_network }
287       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vdns_private_ip_0 }}]
288
289   vdns_private_1_port:
290     type: OS::Neutron::Port
291     properties:
292       network: { get_param: onap_private_net_id }
293       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]
294
295   vdns_floating_ip:
296     type: OS::Neutron::FloatingIP
297     properties:
298       floating_network_id: { get_param: public_net_id }
299       port_id: { get_resource: vdns_private_1_port }
300
301   vdns_0:
302     type: OS::Nova::Server
303     properties:
304       image: { get_param: vlb_image_name }
305       flavor: { get_param: vlb_flavor_name }
306       name: { get_param: vdns_name_0 }
307       key_name: { get_resource: my_keypair }
308       networks:
309         - network: { get_param: public_net_id }
310         - port: { get_resource: vdns_private_0_port }
311         - port: { get_resource: vdns_private_1_port }
312       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
313       user_data_format: RAW
314       user_data:
315         str_replace:
316           params:
317             __lb_oam_int__ : { get_param: vlb_private_ip_1 }
318             __lb_private_ipaddr__: { get_param: vlb_private_ip_0 }
319             __local_private_ipaddr__: { get_param: vdns_private_ip_0 }
320             __repo_url_blob__ : { get_param: repo_url_blob }
321             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
322             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
323             __install_script_version__ : { get_param: install_script_version }
324             __cloud_env__ : { get_param: cloud_env }
325           template: |
326             #!/bin/bash
327
328             # Create configuration files
329             mkdir /opt/config
330             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
331             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
332             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
333             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
334             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
335             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
336             echo "__install_script_version__" > /opt/config/install_script_version.txt
337             echo "__cloud_env__" > /opt/config/cloud_env.txt
338
339             # Download and run install script
340             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vlb/__install_script_version__/v_dns_install.sh -o /opt/v_dns_install.sh
341             cd /opt
342             chmod +x v_dns_install.sh
343             ./v_dns_install.sh