Add URL to Nexus repo in Heat templates
[demo.git] / heat / vCPE / infra / base_vcpe_infra.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4
5 #
6 # Copyright 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 to deploy vCPE Infrastructue emlements (vAAA, vDHCP, vDNS_DHCP, webServer)
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   vcpe_image_name:
37     type: string
38     label: Image name or ID
39     description: Image to be used for compute instance
40   vcpe_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   onap_private_net_id:
49     type: string
50     label: ONAP management network name or ID
51     description: Private network that connects ONAP components and the VNF
52   onap_private_subnet_id:
53     type: string
54     label: ONAP management sub-network name or ID
55     description: Private sub-network that connects ONAP components and the VNF
56   onap_private_net_cidr:
57     type: string
58     label: ONAP private network CIDR
59     description: The CIDR of the protected private network
60   cpe_signal_net_id:
61     type: string
62     label: vAAA private network name or ID
63     description: Private network that connects vAAA with vDNSs
64   cpe_signal_subnet_id:
65     type: string
66     label: CPE Signal subnet
67     description: CPE Signal subnet
68   cpe_signal_net_cidr:
69     type: string
70     label: vAAA private network CIDR
71     description: The CIDR of the vAAA private network
72   cpe_public_net_id:
73     type: string
74     label: vCPE Public network (emulates internet) name or ID
75     description: Private network that connects vGW to emulated internet
76   cpe_public_subnet_id:
77     type: string
78     label: CPE Public subnet
79     description: CPE Public subnet
80   cpe_public_net_cidr:
81     type: string
82     label: vCPE public network CIDR
83     description: The CIDR of the vCPE public
84   vaaa_private_ip_0:
85     type: string
86     label: vAAA private IP address towards the CPE_SIGNAL private network
87     description: Private IP address that is assigned to the vAAA to communicate with the vCPE components
88   vaaa_private_ip_1:
89     type: string
90     label: vAAA private IP address towards the ONAP management network
91     description: Private IP address that is assigned to the vAAA to communicate with ONAP components
92   vdns_private_ip_0:
93     type: string
94     label: vDNS private IP address towards the CPE_PUBLIC private network
95     description: Private IP address that is assigned to the vDNS to communicate with the vCPE components
96   vdns_private_ip_1:
97     type: string
98     label: vDNS private IP address towards the ONAP management network
99     description: Private IP address that is assigned to the vDNS to communicate with ONAP components
100   vdhcp_private_ip_0:
101     type: string
102     label: vDHCP  private IP address towards the CPE_SIGNAL private network
103     description: Private IP address that is assigned to the vDHCP to communicate with the vCPE components
104   vdhcp_private_ip_1:
105     type: string
106     label: vDNS private IP address towards the ONAP management network
107     description: Private IP address that is assigned to the vDHCP to communicate with ONAP components
108   vweb_private_ip_0:
109     type: string
110     label: vWEB private IP address towards the CPE_PUBLIC private network
111     description: Private IP address that is assigned to the vWEB to communicate with the vGWs 
112   vweb_private_ip_1:
113     type: string
114     label: vWEB private IP address towards the ONAP management network
115     description: Private IP address that is assigned to the vWEB to communicate with ONAP components
116   vaaa_name_0:
117     type: string
118     label: vAAA name
119     description: Name of the vAAA
120   vdns_name_0:
121     type: string
122     label: vDNS name
123     description: Name of the vDNS
124   vdhcp_name_0:
125     type: string
126     label: vDHCP name
127     description: Name of the vDHCP
128   vweb_name_0:
129     type: string
130     label: vWEB name
131     description: Name of the vWEB 
132   vnf_id:
133     type: string
134     label: VNF ID
135     description: The VNF ID is provided by ONAP
136   vf_module_id:
137     type: string
138     label: vFirewall module ID
139     description: The vAAA Module ID is provided by ONAP
140   dcae_collector_ip:
141     type: string
142     label: DCAE collector IP address
143     description: IP address of the DCAE collector
144   dcae_collector_port:
145     type: string
146     label: DCAE collector port
147     description: Port of the DCAE collector
148   mr_ip_addr:
149     type: string
150     label: Message Router IP address
151     description: IP address of the Message Router that for vDHCP configuration 
152   mr_ip_port:
153     type: string
154     label: Message Router Port 
155     description: IP port of the Message Router that for vDHCP configuration 
156   key_name:
157     type: string
158     label: Key pair name
159     description: Public/Private key pair name
160   pub_key:
161     type: string
162     label: Public key
163     description: Public key to be installed on the compute instance
164   repo_url_artifacts:
165     type: string
166     label: Repository URL
167     description: URL of the repository that hosts the demo packages
168   install_script_version:
169     type: string
170     label: Installation script version number
171     description: Version number of the scripts that install the vFW demo app
172   demo_artifacts_version:
173     type: string
174     label: Artifacts version used in demo vnfs
175     description: Artifacts (jar, tar.gz) version used in demo vnfs
176   nexus_artifact_repo:
177     type: string
178     description: Root URL for the Nexus repository for Maven artifacts.
179     default: "https://nexus.onap.org"
180   cloud_env:
181     type: string
182     label: Cloud environment
183     description: Cloud environment (e.g., openstack, rackspace)
184
185 #############
186 #           #
187 # RESOURCES #
188 #           #
189 #############
190
191 resources:
192
193   random-str:
194     type: OS::Heat::RandomString
195     properties:
196       length: 4
197
198   my_keypair:
199     type: OS::Nova::KeyPair
200     properties:
201       name:
202         str_replace:
203           template: base_rand
204           params:
205             base: { get_param: key_name }
206             rand: { get_resource: random-str }
207       public_key: { get_param: pub_key }
208       save_private_key: false
209
210
211   # Virtual AAA server Instantiation
212   vaaa_private_0_port:
213     type: OS::Neutron::Port
214     properties:
215       network: { get_param: cpe_signal_net_id }
216       fixed_ips: [{"subnet": { get_param: cpe_signal_subnet_id }, "ip_address": { get_param: vaaa_private_ip_0 }}]
217
218   vaaa_private_1_port:
219     type: OS::Neutron::Port
220     properties:
221       network: { get_param: onap_private_net_id }
222       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vaaa_private_ip_1 }}]
223
224   vaaa_0:
225     type: OS::Nova::Server
226     properties:
227       image: { get_param: vcpe_image_name }
228       flavor: { get_param: vcpe_flavor_name }
229       name: { get_param: vaaa_name_0 }
230       key_name: { get_resource: my_keypair }
231       networks:
232         - network: { get_param: public_net_id }
233         - port: { get_resource: vaaa_private_0_port }
234         - port: { get_resource: vaaa_private_1_port }
235       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
236       user_data_format: RAW
237       user_data:
238         str_replace:
239           params:
240             __dcae_collector_ip__: { get_param: dcae_collector_ip }
241             __dcae_collector_port__: { get_param: dcae_collector_port }
242             __cpe_signal_net_ipaddr__: { get_param: vaaa_private_ip_0 }
243             __oam_ipaddr__: { get_param: vaaa_private_ip_1 }
244             __oam_cidr__: { get_param: onap_private_net_cidr }
245             __cpe_signal_net_cidr__: { get_param: cpe_signal_net_cidr }
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             __cloud_env__ : { get_param: cloud_env }
250             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
251           template: |
252             #!/bin/bash
253
254             # Create configuration files
255             mkdir /opt/config
256             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
257             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
258             echo "__cpe_signal_net_ipaddr__" > /opt/config/cpe_signal_net_ipaddr.txt
259             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
260             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
261             echo "__cpe_signal_net_cidr__" > /opt/config/cpe_signal_net_cidr.txt
262             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
263             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
264             echo "__install_script_version__" > /opt/config/install_script_version.txt
265             echo "__cloud_env__" > /opt/config/cloud_env.txt
266             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
267
268             # Download and run install script
269             apt-get -y install unzip
270             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
271             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vcpe&a=vcpe-scripts&e=zip&v=__install_script_version__" -o /opt/vcpe-scripts-__install_script_version__.zip
272             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_aaa_install.sh
273             cd /opt
274             chmod +x v_aaa_install.sh
275             ./v_aaa_install.sh
276
277
278   # Virtual DNS Instantiation
279   vdns_private_0_port:
280     type: OS::Neutron::Port
281     properties:
282       network: { get_param: cpe_public_net_id }
283       fixed_ips: [{"subnet": { get_param: cpe_public_subnet_id }, "ip_address": { get_param: vdns_private_ip_0 }}]
284
285   vdns_private_1_port:
286     type: OS::Neutron::Port
287     properties:
288       network: { get_param: onap_private_net_id }
289       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]
290
291   vdns_0:
292     type: OS::Nova::Server
293     properties:
294       image: { get_param: vcpe_image_name }
295       flavor: { get_param: vcpe_flavor_name }
296       name: { get_param: vdns_name_0 }
297       key_name: { get_resource: my_keypair }
298       networks:
299         - network: { get_param: public_net_id }
300         - port: { get_resource: vdns_private_0_port }
301         - port: { get_resource: vdns_private_1_port }
302       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
303       user_data_format: RAW
304       user_data:
305         str_replace:
306           params:
307             __oam_ipaddr__ : { get_param: vdns_private_ip_1 }
308             __cpe_public_net_ipaddr__: { get_param: vdns_private_ip_0 }
309             __oam_cidr__: { get_param: onap_private_net_cidr }
310             __cpe_public_net_cidr__: { get_param: cpe_public_net_cidr }
311             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
312             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
313             __install_script_version__ : { get_param: install_script_version }
314             __cloud_env__ : { get_param: cloud_env }
315             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
316           template: |
317             #!/bin/bash
318
319             # Create configuration files
320             mkdir /opt/config
321             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
322             echo "__cpe_public_net_ipaddr__" > /opt/config/cpe_public_net_ipaddr.txt
323             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
324             echo "__cpe_public_net_cidr__" > /opt/config/cpe_public_net_cidr.txt
325             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
326             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
327             echo "__install_script_version__" > /opt/config/install_script_version.txt
328             echo "__cloud_env__" > /opt/config/cloud_env.txt
329             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
330
331             # Download and run install script
332             apt-get -y install unzip
333             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
334             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vcpe&a=vcpe-scripts&e=zip&v=__install_script_version__" -o /opt/vcpe-scripts-__install_script_version__.zip
335             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_dns_install.sh
336             cd /opt
337             chmod +x v_dns_install.sh
338             ./v_dns_install.sh
339
340
341   # Virtual DHCP Instantiation
342   vdhcp_private_0_port:
343     type: OS::Neutron::Port
344     properties:
345       network: { get_param: cpe_signal_net_id }
346       fixed_ips: [{"subnet": { get_param: cpe_signal_subnet_id }, "ip_address": { get_param: vdhcp_private_ip_0 }}]
347
348   vdhcp_private_1_port:
349     type: OS::Neutron::Port
350     properties:
351       network: { get_param: onap_private_net_id }
352       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdhcp_private_ip_1 }}]
353
354   vdhcp_0:
355     type: OS::Nova::Server
356     properties:
357       image: { get_param: vcpe_image_name }
358       flavor: { get_param: vcpe_flavor_name }
359       name: { get_param: vdhcp_name_0 }
360       key_name: { get_resource: my_keypair }
361       networks:
362         - network: { get_param: public_net_id }
363         - port: { get_resource: vdhcp_private_0_port }
364         - port: { get_resource: vdhcp_private_1_port }
365       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
366       user_data_format: RAW
367       user_data:
368         str_replace:
369           params:
370             __oam_ipaddr__ : { get_param: vdhcp_private_ip_1 }
371             __cpe_signal_ipaddr__ : { get_param: vdhcp_private_ip_0 }
372             __oam_cidr__ : { get_param: onap_private_net_cidr }
373             __cpe_signal_net_cidr__ : { get_param: cpe_signal_net_cidr }
374             __mr_ip_addr__ : { get_param: mr_ip_addr }
375             __mr_ip_port__ : { get_param: mr_ip_port }
376             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
377             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
378             __install_script_version__ : { get_param: install_script_version }
379             __cloud_env__ : { get_param: cloud_env }
380             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
381           template: |
382             #!/bin/bash
383
384             # Create configuration files
385             mkdir /opt/config
386             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
387             echo "__cpe_signal_ipaddr__" > /opt/config/cpe_signal_ipaddr.txt
388             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
389             echo "__cpe_signal_net_cidr__" > /opt/config/cpe_signal_net_cidr.txt
390             echo "__mr_ip_addr__" > /opt/config/mr_ip_addr.txt
391             echo "__mr_ip_port__" > /opt/config/mr_ip_port.txt
392             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
393             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
394             echo "__install_script_version__" > /opt/config/install_script_version.txt
395             echo "__cloud_env__" > /opt/config/cloud_env.txt
396             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
397
398             # Download and run install script
399             apt-get -y install unzip
400             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
401             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vcpe&a=vcpe-scripts&e=zip&v=__install_script_version__" -o /opt/vcpe-scripts-__install_script_version__.zip
402             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_dhcp_install.sh
403             cd /opt
404             chmod +x v_dhcp_install.sh
405             ./v_dhcp_install.sh
406
407   # vWEB instantiaion
408   vweb_private_0_port:
409     type: OS::Neutron::Port
410     properties:
411       network: { get_param: cpe_public_net_id }
412       fixed_ips: [{"subnet": { get_param: cpe_public_subnet_id }, "ip_address": { get_param: vweb_private_ip_0 }}]
413
414   vweb_private_1_port:
415     type: OS::Neutron::Port
416     properties:
417       network: { get_param: onap_private_net_id }
418       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vweb_private_ip_1 }}]
419
420
421   vweb_0:
422     type: OS::Nova::Server
423     properties:
424       image: { get_param: vcpe_image_name }
425       flavor: { get_param: vcpe_flavor_name }
426       name: { get_param: vweb_name_0 }
427       key_name: { get_resource: my_keypair }
428       networks:
429         - network: { get_param: public_net_id }
430         - port: { get_resource: vweb_private_0_port }
431         - port: { get_resource: vweb_private_1_port }
432       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
433       user_data_format: RAW
434       user_data:
435         str_replace:
436           params:
437             __oam_ipaddr__ : { get_param: vweb_private_ip_1 }
438             __cpe_public_ipaddr__: { get_param: vweb_private_ip_0 }
439             __oam_cidr__: { get_param: onap_private_net_cidr }
440             __cpe_public_net_cidr__: { get_param: cpe_public_net_cidr }
441             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
442             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
443             __install_script_version__ : { get_param: install_script_version }
444             __cloud_env__ : { get_param: cloud_env }
445             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
446           template: |
447             #!/bin/bash
448
449             # Create configuration files
450             mkdir /opt/config
451             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
452             echo "__cpe_public_ipaddr__" > /opt/config/cpe_public_ipaddr.txt
453             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
454             echo "__cpe_public_net_cidr__" > /opt/config/cpe_public_net_cidr.txt
455             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
456             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
457             echo "__install_script_version__" > /opt/config/install_script_version.txt
458             echo "__cloud_env__" > /opt/config/cloud_env.txt
459             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
460
461             # Download and run install script
462             apt-get -y install unzip
463             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
464             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vcpe&a=vcpe-scripts&e=zip&v=__install_script_version__" -o /opt/vcpe-scripts-__install_script_version__.zip
465             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_web_install.sh
466             cd /opt
467             chmod +x v_web_install.sh
468             ./v_web_install.sh