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