6ef33cca4258747bec1e9a9f656ddc73eb0d93d3
[demo.git] / heat / vFW / base_vfw_openstack.yaml
1 ##########################################################################\r
2 #\r
3 #==================LICENSE_START==========================================\r
4\r
5 #\r
6 # Copyright © 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 demo app for ONAP\r
28 \r
29 ##############\r
30 #            #\r
31 # PARAMETERS #\r
32 #            #\r
33 ##############\r
34 \r
35 parameters:\r
36   vfw_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   vfw_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   protected_private_net_id:\r
53     type: string\r
54     label: Protected private network name or ID\r
55     description: Private network that connects vFirewall with vSink\r
56   onap_private_net_id:\r
57     type: string\r
58     label: ONAP management network name or ID\r
59     description: Private network that connects ONAP components and the VNF\r
60   onap_private_subnet_id:\r
61     type: string\r
62     label: ONAP management sub-network name or ID\r
63     description: Private sub-network that connects ONAP components and the VNF\r
64   unprotected_private_net_cidr:\r
65     type: string\r
66     label: Unprotected private network CIDR\r
67     description: The CIDR of the unprotected private 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_cidr:\r
73     type: string\r
74     label: ONAP private network CIDR\r
75     description: The CIDR of the protected private network\r
76   vfw_private_ip_0:\r
77     type: string\r
78     label: vFirewall private IP address towards the unprotected network\r
79     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator\r
80   vfw_private_ip_1:\r
81     type: string\r
82     label: vFirewall private IP address towards the protected network\r
83     description: Private IP address that is assigned to the vFirewall to communicate with the vSink\r
84   vfw_private_ip_2:\r
85     type: string\r
86     label: vFirewall private IP address towards the ONAP management network\r
87     description: Private IP address that is assigned to the vFirewall to communicate with ONAP components\r
88   vpg_private_ip_0:\r
89     type: string\r
90     label: vPacketGenerator private IP address towards the unprotected network\r
91     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall\r
92   vpg_private_ip_1:\r
93     type: string\r
94     label: vPacketGenerator private IP address towards the ONAP management network\r
95     description: Private IP address that is assigned to the vPacketGenerator to communicate with ONAP components\r
96   vsn_private_ip_0:\r
97     type: string\r
98     label: vSink private IP address towards the protected network\r
99     description: Private IP address that is assigned to the vSink to communicate with the vFirewall\r
100   vsn_private_ip_1:\r
101     type: string\r
102     label: vSink private IP address towards the ONAP management network\r
103     description: Private IP address that is assigned to the vSink to communicate with ONAP components\r
104   vfw_name_0:\r
105     type: string\r
106     label: vFirewall name\r
107     description: Name of the vFirewall\r
108   vpg_name_0:\r
109     type: string\r
110     label: vPacketGenerator name\r
111     description: Name of the vPacketGenerator\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   protected_private_network:\r
191     type: OS::Neutron::Net\r
192     properties:\r
193       name: { get_param: protected_private_net_id }\r
194 \r
195   unprotected_private_subnet:\r
196     type: OS::Neutron::Subnet\r
197     properties:\r
198       network_id: { get_resource: unprotected_private_network }\r
199       cidr: { get_param: unprotected_private_net_cidr }\r
200 \r
201   protected_private_subnet:\r
202     type: OS::Neutron::Subnet\r
203     properties:\r
204       network_id: { get_resource: protected_private_network }\r
205       cidr: { get_param: protected_private_net_cidr }\r
206 \r
207   # Virtual Firewall instantiation\r
208   vfw_private_0_port:\r
209     type: OS::Neutron::Port\r
210     properties:\r
211       security_groups: []\r
212       port_security_enabled: False\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       security_groups: []\r
220       port_security_enabled: False\r
221       network: { get_resource: protected_private_network }\r
222       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vfw_private_ip_1 }}]\r
223 \r
224   vfw_private_2_port:\r
225     type: OS::Neutron::Port\r
226     properties:\r
227       network: { get_param: onap_private_net_id }\r
228       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_2 }}]\r
229 \r
230   vfw_floating_ip:\r
231     type: OS::Neutron::FloatingIP\r
232     properties:\r
233       floating_network_id: { get_param: public_net_id }\r
234       port_id: { get_resource: vfw_private_2_port }\r
235 \r
236   vfw_0:\r
237     type: OS::Nova::Server\r
238     properties:\r
239       image: { get_param: vfw_image_name }\r
240       flavor: { get_param: vfw_flavor_name }\r
241       name: { get_param: vfw_name_0 }\r
242       key_name: { get_resource: my_keypair }\r
243       networks:\r
244         - port: { get_resource: vfw_private_2_port }\r
245         - port: { get_resource: vfw_private_0_port }\r
246         - port: { get_resource: vfw_private_1_port }\r
247       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\r
248       user_data_format: RAW\r
249       user_data:\r
250         str_replace:\r
251           params:\r
252             __dcae_collector_ip__ : { get_param: dcae_collector_ip }\r
253             __dcae_collector_port__ : { get_param: dcae_collector_port }\r
254             __repo_url_blob__ : { get_param: repo_url_blob }\r
255             __repo_url_artifacts__ : { get_param: repo_url_artifacts }\r
256             __demo_artifacts_version__ : { get_param: demo_artifacts_version }\r
257             __install_script_version__ : { get_param: install_script_version }\r
258             __vfw_private_ip_0__ : { get_param: vfw_private_ip_0 }\r
259             __vfw_private_ip_1__ : { get_param: vfw_private_ip_1 }\r
260             __cloud_env__ : { get_param: cloud_env }\r
261           template: |\r
262             #!/bin/bash\r
263             \r
264             # Create configuration files\r
265             mkdir /opt/config\r
266             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt\r
267             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt\r
268             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt\r
269             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt\r
270             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt\r
271             echo "__install_script_version__" > /opt/config/install_script_version.txt\r
272             echo "__vfw_private_ip_0__" > /opt/config/vfw_private_ip_0.txt\r
273             echo "__vfw_private_ip_1__" > /opt/config/vfw_private_ip_1.txt\r
274             echo "__cloud_env__" > /opt/config/cloud_env.txt\r
275             \r
276             # Download and run install script\r
277             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vfw/__install_script_version__/v_firewall_install.sh -o /opt/v_firewall_install.sh\r
278             cd /opt\r
279             chmod +x v_firewall_install.sh\r
280             ./v_firewall_install.sh\r
281 \r
282 \r
283   # Virtual Packet Generator instantiation\r
284   vpg_floating_ip:\r
285     type: OS::Neutron::FloatingIP\r
286     properties:\r
287       floating_network_id: { get_param: public_net_id }\r
288       port_id: { get_resource: vpg_private_1_port }\r
289 \r
290   vpg_private_0_port:\r
291     type: OS::Neutron::Port\r
292     properties:\r
293       network: { get_resource: unprotected_private_network }\r
294       fixed_ips: [{"subnet": { get_resource: unprotected_private_subnet }, "ip_address": { get_param: vpg_private_ip_0 }}]\r
295 \r
296   vpg_private_1_port:\r
297     type: OS::Neutron::Port\r
298     properties:\r
299       network: { get_param: onap_private_net_id }\r
300       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]\r
301 \r
302   vpg_0:\r
303     type: OS::Nova::Server\r
304     properties:\r
305       image: { get_param: vfw_image_name }\r
306       flavor: { get_param: vfw_flavor_name }\r
307       name: { get_param: vpg_name_0 }\r
308       key_name: { get_resource: my_keypair }\r
309       networks:\r
310         - port: { get_resource: vpg_private_1_port }\r
311         - port: { get_resource: vpg_private_0_port }\r
312       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\r
313       user_data_format: RAW\r
314       user_data:\r
315         str_replace:\r
316           params:\r
317             __fw_ipaddr__: { get_param: vfw_private_ip_0 }\r
318             __protected_net_cidr__: { get_param: protected_private_net_cidr }\r
319             __sink_ipaddr__: { get_param: vsn_private_ip_0 }\r
320             __repo_url_blob__ : { get_param: repo_url_blob }\r
321             __repo_url_artifacts__ : { get_param: repo_url_artifacts }\r
322             __demo_artifacts_version__ : { get_param: demo_artifacts_version }\r
323             __install_script_version__ : { get_param: install_script_version }\r
324             __vpg_private_ip_0__ : { get_param: vpg_private_ip_0 }\r
325             __cloud_env__ : { get_param: cloud_env }\r
326           template: |\r
327             #!/bin/bash\r
328             \r
329             # Create configuration files\r
330             mkdir /opt/config\r
331             echo "__fw_ipaddr__" > /opt/config/fw_ipaddr.txt\r
332             echo "__protected_net_cidr__" > /opt/config/protected_net_cidr.txt\r
333             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt\r
334             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt\r
335             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt\r
336             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt\r
337             echo "__install_script_version__" > /opt/config/install_script_version.txt\r
338             echo "__vpg_private_ip_0__" > /opt/config/vpg_private_ip_0.txt\r
339             echo "__cloud_env__" > /opt/config/cloud_env.txt\r
340             \r
341             # Download and run install script\r
342             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vfw/__install_script_version__/v_packetgen_install.sh -o /opt/v_packetgen_install.sh\r
343             cd /opt\r
344             chmod +x v_packetgen_install.sh\r
345             ./v_packetgen_install.sh\r
346 \r
347 \r
348   # Virtual Sink instantiation\r
349   vsn_private_0_port:\r
350     type: OS::Neutron::Port\r
351     properties:\r
352       network: { get_resource: protected_private_network }\r
353       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vsn_private_ip_0 }}]\r
354 \r
355   vsn_private_1_port:\r
356     type: OS::Neutron::Port\r
357     properties:\r
358       network: { get_param: onap_private_net_id }\r
359       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_1 }}]\r
360 \r
361   vsn_floating_ip:\r
362     type: OS::Neutron::FloatingIP\r
363     properties:\r
364       floating_network_id: { get_param: public_net_id }\r
365       port_id: { get_resource: vsn_private_1_port }\r
366 \r
367   vsn_0:\r
368     type: OS::Nova::Server\r
369     properties:\r
370       image: { get_param: vfw_image_name }\r
371       flavor: { get_param: vfw_flavor_name }\r
372       name: { get_param: vsn_name_0 }\r
373       key_name: { get_resource: my_keypair }\r
374       networks:\r
375         - port: { get_resource: vsn_private_1_port }\r
376         - port: { get_resource: vsn_private_0_port }\r
377       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\r
378       user_data_format: RAW\r
379       user_data:\r
380         str_replace:\r
381           params:\r
382             __protected_net_gw__: { get_param: vfw_private_ip_1 }\r
383             __unprotected_net__: { get_param: unprotected_private_net_cidr }\r
384             __repo_url_blob__ : { get_param: repo_url_blob }\r
385             __repo_url_artifacts__ : { get_param: repo_url_artifacts }\r
386             __install_script_version__ : { get_param: install_script_version }\r
387             __vsn_private_ip_0__ : { get_param: vsn_private_ip_0 }\r
388             __cloud_env__ : { get_param: cloud_env }\r
389           template: |\r
390             #!/bin/bash\r
391             \r
392             # Create configuration files\r
393             mkdir /opt/config\r
394             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt\r
395             echo "__unprotected_net__" > /opt/config/unprotected_net.txt\r
396             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt\r
397             echo "__install_script_version__" > /opt/config/install_script_version.txt\r
398             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt\r
399             echo "__cloud_env__" > /opt/config/cloud_env.txt\r
400             \r
401             # Download and run install script\r
402             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vfw/__install_script_version__/v_sink_install.sh -o /opt/v_sink_install.sh\r
403             cd /opt\r
404             chmod +x v_sink_install.sh\r
405             ./v_sink_install.sh