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