514de349b023534e5b5596d2ccd2d6a1f2badb35
[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 (FW and Sink) 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   vsn_private_ip_0:\r
93     type: string\r
94     label: vSink private IP address towards the protected network\r
95     description: Private IP address that is assigned to the vSink to communicate with the vFirewall\r
96   vsn_private_ip_1:\r
97     type: string\r
98     label: vSink private IP address towards the ONAP management network\r
99     description: Private IP address that is assigned to the vSink to communicate with ONAP components\r
100   vfw_name_0:\r
101     type: string\r
102     label: vFirewall name\r
103     description: Name of the vFirewall\r
104   vsn_name_0:\r
105     type: string\r
106     label: vSink name\r
107     description: Name of the vSink\r
108   vnf_id:\r
109     type: string\r
110     label: VNF ID\r
111     description: The VNF ID is provided by ONAP\r
112   vf_module_id:\r
113     type: string\r
114     label: vFirewall module ID\r
115     description: The vFirewall Module ID is provided by ONAP\r
116   dcae_collector_ip:\r
117     type: string\r
118     label: DCAE collector IP address\r
119     description: IP address of the DCAE collector\r
120   dcae_collector_port:\r
121     type: string\r
122     label: DCAE collector port\r
123     description: Port of the DCAE collector\r
124   key_name:\r
125     type: string\r
126     label: Key pair name\r
127     description: Public/Private key pair name\r
128   pub_key:\r
129     type: string\r
130     label: Public key\r
131     description: Public key to be installed on the compute instance\r
132   repo_url_blob:\r
133     type: string\r
134     label: Repository URL\r
135     description: URL of the repository that hosts the demo packages\r
136   repo_url_artifacts:\r
137     type: string\r
138     label: Repository URL\r
139     description: URL of the repository that hosts the demo packages\r
140   install_script_version:\r
141     type: string\r
142     label: Installation script version number\r
143     description: Version number of the scripts that install the vFW demo app\r
144   demo_artifacts_version:\r
145     type: string\r
146     label: Artifacts version used in demo vnfs\r
147     description: Artifacts (jar, tar.gz) version used in demo vnfs\r
148   cloud_env:\r
149     type: string\r
150     label: Cloud environment\r
151     description: Cloud environment (e.g., openstack, rackspace)\r
152 \r
153 #############\r
154 #           #\r
155 # RESOURCES #\r
156 #           #\r
157 #############\r
158 \r
159 resources:\r
160   random-str:\r
161     type: OS::Heat::RandomString\r
162     properties:\r
163       length: 4\r
164 \r
165   my_keypair:\r
166     type: OS::Nova::KeyPair\r
167     properties:\r
168       name:\r
169         str_replace:\r
170           template: base_rand\r
171           params:\r
172             base: { get_param: key_name }\r
173             rand: { get_resource: random-str }\r
174       public_key: { get_param: pub_key }\r
175       save_private_key: false\r
176 \r
177   unprotected_private_network:\r
178     type: OS::Neutron::Net\r
179     properties:\r
180       name: { get_param: unprotected_private_net_id }\r
181 \r
182   protected_private_network:\r
183     type: OS::Neutron::Net\r
184     properties:\r
185       name: { get_param: protected_private_net_id }\r
186 \r
187   unprotected_private_subnet:\r
188     type: OS::Neutron::Subnet\r
189     properties:\r
190       name: { get_param: unprotected_private_subnet_id }\r
191       network_id: { get_resource: unprotected_private_network }\r
192       cidr: { get_param: unprotected_private_net_cidr }\r
193 \r
194   protected_private_subnet:\r
195     type: OS::Neutron::Subnet\r
196     properties:\r
197       name: { get_param: protected_private_subnet_id }\r
198       network_id: { get_resource: protected_private_network }\r
199       cidr: { get_param: protected_private_net_cidr }\r
200 \r
201   # Virtual Firewall instantiation\r
202   vfw_private_0_port:\r
203     type: OS::Neutron::Port\r
204     properties:\r
205       network: { get_resource: unprotected_private_network }\r
206       fixed_ips: [{"subnet": { get_resource: unprotected_private_subnet }, "ip_address": { get_param: vfw_private_ip_0 }}]\r
207 \r
208   vfw_private_1_port:\r
209     type: OS::Neutron::Port\r
210     properties:\r
211       allowed_address_pairs: [{ "ip_address": { get_param: vpg_private_ip_0 }}]\r
212       network: { get_resource: protected_private_network }\r
213       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vfw_private_ip_1 }}]\r
214 \r
215   vfw_private_2_port:\r
216     type: OS::Neutron::Port\r
217     properties:\r
218       network: { get_param: onap_private_net_id }\r
219       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_2 }}]\r
220 \r
221   vfw_0:\r
222     type: OS::Nova::Server\r
223     properties:\r
224       image: { get_param: vfw_image_name }\r
225       flavor: { get_param: vfw_flavor_name }\r
226       name: { get_param: vfw_name_0 }\r
227       key_name: { get_resource: my_keypair }\r
228       networks:\r
229         - network: { get_param: public_net_id }\r
230         - port: { get_resource: vfw_private_0_port }\r
231         - port: { get_resource: vfw_private_1_port }\r
232         - port: { get_resource: vfw_private_2_port }\r
233       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\r
234       user_data_format: RAW\r
235       user_data:\r
236         str_replace:\r
237           params:\r
238             __dcae_collector_ip__ : { get_param: dcae_collector_ip }\r
239             __dcae_collector_port__ : { get_param: dcae_collector_port }\r
240             __repo_url_blob__ : { get_param: repo_url_blob }\r
241             __repo_url_artifacts__ : { get_param: repo_url_artifacts }\r
242             __demo_artifacts_version__ : { get_param: demo_artifacts_version }\r
243             __install_script_version__ : { get_param: install_script_version }\r
244             __vfw_private_ip_0__ : { get_param: vfw_private_ip_0 }\r
245             __vfw_private_ip_1__ : { get_param: vfw_private_ip_1 }\r
246             __vfw_private_ip_2__ : { get_param: vfw_private_ip_2 }\r
247             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }\r
248             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }\r
249             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }\r
250             __cloud_env__ : { get_param: cloud_env }\r
251           template: |\r
252             #!/bin/bash\r
253             \r
254             # Create configuration files\r
255             mkdir /opt/config\r
256             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt\r
257             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt\r
258             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt\r
259             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt\r
260             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt\r
261             echo "__install_script_version__" > /opt/config/install_script_version.txt\r
262             echo "__vfw_private_ip_0__" > /opt/config/vfw_private_ip_0.txt\r
263             echo "__vfw_private_ip_1__" > /opt/config/vfw_private_ip_1.txt\r
264             echo "__vfw_private_ip_2__" > /opt/config/vfw_private_ip_2.txt\r
265             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt\r
266             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt\r
267             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt\r
268             echo "__cloud_env__" > /opt/config/cloud_env.txt\r
269             \r
270             # Download and run install script\r
271             curl -k __repo_url_blob__/org.onap.demo/vnfs/vfw/__install_script_version__/v_firewall_install.sh -o /opt/v_firewall_install.sh\r
272             cd /opt\r
273             chmod +x v_firewall_install.sh\r
274             ./v_firewall_install.sh\r
275 \r
276 \r
277   # Virtual Sink instantiation\r
278   vsn_private_0_port:\r
279     type: OS::Neutron::Port\r
280     properties:\r
281       network: { get_resource: protected_private_network }\r
282       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vsn_private_ip_0 }}]\r
283 \r
284   vsn_private_1_port:\r
285     type: OS::Neutron::Port\r
286     properties:\r
287       network: { get_param: onap_private_net_id }\r
288       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_1 }}]\r
289 \r
290   vsn_0:\r
291     type: OS::Nova::Server\r
292     properties:\r
293       image: { get_param: vfw_image_name }\r
294       flavor: { get_param: vfw_flavor_name }\r
295       name: { get_param: vsn_name_0 }\r
296       key_name: { get_resource: my_keypair }\r
297       networks:\r
298         - network: { get_param: public_net_id }\r
299         - port: { get_resource: vsn_private_0_port }\r
300         - port: { get_resource: vsn_private_1_port }\r
301       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\r
302       user_data_format: RAW\r
303       user_data:\r
304         str_replace:\r
305           params:\r
306             __protected_net_gw__: { get_param: vfw_private_ip_1 }\r
307             __unprotected_net__: { get_param: unprotected_private_net_cidr }\r
308             __repo_url_blob__ : { get_param: repo_url_blob }\r
309             __repo_url_artifacts__ : { get_param: repo_url_artifacts }\r
310             __install_script_version__ : { get_param: install_script_version }\r
311             __vsn_private_ip_0__ : { get_param: vsn_private_ip_0 }\r
312             __vsn_private_ip_1__ : { get_param: vsn_private_ip_1 }\r
313             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }\r
314             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }\r
315             __cloud_env__ : { get_param: cloud_env }\r
316           template: |\r
317             #!/bin/bash\r
318             \r
319             # Create configuration files\r
320             mkdir /opt/config\r
321             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt\r
322             echo "__unprotected_net__" > /opt/config/unprotected_net.txt\r
323             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt\r
324             echo "__install_script_version__" > /opt/config/install_script_version.txt\r
325             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt\r
326             echo "__vsn_private_ip_1__" > /opt/config/vsn_private_ip_1.txt\r
327             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt\r
328             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt\r
329             echo "__cloud_env__" > /opt/config/cloud_env.txt\r
330             \r
331             # Download and run install script\r
332             curl -k __repo_url_blob__/org.onap.demo/vnfs/vfw/__install_script_version__/v_sink_install.sh -o /opt/v_sink_install.sh\r
333             cd /opt\r
334             chmod +x v_sink_install.sh\r
335             ./v_sink_install.sh\r