vFW and vFWCL templates for HPA
[demo.git] / heat / vFW_HPA / vFWCL / vFWSNK / 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 Closed Loop demo app (vFW and vSink) for ONAP
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   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: Sink Flavor
47     description: Type of instance (flavor) to be used for vsink VM
48   public_net_id:
49     type: string
50     label: Public network name or ID
51     description: Public network that enables remote connection to VNF
52   unprotected_private_net_id:
53     type: string
54     label: Unprotected private network name or ID
55     description: Private network that connects vPacketGenerator with vFirewall
56   unprotected_private_subnet_id:
57     type: string
58     label: Unprotected private subnetwork name or ID
59     description: Private subnetwork of the protected network
60   unprotected_private_net_cidr:
61     type: string
62     label: Unprotected private network CIDR
63     description: The CIDR of the unprotected private network
64   protected_private_net_id:
65     type: string
66     label: Protected private network name or ID
67     description: Private network that connects vFirewall with vSink
68   protected_private_subnet_id:
69     type: string
70     label: Protected private subnetwork name or ID
71     description: Private subnetwork of the unprotected network
72   protected_private_net_cidr:
73     type: string
74     label: Protected private network CIDR
75     description: The CIDR of the protected private network
76   onap_private_net_id:
77     type: string
78     label: ONAP management network name or ID
79     description: Private network that connects ONAP components and the VNF
80   onap_private_subnet_id:
81     type: string
82     label: ONAP management sub-network name or ID
83     description: Private sub-network that connects ONAP components and the VNF
84   onap_private_net_cidr:
85     type: string
86     label: ONAP private network CIDR
87     description: The CIDR of the protected private network
88   vfw_private_ip_0:
89     type: string
90     label: vFirewall private IP address towards the unprotected network
91     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator
92   vfw_private_ip_1:
93     type: string
94     label: vFirewall private IP address towards the protected network
95     description: Private IP address that is assigned to the vFirewall to communicate with the vSink
96   vfw_private_ip_2:
97     type: string
98     label: vFirewall private IP address towards the ONAP management network
99     description: Private IP address that is assigned to the vFirewall to communicate with ONAP components
100   vpg_private_ip_0:
101     type: string
102     label: vPacketGenerator private IP address towards the unprotected network
103     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall
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   vfw_name_0:
128     type: string
129     label: vFirewall name
130     description: Name of the vFirewall
131   vsn_name_0:
132     type: string
133     label: vSink name
134     description: Name of the vSink
135   vnf_id:
136     type: string
137     label: VNF ID
138     description: The VNF ID is provided by ONAP
139   vf_module_id:
140     type: string
141     label: vFirewall module ID
142     description: The vFirewall Module ID is provided by ONAP
143   dcae_collector_ip:
144     type: string
145     label: DCAE collector IP address
146     description: IP address of the DCAE collector
147   dcae_collector_port:
148     type: string
149     label: DCAE collector port
150     description: Port of the DCAE collector
151   key_name:
152     type: string
153     label: Key pair name
154     description: Public/Private key pair name
155   pub_key:
156     type: string
157     label: Public key
158     description: Public key to be installed on the compute instance
159   install_script_version:
160     type: string
161     label: Installation script version number
162     description: Version number of the scripts that install the vFW demo app
163   demo_artifacts_version:
164     type: string
165     label: Artifacts version used in demo vnfs
166     description: Artifacts (jar, tar.gz) version used in demo vnfs
167   nexus_artifact_repo:
168     type: string
169     description: Root URL for the Nexus repository for Maven artifacts.
170     default: "https://nexus.onap.org"
171   cloud_env:
172     type: string
173     label: Cloud environment
174     description: Cloud environment (e.g., openstack, rackspace)
175   sec_group:
176     type: string
177     description: ONAP Security Group
178
179 #############
180 #           #
181 # RESOURCES #
182 #           #
183 #############
184
185 resources:
186   random-str:
187     type: OS::Heat::RandomString
188     properties:
189       length: 4
190
191   my_keypair:
192     type: OS::Nova::KeyPair
193     properties:
194       name:
195         str_replace:
196           template: base_rand
197           params:
198             base: { get_param: key_name }
199             rand: { get_resource: random-str }
200       public_key: { get_param: pub_key }
201       save_private_key: false
202
203   unprotected_private_network:
204     type: OS::Neutron::Net
205     properties:
206       name: { get_param: unprotected_private_net_id }
207
208   unprotected_private_subnet:
209     type: OS::Neutron::Subnet
210     properties:
211       name: { get_param: unprotected_private_subnet_id }
212       network_id: { get_resource: unprotected_private_network }
213       cidr: { get_param: unprotected_private_net_cidr }
214
215   protected_private_network:
216     type: OS::Neutron::Net
217     properties:
218       name: { get_param: protected_private_net_id }
219
220   protected_private_subnet:
221     type: OS::Neutron::Subnet
222     properties:
223       name: { get_param: protected_private_subnet_id }
224       network_id: { get_resource: protected_private_network }
225       cidr: { get_param: protected_private_net_cidr }
226
227   # Virtual Firewall instantiation
228   vfw_private_0_port:
229     type: OS::Neutron::Port
230     properties:
231       network: { get_resource: unprotected_private_network }
232       binding:vnic_type: { get_param: vfw_private_0_port_vnic_type}
233       fixed_ips: [{"subnet": { get_resource: unprotected_private_subnet }, "ip_address": { get_param: vfw_private_ip_0 }}]
234       security_groups:
235       - { get_param: sec_group }
236
237   vfw_private_1_port:
238     type: OS::Neutron::Port
239     properties:
240       allowed_address_pairs: [{ "ip_address": { get_param: vpg_private_ip_0 }}]
241       network: { get_resource: protected_private_network }
242       binding:vnic_type: { get_param: vfw_private_1_port_vnic_type}
243       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vfw_private_ip_1 }}]
244       security_groups:
245       - { get_param: sec_group }
246
247   vfw_private_2_port:
248     type: OS::Neutron::Port
249     properties:
250       network: { get_param: onap_private_net_id }
251       binding:vnic_type: { get_param: vfw_private_2_port_vnic_type}
252       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_2 }}]
253       security_groups:
254       - { get_param: sec_group }
255
256   vfw_0:
257     type: OS::Nova::Server
258     properties:
259       image: { get_param: image_name }
260       flavor: { get_param: firewall_flavor_name }
261       name: { get_param: vfw_name_0 }
262       key_name: { get_resource: my_keypair }
263       networks:
264         - network: { get_param: public_net_id }
265         - port: { get_resource: vfw_private_0_port }
266         - port: { get_resource: vfw_private_1_port }
267         - port: { get_resource: vfw_private_2_port }
268       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
269       user_data_format: RAW
270       user_data:
271         str_replace:
272           params:
273             __dcae_collector_ip__ : { get_param: dcae_collector_ip }
274             __dcae_collector_port__ : { get_param: dcae_collector_port }
275             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
276             __install_script_version__ : { get_param: install_script_version }
277             __vfw_private_ip_0__ : { get_param: vfw_private_ip_0 }
278             __vfw_private_ip_1__ : { get_param: vfw_private_ip_1 }
279             __vfw_private_ip_2__ : { get_param: vfw_private_ip_2 }
280             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
281             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
282             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
283             __cloud_env__ : { get_param: cloud_env }
284             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
285           template: |
286             #!/bin/bash
287
288             # Create configuration files
289             mkdir /opt/config
290             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
291             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
292             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
293             echo "__install_script_version__" > /opt/config/install_script_version.txt
294             echo "__vfw_private_ip_0__" > /opt/config/vfw_private_ip_0.txt
295             echo "__vfw_private_ip_1__" > /opt/config/vfw_private_ip_1.txt
296             echo "__vfw_private_ip_2__" > /opt/config/vfw_private_ip_2.txt
297             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
298             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
299             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
300             echo "__cloud_env__" > /opt/config/cloud_env.txt
301             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
302
303             # Download and run install script
304             apt-get update
305             apt-get -y install unzip
306             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
307             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
308             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_firewall_install.sh
309             cd /opt
310             chmod +x v_firewall_install.sh
311             ./v_firewall_install.sh
312
313
314   # Virtual Sink instantiation
315   vsn_private_0_port:
316     type: OS::Neutron::Port
317     properties:
318       network: { get_resource: protected_private_network }
319       binding:vnic_type: { get_param: vsn_private_0_port_vnic_type}
320       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vsn_private_ip_0 }}]
321       security_groups:
322       - { get_param: sec_group }
323
324   vsn_private_1_port:
325     type: OS::Neutron::Port
326     properties:
327       network: { get_param: onap_private_net_id }
328       binding:vnic_type: { get_param: vsn_private_1_port_vnic_type}
329       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_1 }}]
330       security_groups:
331       - { get_param: sec_group }
332
333   vsn_0:
334     type: OS::Nova::Server
335     properties:
336       image: { get_param: image_name }
337       flavor: { get_param: sink_flavor_name }
338       name: { get_param: vsn_name_0 }
339       key_name: { get_resource: my_keypair }
340       networks:
341         - network: { get_param: public_net_id }
342         - port: { get_resource: vsn_private_0_port }
343         - port: { get_resource: vsn_private_1_port }
344       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
345       user_data_format: RAW
346       user_data:
347         str_replace:
348           params:
349             __protected_net_gw__: { get_param: vfw_private_ip_1 }
350             __unprotected_net__: { get_param: unprotected_private_net_cidr }
351             __install_script_version__ : { get_param: install_script_version }
352             __vsn_private_ip_0__ : { get_param: vsn_private_ip_0 }
353             __vsn_private_ip_1__ : { get_param: vsn_private_ip_1 }
354             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
355             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
356             __cloud_env__ : { get_param: cloud_env }
357             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
358           template: |
359             #!/bin/bash
360
361             # Create configuration files
362             mkdir /opt/config
363             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt
364             echo "__unprotected_net__" > /opt/config/unprotected_net.txt
365             echo "__install_script_version__" > /opt/config/install_script_version.txt
366             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt
367             echo "__vsn_private_ip_1__" > /opt/config/vsn_private_ip_1.txt
368             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
369             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
370             echo "__cloud_env__" > /opt/config/cloud_env.txt
371             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
372
373             # Download and run install script
374             apt-get update
375             apt-get -y install unzip
376             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
377             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
378             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_sink_install.sh
379             cd /opt
380             chmod +x v_sink_install.sh
381             ./v_sink_install.sh