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