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