Remove sdnc parameters from vFW heat template
[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
196 #############
197 #           #
198 # RESOURCES #
199 #           #
200 #############
201
202 resources:
203   random-str:
204     type: OS::Heat::RandomString
205     properties:
206       length: 4
207
208   my_keypair:
209     type: OS::Nova::KeyPair
210     properties:
211       name:
212         str_replace:
213           template: base_rand
214           params:
215             base: { get_param: key_name }
216             rand: { get_resource: random-str }
217       public_key: { get_param: pub_key }
218       save_private_key: false
219
220   unprotected_private_network:
221     type: OS::Neutron::Net
222     properties:
223       name: { get_param: unprotected_private_net_id }
224
225   protected_private_network:
226     type: OS::Neutron::Net
227     properties:
228       name: { get_param: protected_private_net_id }
229
230   unprotected_private_subnet:
231     type: OS::Neutron::Subnet
232     properties:
233       network_id: { get_resource: unprotected_private_network }
234       cidr: { get_param: unprotected_private_net_cidr }
235
236   protected_private_subnet:
237     type: OS::Neutron::Subnet
238     properties:
239       network_id: { get_resource: protected_private_network }
240       cidr: { get_param: protected_private_net_cidr }
241
242   # Virtual Firewall instantiation
243   vfw_private_0_port:
244     type: OS::Neutron::Port
245     properties:
246       network: { get_resource: unprotected_private_network }
247       binding:vnic_type: { get_param: vfw_private_0_port_vnic_type}
248       fixed_ips: [{"subnet": { get_resource: unprotected_private_subnet }, "ip_address": { get_param: vfw_private_ip_0 }}]
249       security_groups:
250       - { get_param: sec_group }
251
252   vfw_private_1_port:
253     type: OS::Neutron::Port
254     properties:
255       allowed_address_pairs: [{ "ip_address": { get_param: vpg_private_ip_0 }}]
256       network: { get_resource: protected_private_network }
257       binding:vnic_type: { get_param: vfw_private_1_port_vnic_type}
258       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vfw_private_ip_1 }}]
259       security_groups:
260       - { get_param: sec_group }
261
262   vfw_private_2_port:
263     type: OS::Neutron::Port
264     properties:
265       network: { get_param: onap_private_net_id }
266       binding:vnic_type: { get_param: vfw_private_2_port_vnic_type}
267       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_2 }}]
268       security_groups:
269       - { get_param: sec_group }
270
271   vfw_0:
272     type: OS::Nova::Server
273     properties:
274       image: { get_param: vfw_image_name }
275       flavor: { get_param: firewall_flavor_name }
276       name: { get_param: vfw_name_0 }
277       key_name: { get_resource: my_keypair }
278       networks:
279         - network: { get_param: public_net_id }
280         - port: { get_resource: vfw_private_0_port }
281         - port: { get_resource: vfw_private_1_port }
282         - port: { get_resource: vfw_private_2_port }
283       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
284       user_data_format: RAW
285       user_data:
286         str_replace:
287           params:
288             __dcae_collector_ip__ : { get_param: dcae_collector_ip }
289             __dcae_collector_port__ : { get_param: dcae_collector_port }
290             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
291             __install_script_version__ : { get_param: install_script_version }
292             __vfw_private_ip_0__ : { get_param: vfw_private_ip_0 }
293             __vfw_private_ip_1__ : { get_param: vfw_private_ip_1 }
294             __vfw_private_ip_2__ : { get_param: vfw_private_ip_2 }
295             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
296             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
297             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
298             __cloud_env__ : { get_param: cloud_env }
299             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
300           template: |
301             #!/bin/bash
302
303             # Create configuration files
304             mkdir /opt/config
305             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
306             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
307             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
308             echo "__install_script_version__" > /opt/config/install_script_version.txt
309             echo "__vfw_private_ip_0__" > /opt/config/vfw_private_ip_0.txt
310             echo "__vfw_private_ip_1__" > /opt/config/vfw_private_ip_1.txt
311             echo "__vfw_private_ip_2__" > /opt/config/vfw_private_ip_2.txt
312             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
313             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
314             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
315             echo "__cloud_env__" > /opt/config/cloud_env.txt
316             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
317
318             # Download and run install script
319             apt-get update
320             apt-get -y install unzip
321             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
322             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
323             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_firewall_install.sh
324             cd /opt
325             chmod +x v_firewall_install.sh
326             ./v_firewall_install.sh
327
328
329   # Virtual Packet Generator instantiation
330   vpg_private_0_port:
331     type: OS::Neutron::Port
332     properties:
333       network: { get_resource: unprotected_private_network }
334       binding:vnic_type: { get_param: vpg_private_0_port_vnic_type}
335       fixed_ips: [{"subnet": { get_resource: unprotected_private_subnet }, "ip_address": { get_param: vpg_private_ip_0 }}]
336       security_groups:
337       - { get_param: sec_group }
338
339   vpg_private_1_port:
340     type: OS::Neutron::Port
341     properties:
342       network: { get_param: onap_private_net_id }
343       binding:vnic_type: { get_param: vpg_private_1_port_vnic_type}
344       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]
345       security_groups:
346       - { get_param: sec_group }
347
348   vpg_0:
349     type: OS::Nova::Server
350     properties:
351       image: { get_param: vfw_image_name }
352       flavor: { get_param: packetgen_flavor_name }
353       name: { get_param: vpg_name_0 }
354       key_name: { get_resource: my_keypair }
355       networks:
356         - network: { get_param: public_net_id }
357         - port: { get_resource: vpg_private_0_port }
358         - port: { get_resource: vpg_private_1_port }
359       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
360       user_data_format: RAW
361       user_data:
362         str_replace:
363           params:
364             __fw_ipaddr__: { get_param: vfw_private_ip_0 }
365             __protected_net_cidr__: { get_param: protected_private_net_cidr }
366             __sink_ipaddr__: { get_param: vsn_private_ip_0 }
367             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
368             __install_script_version__ : { get_param: install_script_version }
369             __vpg_private_ip_0__ : { get_param: vpg_private_ip_0 }
370             __vpg_private_ip_1__ : { get_param: vpg_private_ip_1 }
371             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
372             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
373             __cloud_env__ : { get_param: cloud_env }
374             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
375           template: |
376             #!/bin/bash
377
378             # Create configuration files
379             mkdir /opt/config
380             echo "__fw_ipaddr__" > /opt/config/fw_ipaddr.txt
381             echo "__protected_net_cidr__" > /opt/config/protected_net_cidr.txt
382             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt
383             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
384             echo "__install_script_version__" > /opt/config/install_script_version.txt
385             echo "__vpg_private_ip_0__" > /opt/config/vpg_private_ip_0.txt
386             echo "__vpg_private_ip_1__" > /opt/config/vpg_private_ip_1.txt
387             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
388             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
389             echo "__cloud_env__" > /opt/config/cloud_env.txt
390             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
391
392             # Download and run install script
393             apt-get update
394             apt-get -y install unzip
395             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
396             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
397             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
398             cd /opt
399             chmod +x v_packetgen_install.sh
400             ./v_packetgen_install.sh
401
402
403   # Virtual Sink instantiation
404   vsn_private_0_port:
405     type: OS::Neutron::Port
406     properties:
407       network: { get_resource: protected_private_network }
408       binding:vnic_type: { get_param: vsn_private_0_port_vnic_type}
409       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vsn_private_ip_0 }}]
410       security_groups:
411       - { get_param: sec_group }
412
413   vsn_private_1_port:
414     type: OS::Neutron::Port
415     properties:
416       network: { get_param: onap_private_net_id }
417       binding:vnic_type: { get_param: vsn_private_1_port_vnic_type}
418       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_1 }}]
419       security_groups:
420       - { get_param: sec_group }
421
422   vsn_0:
423     type: OS::Nova::Server
424     properties:
425       image: { get_param: vfw_image_name }
426       flavor: { get_param: sink_flavor_name }
427       name: { get_param: vsn_name_0 }
428       key_name: { get_resource: my_keypair }
429       networks:
430         - network: { get_param: public_net_id }
431         - port: { get_resource: vsn_private_0_port }
432         - port: { get_resource: vsn_private_1_port }
433       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
434       user_data_format: RAW
435       user_data:
436         str_replace:
437           params:
438             __protected_net_gw__: { get_param: vfw_private_ip_1 }
439             __unprotected_net__: { get_param: unprotected_private_net_cidr }
440             __install_script_version__ : { get_param: install_script_version }
441             __vsn_private_ip_0__ : { get_param: vsn_private_ip_0 }
442             __vsn_private_ip_1__ : { get_param: vsn_private_ip_1 }
443             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
444             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
445             __cloud_env__ : { get_param: cloud_env }
446             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
447           template: |
448             #!/bin/bash
449
450             # Create configuration files
451             mkdir /opt/config
452             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt
453             echo "__unprotected_net__" > /opt/config/unprotected_net.txt
454             echo "__install_script_version__" > /opt/config/install_script_version.txt
455             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt
456             echo "__vsn_private_ip_1__" > /opt/config/vsn_private_ip_1.txt
457             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
458             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
459             echo "__cloud_env__" > /opt/config/cloud_env.txt
460             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
461
462             # Download and run install script
463             apt-get update
464             apt-get -y install unzip
465             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
466             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
467             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_sink_install.sh
468             cd /opt
469             chmod +x v_sink_install.sh
470             ./v_sink_install.sh