Fix spacing issues in YAML files in heat
[demo.git] / heat / vFWDT / vFWSNK / base_vfw.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
7 # Copyright (c) 2018 Orange Intellectual Property. All rights reserved.
8 #
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #        http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20 #==================LICENSE_END============================================
21 #
22 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 #
24 ##########################################################################
25
26 heat_template_version: 2013-05-23
27
28 description: Heat template that deploys vFirewall Closed Loop demo app (vFW and vSink) for ONAP
29
30 ##############
31 #            #
32 # PARAMETERS #
33 #            #
34 ##############
35
36 parameters:
37   image_name:
38     type: string
39     label: Image name or ID
40     description: Image to be used for compute instance
41   flavor_name:
42     type: string
43     label: Flavor
44     description: Type of instance (flavor) to be used
45   public_net_id:
46     type: string
47     label: Public network name or ID
48     description: Public network that enables remote connection to VNF
49   unprotected_private_net_id:
50     type: string
51     label: Unprotected private network name or ID
52     description: Private network that connects vPacketGenerator with vFirewall
53   unprotected_private_subnet_id:
54     type: string
55     label: Unprotected private subnetwork name or ID
56     description: Private subnetwork of the protected network
57   unprotected_private_net_cidr:
58     type: string
59     label: Unprotected private network CIDR
60     description: The CIDR of the unprotected private network
61   protected_private_net_id:
62     type: string
63     label: Protected private network name or ID
64     description: Private network that connects vFirewall with vSink
65   protected_private_subnet_id:
66     type: string
67     label: Protected private subnetwork name or ID
68     description: Private subnetwork of the unprotected network
69   protected_private_net_cidr:
70     type: string
71     label: Protected private network CIDR
72     description: The CIDR of the protected private network
73   onap_private_net_id:
74     type: string
75     label: ONAP management network name or ID
76     description: Private network that connects ONAP components and the VNF
77   onap_private_subnet_id:
78     type: string
79     label: ONAP management sub-network name or ID
80     description: Private sub-network that connects ONAP components and the VNF
81   onap_private_net_cidr:
82     type: string
83     label: ONAP private network CIDR
84     description: The CIDR of the protected private network
85   ext_private_net_id:
86     type: string
87     label: external private network name or ID
88     description: Private network that enables connection to the public network
89   ext_private_subnet_id:
90     type: string
91     label: External private subnetwork name or ID
92     description: Private subnetwork that enables connection to the public network
93   ext_private_net_cidr:
94     type: string
95     label: External private network CIDR
96     description: The CIDR of the external private network
97   vfw_private_ip_0:
98     type: string
99     label: vFirewall private IP address towards the unprotected network
100     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator
101   vfw_private_ip_1:
102     type: string
103     label: vFirewall private IP address towards the protected network
104     description: Private IP address that is assigned to the vFirewall to communicate with the vSink
105   vfw_private_ip_2:
106     type: string
107     label: vFirewall private IP address towards the ONAP management network
108     description: Private IP address that is assigned to the vFirewall to communicate with ONAP components
109   vfw_private_ip_3:
110     type: string
111     label: vFirewall private IP address towards public
112     description: Private IP address that is assigned to the vFirewall to communicate with internet
113   vpg_private_ip_0:
114     type: string
115     label: vPacketGenerator private IP address towards the unprotected network
116     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall
117   vsn_private_ip_0:
118     type: string
119     label: vSink private IP address towards the protected network
120     description: Private IP address that is assigned to the vSink to communicate with the vFirewall
121   vsn_private_ip_1:
122     type: string
123     label: vSink private IP address towards the ONAP management network
124     description: Private IP address that is assigned to the vSink to communicate with ONAP components
125   vsn_private_ip_2:
126     type: string
127     label: vSink private IP address towards public
128     description: Private IP address that is assigned to the vSink to communicate with internet
129   vfw_name_0:
130     type: string
131     label: vFirewall name
132     description: Name of the vFirewall
133   vsn_name_0:
134     type: string
135     label: vSink name
136     description: Name of the vSink
137   vnf_id:
138     type: string
139     label: VNF ID
140     description: The VNF ID is provided by ONAP
141   vf_module_id:
142     type: string
143     label: vFirewall module ID
144     description: The vFirewall Module ID is provided by ONAP
145   dcae_collector_ip:
146     type: string
147     label: DCAE collector IP address
148     description: IP address of the DCAE collector
149   dcae_collector_port:
150     type: string
151     label: DCAE collector port
152     description: Port of the DCAE collector
153   key_name:
154     type: string
155     label: Key pair name
156     description: Public/Private key pair name
157   pub_key:
158     type: string
159     label: Public key
160     description: Public key to be installed on the compute instance
161   nexus_artifact_repo:
162     type: string
163     description: Root URL for the Nexus repository for Maven artifacts.
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   cloud_env:
173     type: string
174     label: Cloud environment
175     description: Cloud environment (e.g., openstack, rackspace)
176   sec_group:
177     type: string
178     description: ONAP Security Group
179
180 #############
181 #           #
182 # RESOURCES #
183 #           #
184 #############
185
186 resources:
187   random-str:
188     type: OS::Heat::RandomString
189     properties:
190       length: 4
191
192   my_keypair:
193     type: OS::Nova::KeyPair
194     properties:
195       name:
196         str_replace:
197           template: base_rand
198           params:
199             base: { get_param: key_name }
200             rand: { get_resource: random-str }
201       public_key: { get_param: pub_key }
202       save_private_key: false
203
204   # Virtual Firewall instantiation
205   vfw_private_0_port:
206     type: OS::Neutron::Port
207     properties:
208       network: { get_param: unprotected_private_net_id }
209       fixed_ips: [{"subnet": { get_param: unprotected_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_0 }}]
210       security_groups:
211       - { get_param: sec_group }
212
213   vfw_private_1_port:
214     type: OS::Neutron::Port
215     properties:
216       allowed_address_pairs: [{ "ip_address": { get_param: vpg_private_ip_0 }}]
217       network: { get_param: protected_private_net_id }
218       fixed_ips: [{"subnet": { get_param: protected_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_1 }}]
219       security_groups:
220       - { get_param: sec_group }
221
222   vfw_private_2_port:
223     type: OS::Neutron::Port
224     properties:
225       network: { get_param: onap_private_net_id }
226       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_2 }}]
227       security_groups:
228       - { get_param: sec_group }
229
230   vfw_private_3_port:
231     type: OS::Neutron::Port
232     properties:
233       network: { get_param: ext_private_net_id }
234       fixed_ips: [{"subnet": { get_param: ext_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_3 }}]
235       security_groups:
236        - { get_param: sec_group }
237
238   vfw_ext_floatingip:
239     type: OS::Neutron::FloatingIP
240     properties:
241       floating_network: { get_param: public_net_id }
242       port_id: { get_resource: vfw_private_3_port }
243
244   vfw_0:
245     type: OS::Nova::Server
246     properties:
247       image: { get_param: image_name }
248       flavor: { get_param: flavor_name }
249       name: { get_param: vfw_name_0 }
250       key_name: { get_resource: my_keypair }
251       networks:
252         - port: { get_resource: vfw_private_3_port }
253         - port: { get_resource: vfw_private_0_port }
254         - port: { get_resource: vfw_private_1_port }
255         - port: { get_resource: vfw_private_2_port }
256       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
257       user_data_format: RAW
258       user_data:
259         str_replace:
260           params:
261             __dcae_collector_ip__: { get_param: dcae_collector_ip }
262             __dcae_collector_port__: { get_param: dcae_collector_port }
263             __demo_artifacts_version__: { get_param: demo_artifacts_version }
264             __install_script_version__: { get_param: install_script_version }
265             __vfw_private_ip_0__: { get_param: vfw_private_ip_0 }
266             __vfw_private_ip_1__: { get_param: vfw_private_ip_1 }
267             __vfw_private_ip_2__: { get_param: vfw_private_ip_2 }
268             __vfw_private_ip_3__: { get_param: vfw_private_ip_3 }
269             __unprotected_private_net_cidr__: { get_param: unprotected_private_net_cidr }
270             __protected_private_net_cidr__: { get_param: protected_private_net_cidr }
271             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
272             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
273             __cloud_env__: { get_param: cloud_env }
274           template: |
275             #!/bin/bash
276
277             # Create configuration files
278             mkdir /opt/config
279             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
280             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
281             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
282             echo "__install_script_version__" > /opt/config/install_script_version.txt
283             echo "__vfw_private_ip_0__" > /opt/config/vfw_private_ip_0.txt
284             echo "__vfw_private_ip_1__" > /opt/config/vfw_private_ip_1.txt
285             echo "__vfw_private_ip_2__" > /opt/config/vfw_private_ip_2.txt
286             echo "__vfw_private_ip_3__" > /opt/config/vfw_private_ip_3.txt
287             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
288             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
289             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
290             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
291             echo "__cloud_env__" > /opt/config/cloud_env.txt
292
293             # Download and run install script
294             apt-get update
295             apt-get -y install unzip
296             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
297             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
298             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_firewall_install.sh
299             cd /opt
300             chmod +x v_firewall_install.sh
301             ./v_firewall_install.sh
302
303
304   # Virtual Sink instantiation
305   vsn_private_0_port:
306     type: OS::Neutron::Port
307     properties:
308       network: { get_param: protected_private_net_id }
309       fixed_ips: [{"subnet": { get_param: protected_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_0 }}]
310       security_groups:
311       - { get_param: sec_group }
312
313   vsn_private_1_port:
314     type: OS::Neutron::Port
315     properties:
316       network: { get_param: onap_private_net_id }
317       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_1 }}]
318       security_groups:
319       - { get_param: sec_group }
320
321   vsn_private_2_port:
322     type: OS::Neutron::Port
323     properties:
324       network: { get_param: ext_private_net_id }
325       fixed_ips: [{"subnet": { get_param: ext_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_2 }}]
326       security_groups:
327       - { get_param: sec_group }
328
329   vsn_ext_floatingip:
330     type: OS::Neutron::FloatingIP
331     properties:
332       floating_network: { get_param: public_net_id }
333       port_id: { get_resource: vsn_private_2_port }
334
335   vsn_0:
336     type: OS::Nova::Server
337     properties:
338       image: { get_param: image_name }
339       flavor: { get_param: flavor_name }
340       name: { get_param: vsn_name_0 }
341       key_name: { get_resource: my_keypair }
342       networks:
343         - port: { get_resource: vsn_private_2_port }
344         - port: { get_resource: vsn_private_0_port }
345         - port: { get_resource: vsn_private_1_port }
346       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
347       user_data_format: RAW
348       user_data:
349         str_replace:
350           params:
351             __protected_net_gw__: { get_param: vfw_private_ip_1 }
352             __unprotected_net__: { get_param: unprotected_private_net_cidr }
353             __install_script_version__: { get_param: install_script_version }
354             __vsn_private_ip_0__: { get_param: vsn_private_ip_0 }
355             __vsn_private_ip_1__: { get_param: vsn_private_ip_1 }
356             __vsn_private_ip_2__: { get_param: vsn_private_ip_2 }
357             __protected_private_net_cidr__: { get_param: protected_private_net_cidr }
358             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
359             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
360             __cloud_env__: { get_param: cloud_env }
361           template: |
362             #!/bin/bash
363
364             # Create configuration files
365             mkdir /opt/config
366             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt
367             echo "__unprotected_net__" > /opt/config/unprotected_net.txt
368             echo "__install_script_version__" > /opt/config/install_script_version.txt
369             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt
370             echo "__vsn_private_ip_1__" > /opt/config/vsn_private_ip_1.txt
371             echo "__vsn_private_ip_2__" > /opt/config/vsn_private_ip_2.txt
372             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
373             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
374             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
375             echo "__cloud_env__" > /opt/config/cloud_env.txt
376
377             # Download and run install script
378             apt-get update
379             apt-get -y install unzip
380             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
381             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
382             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_sink_install.sh
383             cd /opt
384             chmod +x v_sink_install.sh
385             ./v_sink_install.sh