d30a64fc8320cefa41058f3882df7a20d0453479
[demo.git] / heat / vFWCL_arm64 / vFWSNK / base_vfw.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright (c) 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 that deploys vFirewall Closed Loop demo app (vFW and vSink) for ONAP
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   vfw_image_name:
37     type: string
38     label: Image name or ID
39     description: Image to be used for compute instance
40   vfw_flavor_name:
41     type: string
42     label: Flavor
43     description: Type of instance (flavor) to be used
44   vsn_image_name:
45     type: string
46     label: Image name or ID
47     description: Image to be used for compute instance
48   vsn_flavor_name:
49     type: string
50     label: Flavor
51     description: Type of instance (flavor) to be used
52   public_net_id:
53     type: string
54     label: Public network name or ID
55     description: Public network that enables remote connection to VNF
56   int_unprotected_private_net_id:
57     type: string
58     label: Unprotected private network name or ID
59     description: Private network that connects vPacketGenerator with vFirewall
60   int_unprotected_private_subnet_id:
61     type: string
62     label: Unprotected private subnetwork name or ID
63     description: Private subnetwork of the protected network
64   unprotected_private_net_cidr:
65     type: string
66     label: Unprotected private network CIDR
67     description: The CIDR of the unprotected private network
68   int_protected_private_net_id:
69     type: string
70     label: Protected private network name or ID
71     description: Private network that connects vFirewall with vSink
72   int_protected_private_subnet_id:
73     type: string
74     label: Protected private subnetwork name or ID
75     description: Private subnetwork of the unprotected network
76   protected_private_net_cidr:
77     type: string
78     label: Protected private network CIDR
79     description: The CIDR of the protected private network
80   onap_private_net_id:
81     type: string
82     label: ONAP management network name or ID
83     description: Private network that connects ONAP components and the VNF
84   onap_private_subnet_id:
85     type: string
86     label: ONAP management sub-network name or ID
87     description: Private sub-network that connects ONAP components and the VNF
88   onap_private_net_cidr:
89     type: string
90     label: ONAP private network CIDR
91     description: The CIDR of the protected private network
92   vfw_int_unprotected_private_ip_0:
93     type: string
94     label: vFirewall private IP address towards the unprotected network
95     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator
96   vfw_int_protected_private_ip_0:
97     type: string
98     label: vFirewall private IP address towards the protected network
99     description: Private IP address that is assigned to the vFirewall to communicate with the vSink
100   vfw_onap_private_ip_0:
101     type: string
102     label: vFirewall private IP address towards the ONAP management network
103     description: Private IP address that is assigned to the vFirewall to communicate with ONAP components
104   vfw_int_protected_private_floating_ip:
105     type: string
106     label: vPacketGenerator private IP address towards the unprotected network
107     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall
108   vsn_int_protected_private_ip_0:
109     type: string
110     label: vSink private IP address towards the protected network
111     description: Private IP address that is assigned to the vSink to communicate with the vFirewall
112   vsn_onap_private_ip_0:
113     type: string
114     label: vSink private IP address towards the ONAP management network
115     description: Private IP address that is assigned to the vSink to communicate with ONAP components
116   vfw_name_0:
117     type: string
118     label: vFirewall name
119     description: Name of the vFirewall
120   vsn_name_0:
121     type: string
122     label: vSink name
123     description: Name of the vSink
124   vnf_name:
125     type: string
126     label: VNF NAME
127     description: The VNF NAME is provided by ONAP
128   vnf_id:
129     type: string
130     label: VNF ID
131     description: The VNF ID is provided by ONAP
132   vf_module_id:
133     type: string
134     label: vFirewall module ID
135     description: The vFirewall Module ID is provided by ONAP
136   dcae_collector_ip:
137     type: string
138     label: DCAE collector IP address
139     description: IP address of the DCAE collector
140   dcae_collector_port:
141     type: string
142     label: DCAE collector port
143     description: Port of the DCAE collector
144   key_name:
145     type: string
146     label: Key pair name
147     description: Public/Private key pair name
148   pub_key:
149     type: string
150     label: Public key
151     description: Public key to be installed on the compute instance
152   install_script_version:
153     type: string
154     label: Installation script version number
155     description: Version number of the scripts that install the vFW demo app
156   demo_artifacts_version:
157     type: string
158     label: Artifacts version used in demo vnfs
159     description: Artifacts (jar, tar.gz) version used in demo vnfs
160   nexus_artifact_repo:
161     type: string
162     description: Root URL for the Nexus repository for Maven artifacts.
163   cloud_env:
164     type: string
165     label: Cloud environment
166     description: Cloud environment (e.g., openstack, rackspace)
167   sec_group:
168     type: string
169     description: ONAP Security Group
170
171 #############
172 #           #
173 # RESOURCES #
174 #           #
175 #############
176
177 resources:
178   random-str:
179     type: OS::Heat::RandomString
180     properties:
181       length: 4
182
183   my_keypair:
184     type: OS::Nova::KeyPair
185     properties:
186       name:
187         str_replace:
188           template: vnfname_base_rand
189           params:
190             base: { get_param: key_name }
191             vnfname: { get_param: vnf_name }
192             rand: { get_resource: random-str }
193       public_key: { get_param: pub_key }
194       save_private_key: false
195
196   int_unprotected_private_network:
197     type: OS::Neutron::Net
198     properties:
199       name:
200         str_replace:
201           template: vnfname_netid
202           params:
203             netid: { get_param: int_unprotected_private_net_id }
204             vnfname: { get_param: vnf_name }
205
206   int_unprotected_private_subnet:
207     type: OS::Neutron::Subnet
208     properties:
209       name:
210         str_replace:
211           template: vnfname_subnetid
212           params:
213             subnetid: { get_param: int_unprotected_private_subnet_id }
214             vnfname: { get_param: vnf_name }
215       network: { get_resource: int_unprotected_private_network }
216       cidr: { get_param: unprotected_private_net_cidr }
217
218   int_protected_private_network:
219     type: OS::Neutron::Net
220     properties:
221       name:
222         str_replace:
223           template: vnfname_netid
224           params:
225             netid: { get_param: int_protected_private_net_id }
226             vnfname: { get_param: vnf_name }
227
228   int_protected_private_subnet:
229     type: OS::Neutron::Subnet
230     properties:
231       name:
232         str_replace:
233           template: vnfname_subnetid
234           params:
235             subnetid: { get_param: int_protected_private_subnet_id }
236             vnfname: { get_param: vnf_name }
237       network: { get_resource: int_protected_private_network }
238       cidr: { get_param: protected_private_net_cidr }
239
240   # Virtual Firewall instantiation
241   vfw_0_int_unprotected_private_port_0:
242     type: OS::Neutron::Port
243     properties:
244       network: { get_resource: int_unprotected_private_network }
245       fixed_ips: [{"subnet": { get_resource: int_unprotected_private_subnet }, "ip_address": { get_param: vfw_int_unprotected_private_ip_0 }}]
246       security_groups:
247       - { get_param: sec_group }
248
249   vfw_0_int_protected_private_port_0:
250     type: OS::Neutron::Port
251     properties:
252       allowed_address_pairs: [{ "ip_address": { get_param: vfw_int_protected_private_floating_ip }}]
253       network: { get_resource: int_protected_private_network }
254       fixed_ips: [{"subnet": { get_resource: int_protected_private_subnet }, "ip_address": { get_param: vfw_int_protected_private_ip_0 }}]
255       security_groups:
256       - { get_param: sec_group }
257
258   vfw_0_onap_private_port_0:
259     type: OS::Neutron::Port
260     properties:
261       network: { get_param: onap_private_net_id }
262       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_onap_private_ip_0 }}]
263       security_groups:
264       - { get_param: sec_group }
265
266   vfw_server_0:
267     type: OS::Nova::Server
268     properties:
269       image: { get_param: vfw_image_name }
270       flavor: { get_param: vfw_flavor_name }
271       name: { get_param: vfw_name_0 }
272       key_name: { get_resource: my_keypair }
273       networks:
274         - network: { get_param: public_net_id }
275         - port: { get_resource: vfw_0_int_unprotected_private_port_0 }
276         - port: { get_resource: vfw_0_int_protected_private_port_0 }
277         - port: { get_resource: vfw_0_onap_private_port_0 }
278       metadata:
279         vnf_name: { get_param: vnf_name }
280         vnf_id: { get_param: vnf_id }
281         vf_module_id: { get_param: vf_module_id }
282       user_data_format: RAW
283       user_data:
284         str_replace:
285           params:
286             __dcae_collector_ip__ : { get_param: dcae_collector_ip }
287             __dcae_collector_port__ : { get_param: dcae_collector_port }
288             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
289             __install_script_version__ : { get_param: install_script_version }
290             __vfw_private_ip_0__ : { get_param: vfw_int_unprotected_private_ip_0 }
291             __vfw_private_ip_1__ : { get_param: vfw_int_protected_private_ip_0 }
292             __vfw_private_ip_2__ : { get_param: vfw_onap_private_ip_0 }
293             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
294             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
295             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
296             __cloud_env__ : { get_param: cloud_env }
297             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
298           template: |
299             #!/bin/bash
300
301             # Create configuration files
302             mkdir /opt/config
303             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
304             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
305             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
306             echo "__install_script_version__" > /opt/config/install_script_version.txt
307             echo "__vfw_private_ip_0__" > /opt/config/vfw_private_ip_0.txt
308             echo "__vfw_private_ip_1__" > /opt/config/vfw_private_ip_1.txt
309             echo "__vfw_private_ip_2__" > /opt/config/vfw_private_ip_2.txt
310             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
311             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
312             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
313             echo "__cloud_env__" > /opt/config/cloud_env.txt
314             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
315
316             # Download and run install script
317             apt-get update
318             apt-get -y install unzip
319             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
320             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vfw&a=vfw-scripts&e=zip&v=__install_script_version__" -o /opt/vfw-scripts-__install_script_version__.zip
321             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_firewall_install_arm64.sh
322             cd /opt
323             chmod +x v_firewall_install_arm64.sh
324             ./v_firewall_install_arm64.sh
325
326
327   # Virtual Sink instantiation
328   vsn_0_int_protected_private_port_0:
329     type: OS::Neutron::Port
330     properties:
331       network: { get_resource: int_protected_private_network }
332       fixed_ips: [{"subnet": { get_resource: int_protected_private_subnet }, "ip_address": { get_param: vsn_int_protected_private_ip_0 }}]
333       security_groups:
334       - { get_param: sec_group }
335
336   vsn_0_onap_private_port_0:
337     type: OS::Neutron::Port
338     properties:
339       network: { get_param: onap_private_net_id }
340       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_onap_private_ip_0 }}]
341       security_groups:
342       - { get_param: sec_group }
343
344   vsn_server_0:
345     type: OS::Nova::Server
346     properties:
347       image: { get_param: vsn_image_name }
348       flavor: { get_param: vsn_flavor_name }
349       name: { get_param: vsn_name_0 }
350       key_name: { get_resource: my_keypair }
351       networks:
352         - network: { get_param: public_net_id }
353         - port: { get_resource: vsn_0_int_protected_private_port_0 }
354         - port: { get_resource: vsn_0_onap_private_port_0 }
355       metadata:
356         vnf_name: { get_param: vnf_name }
357         vnf_id: { get_param: vnf_id }
358         vf_module_id: { get_param: vf_module_id }
359       user_data_format: RAW
360       user_data:
361         str_replace:
362           params:
363             __protected_net_gw__: { get_param: vfw_int_protected_private_ip_0 }
364             __unprotected_net__: { get_param: unprotected_private_net_cidr }
365             __install_script_version__ : { get_param: install_script_version }
366             __vsn_private_ip_0__ : { get_param: vsn_int_protected_private_ip_0 }
367             __vsn_private_ip_1__ : { get_param: vsn_onap_private_ip_0 }
368             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
369             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
370             __cloud_env__ : { get_param: cloud_env }
371             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
372           template: |
373             #!/bin/bash
374
375             # Create configuration files
376             mkdir /opt/config
377             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt
378             echo "__unprotected_net__" > /opt/config/unprotected_net.txt
379             echo "__install_script_version__" > /opt/config/install_script_version.txt
380             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt
381             echo "__vsn_private_ip_1__" > /opt/config/vsn_private_ip_1.txt
382             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
383             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
384             echo "__cloud_env__" > /opt/config/cloud_env.txt
385             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
386
387             # Download and run install script
388             apt-get update
389             apt-get -y install unzip
390             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
391             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vfw&a=vfw-scripts&e=zip&v=__install_script_version__" -o /opt/vfw-scripts-__install_script_version__.zip
392             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_sink_install_arm64.sh
393             cd /opt
394             chmod +x v_sink_install_arm64.sh
395             ./v_sink_install_arm64.sh