856841992ec964e3ded69fbbff40727987aa3ac1
[demo.git] / heat / vFW / 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 demo app 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   vpg_image_name:
45     type: string
46     label: Image name or ID
47     description: Image to be used for compute instance
48   vpg_flavor_name:
49     type: string
50     label: Flavor
51     description: Type of instance (flavor) to be used
52   vsn_image_name:
53     type: string
54     label: Image name or ID
55     description: Image to be used for compute instance
56   vsn_flavor_name:
57     type: string
58     label: Flavor
59     description: Type of instance (flavor) to be used
60   public_net_id:
61     type: string
62     label: Public network name or ID
63     description: Public network that enables remote connection to VNF
64   unprotected_private_net_id:
65     type: string
66     label: Unprotected private network name or ID
67     description: Private network that connects vPacketGenerator with vFirewall
68   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   onap_private_net_id:
73     type: string
74     label: ONAP management network name or ID
75     description: Private network that connects ONAP components and the VNF
76   onap_private_subnet_id:
77     type: string
78     label: ONAP management sub-network name or ID
79     description: Private sub-network that connects ONAP components and the VNF
80   unprotected_private_net_cidr:
81     type: string
82     label: Unprotected private network CIDR
83     description: The CIDR of the unprotected private network
84   protected_private_net_cidr:
85     type: string
86     label: Protected private network CIDR
87     description: The CIDR of the protected private network
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: same value as vpg_int_unprotected_private_ip_0  
107     description: IP to inform OpenStack to enable vfw protected private port to allow packets coming from the packet generator
108   vpg_int_unprotected_private_ip_0:
109     type: string
110     label: vPacketGenerator private IP address towards the unprotected network
111     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall
112   vpg_onap_private_ip_0:
113     type: string
114     label: vPacketGenerator private IP address towards the ONAP management network
115     description: Private IP address that is assigned to the vPacketGenerator to communicate with ONAP components
116   vsn_int_protected_private_ip_0:
117     type: string
118     label: vSink private IP address towards the protected network
119     description: Private IP address that is assigned to the vSink to communicate with the vFirewall
120   vsn_onap_private_ip_0:
121     type: string
122     label: vSink private IP address towards the ONAP management network
123     description: Private IP address that is assigned to the vSink to communicate with ONAP components
124   vfw_name_0:
125     type: string
126     label: vFirewall name
127     description: Name of the vFirewall
128   vpg_name_0:
129     type: string
130     label: vPacketGenerator name
131     description: Name of the vPacketGenerator
132   vsn_name_0:
133     type: string
134     label: vSink name
135     description: Name of the vSink
136   vnf_id:
137     type: string
138     label: VNF ID
139     description: The VNF ID is provided by ONAP
140   vnf_name:
141     type: string
142     label: VNF NAME
143     description: The VNF NAME is provided by ONAP
144   vf_module_id:
145     type: string
146     label: vFirewall module ID
147     description: The vFirewall Module ID is provided by ONAP
148   dcae_collector_ip:
149     type: string
150     label: DCAE collector IP address
151     description: IP address of the DCAE collector
152   dcae_collector_port:
153     type: string
154     label: DCAE collector port
155     description: Port of the DCAE collector
156   key_name:
157     type: string
158     label: Key pair name
159     description: Public/Private key pair name
160   pub_key:
161     type: string
162     label: Public key
163     description: Public key to be installed on the compute instance
164   install_script_version:
165     type: string
166     label: Installation script version number
167     description: Version number of the scripts that install the vFW demo app
168   demo_artifacts_version:
169     type: string
170     label: Artifacts version used in demo vnfs
171     description: Artifacts (jar, tar.gz) version used in demo vnfs
172   nexus_artifact_repo:
173     type: string
174     description: Root URL for the Nexus repository for Maven artifacts.
175     # default values prohibited
176     #default: "https://nexus.onap.org"
177   cloud_env:
178     type: string
179     label: Cloud environment
180     description: Cloud environment (e.g., openstack, rackspace)
181   sec_group:
182     type: string
183     description: ONAP Security Group
184   # Unused in template
185   #sdnc_model_name:
186   #  type: string
187   #  description: SDNC Model Name metatada
188   #sdnc_model_version:
189   #  type: string
190   #  description: SDNC Model Version metatada
191   #sdnc_artifact_name:
192   #  type: string
193   #  description: SDNC Artifact Name metatada
194
195 #############
196 #           #
197 # RESOURCES #
198 #           #
199 #############
200
201 resources:
202   random-str:
203     type: OS::Heat::RandomString
204     properties:
205       length: 4
206
207   my_keypair:
208     type: OS::Nova::KeyPair
209     properties:
210       name:
211         str_replace:
212           template: vnfname_base_rand
213           params:
214             base: { get_param: key_name }
215             rand: { get_resource: random-str }
216             vnfname: { get_param: vnf_name }
217       public_key: { get_param: pub_key }
218       save_private_key: false
219
220   # NETWORK_ROLE: unprotected_private
221   # NETWORK_TYPE: internal
222   int_unprotected_private_network:
223     type: OS::Neutron::Net
224     properties:
225       name:
226         str_replace:
227           template: vnfname_netid
228           params:
229             netid: { get_param: unprotected_private_net_id }
230             vnfname: { get_param: vnf_name }
231
232   # NETWORK_ROLE: protected_private
233   # NETWORK_TYPE: internal
234   int_protected_private_network:
235     type: OS::Neutron::Net
236     properties:
237       name:
238         str_replace:
239           template: vnfname_netid
240           params:
241             netid: { get_param: protected_private_net_id }
242             vnfname: { get_param: vnf_name }
243
244   # NETWORK_ROLE: unprotected_private
245   # NETWORK_TYPE: internal
246   int_unprotected_private_subnet:
247     type: OS::Neutron::Subnet
248     properties:
249       network: { get_resource: int_unprotected_private_network }
250       cidr: { get_param: unprotected_private_net_cidr }
251
252   # NETWORK_ROLE: protected_private
253   # NETWORK_TYPE: internal
254   int_protected_private_subnet:
255     type: OS::Neutron::Subnet
256     properties:
257       network: { get_resource: int_protected_private_network }
258       cidr: { get_param: protected_private_net_cidr }
259
260   ### Virtual Firewall instantiation ###
261
262   # VM_TYPE: vfw
263   # NETWORK_ROLE: protected_private
264   # NETWORK_TYPE: internal
265   vfw_0_int_unprotected_private_port_0:
266     type: OS::Neutron::Port
267     properties:
268       network: { get_resource: int_unprotected_private_network }
269       fixed_ips: [{"subnet": { get_resource: int_unprotected_private_subnet }, "ip_address": { get_param: vfw_int_unprotected_private_ip_0 }}]
270       security_groups:
271       - { get_param: sec_group }
272
273   # VM_TYPE: vfw
274   # NETWORK_ROLE: protected_private
275   # NETWORK_TYPE: internal
276   vfw_0_int_protected_private_port_0:
277     type: OS::Neutron::Port
278     properties:
279       allowed_address_pairs: [{ "ip_address": { get_param: vfw_int_protected_private_floating_ip }}]
280       network: { get_resource: int_protected_private_network }
281       fixed_ips: [{"subnet": { get_resource: int_protected_private_subnet }, "ip_address": { get_param: vfw_int_protected_private_ip_0 }}]
282       security_groups:
283       - { get_param: sec_group }
284
285   # VM_TYPE: vfw
286   # NETWORK_ROLE: onap_private
287   # NETWORK_TYPE: external
288   vfw_0_onap_private_port_0:
289     type: OS::Neutron::Port
290     properties:
291       network: { get_param: onap_private_net_id }
292       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_onap_private_ip_0 }}]
293       security_groups:
294       - { get_param: sec_group }
295
296   # VM_TYPE: vfw
297   vfw_server_0:
298     type: OS::Nova::Server
299     properties:
300       image: { get_param: vfw_image_name }
301       flavor: { get_param: vfw_flavor_name }
302       name: { get_param: vfw_name_0 }
303       key_name: { get_resource: my_keypair }
304       networks:
305         - network: { get_param: public_net_id }
306         - port: { get_resource: vfw_0_int_unprotected_private_port_0 }
307         - port: { get_resource: vfw_0_int_protected_private_port_0 }
308         - port: { get_resource: vfw_0_onap_private_port_0 }
309       metadata:
310         vnf_id: { get_param: vnf_id }
311         vf_module_id: { get_param: vf_module_id }
312         vnf_name: { get_param: vnf_name }
313       user_data_format: RAW
314       user_data:
315         str_replace:
316           params:
317             __dcae_collector_ip__ : { get_param: dcae_collector_ip }
318             __dcae_collector_port__ : { get_param: dcae_collector_port }
319             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
320             __install_script_version__ : { get_param: install_script_version }
321             __vfw_private_ip_0__ : { get_param: vfw_int_unprotected_private_ip_0 }
322             __vfw_private_ip_1__ : { get_param: vfw_int_protected_private_ip_0 }
323             __vfw_private_ip_2__ : { get_param: vfw_onap_private_ip_0 }
324             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
325             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
326             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
327             __cloud_env__ : { get_param: cloud_env }
328             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
329           template: |
330             #!/bin/bash
331
332             # Create configuration files
333             mkdir /opt/config
334             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
335             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
336             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
337             echo "__install_script_version__" > /opt/config/install_script_version.txt
338             echo "__vfw_private_ip_0__" > /opt/config/vfw_private_ip_0.txt
339             echo "__vfw_private_ip_1__" > /opt/config/vfw_private_ip_1.txt
340             echo "__vfw_private_ip_2__" > /opt/config/vfw_private_ip_2.txt
341             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
342             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
343             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
344             echo "__cloud_env__" > /opt/config/cloud_env.txt
345             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
346
347             # Download and run install script
348             apt-get update
349             apt-get -y install unzip
350             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
351             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
352             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_firewall_install.sh
353             cd /opt
354             chmod +x v_firewall_install.sh
355             ./v_firewall_install.sh
356
357
358   ### Virtual Packet Generator instantiation ###
359
360   vpg_0_int_unprotected_private_port_0:
361     type: OS::Neutron::Port
362     properties:
363       network: { get_resource: int_unprotected_private_network }
364       fixed_ips: [{"subnet": { get_resource: int_unprotected_private_subnet }, "ip_address": { get_param: vpg_int_unprotected_private_ip_0 }}]
365       security_groups:
366       - { get_param: sec_group }
367
368   vpg_0_onap_private_port_0:
369     type: OS::Neutron::Port
370     properties:
371       network: { get_param: onap_private_net_id }
372       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_onap_private_ip_0 }}]
373       security_groups:
374       - { get_param: sec_group }
375
376   vpg_server_0:
377     type: OS::Nova::Server
378     properties:
379       image: { get_param: vpg_image_name }
380       flavor: { get_param: vpg_flavor_name }
381       name: { get_param: vpg_name_0 }
382       key_name: { get_resource: my_keypair }
383       networks:
384         - network: { get_param: public_net_id }
385         - port: { get_resource: vpg_0_int_unprotected_private_port_0 }
386         - port: { get_resource: vpg_0_onap_private_port_0 }
387       metadata:
388         vnf_id: { get_param: vnf_id }
389         vf_module_id: { get_param: vf_module_id }
390         vnf_name: { get_param: vnf_name }
391       user_data_format: RAW
392       user_data:
393         str_replace:
394           params:
395             __fw_ipaddr__: { get_param: vfw_int_unprotected_private_ip_0 }
396             __protected_net_cidr__: { get_param: protected_private_net_cidr }
397             __sink_ipaddr__: { get_param: vsn_int_protected_private_ip_0 }
398             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
399             __install_script_version__ : { get_param: install_script_version }
400             __vpg_private_ip_0__ : { get_param: vpg_int_unprotected_private_ip_0 }
401             __vpg_private_ip_1__ : { get_param: vpg_onap_private_ip_0 }
402             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
403             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
404             __cloud_env__ : { get_param: cloud_env }
405             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
406           template: |
407             #!/bin/bash
408
409             # Create configuration files
410             mkdir /opt/config
411             echo "__fw_ipaddr__" > /opt/config/fw_ipaddr.txt
412             echo "__protected_net_cidr__" > /opt/config/protected_net_cidr.txt
413             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt
414             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
415             echo "__install_script_version__" > /opt/config/install_script_version.txt
416             echo "__vpg_private_ip_0__" > /opt/config/vpg_private_ip_0.txt
417             echo "__vpg_private_ip_1__" > /opt/config/vpg_private_ip_1.txt
418             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
419             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
420             echo "__cloud_env__" > /opt/config/cloud_env.txt
421             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
422
423             # Download and run install script
424             apt-get update
425             apt-get -y install unzip
426             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
427             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
428             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
429             cd /opt
430             chmod +x v_packetgen_install.sh
431             ./v_packetgen_install.sh
432
433
434   ### Virtual Sink instantiation ###
435
436   vsn_0_int_protected_private_port_0:
437     type: OS::Neutron::Port
438     properties:
439       network: { get_resource: int_protected_private_network }
440       fixed_ips: [{"subnet": { get_resource: int_protected_private_subnet }, "ip_address": { get_param: vsn_int_protected_private_ip_0 }}]
441       security_groups:
442       - { get_param: sec_group }
443
444   vsn_0_onap_private_port_0:
445     type: OS::Neutron::Port
446     properties:
447       network: { get_param: onap_private_net_id }
448       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_onap_private_ip_0 }}]
449       security_groups:
450       - { get_param: sec_group }
451
452   vsn_server_0:
453     type: OS::Nova::Server
454     properties:
455       image: { get_param: vsn_image_name }
456       flavor: { get_param: vsn_flavor_name }
457       name: { get_param: vsn_name_0 }
458       key_name: { get_resource: my_keypair }
459       networks:
460         - network: { get_param: public_net_id }
461         - port: { get_resource: vsn_0_int_protected_private_port_0 }
462         - port: { get_resource: vsn_0_onap_private_port_0 }
463       metadata:
464         vnf_id: { get_param: vnf_id }
465         vf_module_id: { get_param: vf_module_id }
466         vnf_name: { get_param: vnf_name }
467       user_data_format: RAW
468       user_data:
469         str_replace:
470           params:
471             __protected_net_gw__: { get_param: vfw_int_protected_private_ip_0 }
472             __unprotected_net__: { get_param: unprotected_private_net_cidr }
473             __install_script_version__ : { get_param: install_script_version }
474             __vsn_private_ip_0__ : { get_param: vsn_int_protected_private_ip_0 }
475             __vsn_private_ip_1__ : { get_param: vsn_onap_private_ip_0 }
476             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
477             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
478             __cloud_env__ : { get_param: cloud_env }
479             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
480           template: |
481             #!/bin/bash
482
483             # Create configuration files
484             mkdir /opt/config
485             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt
486             echo "__unprotected_net__" > /opt/config/unprotected_net.txt
487             echo "__install_script_version__" > /opt/config/install_script_version.txt
488             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt
489             echo "__vsn_private_ip_1__" > /opt/config/vsn_private_ip_1.txt
490             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
491             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
492             echo "__cloud_env__" > /opt/config/cloud_env.txt
493             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
494
495             # Download and run install script
496             apt-get update
497             apt-get -y install unzip
498             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
499             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
500             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_sink_install.sh
501             cd /opt
502             chmod +x v_sink_install.sh
503             ./v_sink_install.sh