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