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