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