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