Retrieve demo artifacts via nexus REST API
[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   install_script_version:
165     type: string
166     label: Installation script version number
167     description: Version number of the scripts that install the vFW demo app
168   demo_artifacts_version:
169     type: string
170     label: Artifacts version used in demo vnfs
171     description: Artifacts (jar, tar.gz) version used in demo vnfs
172   nexus_artifact_repo:
173     type: string
174     description: Root URL for the Nexus repository for Maven artifacts.
175     default: "https://nexus.onap.org"
176   cloud_env:
177     type: string
178     label: Cloud environment
179     description: Cloud environment (e.g., openstack, rackspace)
180
181 #############
182 #           #
183 # RESOURCES #
184 #           #
185 #############
186
187 resources:
188
189   random-str:
190     type: OS::Heat::RandomString
191     properties:
192       length: 4
193
194   my_keypair:
195     type: OS::Nova::KeyPair
196     properties:
197       name:
198         str_replace:
199           template: base_rand
200           params:
201             base: { get_param: key_name }
202             rand: { get_resource: random-str }
203       public_key: { get_param: pub_key }
204       save_private_key: false
205
206
207   # Virtual AAA server Instantiation
208   vaaa_private_0_port:
209     type: OS::Neutron::Port
210     properties:
211       network: { get_param: cpe_signal_net_id }
212       fixed_ips: [{"subnet": { get_param: cpe_signal_subnet_id }, "ip_address": { get_param: vaaa_private_ip_0 }}]
213
214   vaaa_private_1_port:
215     type: OS::Neutron::Port
216     properties:
217       network: { get_param: onap_private_net_id }
218       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vaaa_private_ip_1 }}]
219
220   vaaa_0:
221     type: OS::Nova::Server
222     properties:
223       image: { get_param: vcpe_image_name }
224       flavor: { get_param: vcpe_flavor_name }
225       name: { get_param: vaaa_name_0 }
226       key_name: { get_resource: my_keypair }
227       networks:
228         - network: { get_param: public_net_id }
229         - port: { get_resource: vaaa_private_0_port }
230         - port: { get_resource: vaaa_private_1_port }
231       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
232       user_data_format: RAW
233       user_data:
234         str_replace:
235           params:
236             __dcae_collector_ip__: { get_param: dcae_collector_ip }
237             __dcae_collector_port__: { get_param: dcae_collector_port }
238             __cpe_signal_net_ipaddr__: { get_param: vaaa_private_ip_0 }
239             __oam_ipaddr__: { get_param: vaaa_private_ip_1 }
240             __oam_cidr__: { get_param: onap_private_net_cidr }
241             __cpe_signal_net_cidr__: { get_param: cpe_signal_net_cidr }
242             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
243             __install_script_version__ : { get_param: install_script_version }
244             __cloud_env__ : { get_param: cloud_env }
245             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
246           template: |
247             #!/bin/bash
248
249             # Create configuration files
250             mkdir /opt/config
251             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
252             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
253             echo "__cpe_signal_net_ipaddr__" > /opt/config/cpe_signal_net_ipaddr.txt
254             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
255             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
256             echo "__cpe_signal_net_cidr__" > /opt/config/cpe_signal_net_cidr.txt
257             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
258             echo "__install_script_version__" > /opt/config/install_script_version.txt
259             echo "__cloud_env__" > /opt/config/cloud_env.txt
260             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
261
262             # Download and run install script
263             apt-get -y install unzip
264             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
265             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
266             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_aaa_install.sh
267             cd /opt
268             chmod +x v_aaa_install.sh
269             ./v_aaa_install.sh
270
271
272   # Virtual DNS Instantiation
273   vdns_private_0_port:
274     type: OS::Neutron::Port
275     properties:
276       network: { get_param: cpe_public_net_id }
277       fixed_ips: [{"subnet": { get_param: cpe_public_subnet_id }, "ip_address": { get_param: vdns_private_ip_0 }}]
278
279   vdns_private_1_port:
280     type: OS::Neutron::Port
281     properties:
282       network: { get_param: onap_private_net_id }
283       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]
284
285   vdns_0:
286     type: OS::Nova::Server
287     properties:
288       image: { get_param: vcpe_image_name }
289       flavor: { get_param: vcpe_flavor_name }
290       name: { get_param: vdns_name_0 }
291       key_name: { get_resource: my_keypair }
292       networks:
293         - network: { get_param: public_net_id }
294         - port: { get_resource: vdns_private_0_port }
295         - port: { get_resource: vdns_private_1_port }
296       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
297       user_data_format: RAW
298       user_data:
299         str_replace:
300           params:
301             __oam_ipaddr__ : { get_param: vdns_private_ip_1 }
302             __cpe_public_net_ipaddr__: { get_param: vdns_private_ip_0 }
303             __oam_cidr__: { get_param: onap_private_net_cidr }
304             __cpe_public_net_cidr__: { get_param: cpe_public_net_cidr }
305             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
306             __install_script_version__ : { get_param: install_script_version }
307             __cloud_env__ : { get_param: cloud_env }
308             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
309           template: |
310             #!/bin/bash
311
312             # Create configuration files
313             mkdir /opt/config
314             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
315             echo "__cpe_public_net_ipaddr__" > /opt/config/cpe_public_net_ipaddr.txt
316             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
317             echo "__cpe_public_net_cidr__" > /opt/config/cpe_public_net_cidr.txt
318             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
319             echo "__install_script_version__" > /opt/config/install_script_version.txt
320             echo "__cloud_env__" > /opt/config/cloud_env.txt
321             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
322
323             # Download and run install script
324             apt-get -y install unzip
325             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
326             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
327             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_dns_install.sh
328             cd /opt
329             chmod +x v_dns_install.sh
330             ./v_dns_install.sh
331
332
333   # Virtual DHCP Instantiation
334   vdhcp_private_0_port:
335     type: OS::Neutron::Port
336     properties:
337       network: { get_param: cpe_signal_net_id }
338       fixed_ips: [{"subnet": { get_param: cpe_signal_subnet_id }, "ip_address": { get_param: vdhcp_private_ip_0 }}]
339
340   vdhcp_private_1_port:
341     type: OS::Neutron::Port
342     properties:
343       network: { get_param: onap_private_net_id }
344       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdhcp_private_ip_1 }}]
345
346   vdhcp_0:
347     type: OS::Nova::Server
348     properties:
349       image: { get_param: vcpe_image_name }
350       flavor: { get_param: vcpe_flavor_name }
351       name: { get_param: vdhcp_name_0 }
352       key_name: { get_resource: my_keypair }
353       networks:
354         - network: { get_param: public_net_id }
355         - port: { get_resource: vdhcp_private_0_port }
356         - port: { get_resource: vdhcp_private_1_port }
357       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
358       user_data_format: RAW
359       user_data:
360         str_replace:
361           params:
362             __oam_ipaddr__ : { get_param: vdhcp_private_ip_1 }
363             __cpe_signal_ipaddr__ : { get_param: vdhcp_private_ip_0 }
364             __oam_cidr__ : { get_param: onap_private_net_cidr }
365             __cpe_signal_net_cidr__ : { get_param: cpe_signal_net_cidr }
366             __mr_ip_addr__ : { get_param: mr_ip_addr }
367             __mr_ip_port__ : { get_param: mr_ip_port }
368             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
369             __install_script_version__ : { get_param: install_script_version }
370             __cloud_env__ : { get_param: cloud_env }
371             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
372           template: |
373             #!/bin/bash
374
375             # Create configuration files
376             mkdir /opt/config
377             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
378             echo "__cpe_signal_ipaddr__" > /opt/config/cpe_signal_ipaddr.txt
379             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
380             echo "__cpe_signal_net_cidr__" > /opt/config/cpe_signal_net_cidr.txt
381             echo "__mr_ip_addr__" > /opt/config/mr_ip_addr.txt
382             echo "__mr_ip_port__" > /opt/config/mr_ip_port.txt
383             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
384             echo "__install_script_version__" > /opt/config/install_script_version.txt
385             echo "__cloud_env__" > /opt/config/cloud_env.txt
386             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
387
388             # Download and run install script
389             apt-get -y install unzip
390             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
391             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
392             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_dhcp_install.sh
393             cd /opt
394             chmod +x v_dhcp_install.sh
395             ./v_dhcp_install.sh
396
397   # vWEB instantiaion
398   vweb_private_0_port:
399     type: OS::Neutron::Port
400     properties:
401       network: { get_param: cpe_public_net_id }
402       fixed_ips: [{"subnet": { get_param: cpe_public_subnet_id }, "ip_address": { get_param: vweb_private_ip_0 }}]
403
404   vweb_private_1_port:
405     type: OS::Neutron::Port
406     properties:
407       network: { get_param: onap_private_net_id }
408       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vweb_private_ip_1 }}]
409
410
411   vweb_0:
412     type: OS::Nova::Server
413     properties:
414       image: { get_param: vcpe_image_name }
415       flavor: { get_param: vcpe_flavor_name }
416       name: { get_param: vweb_name_0 }
417       key_name: { get_resource: my_keypair }
418       networks:
419         - network: { get_param: public_net_id }
420         - port: { get_resource: vweb_private_0_port }
421         - port: { get_resource: vweb_private_1_port }
422       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
423       user_data_format: RAW
424       user_data:
425         str_replace:
426           params:
427             __oam_ipaddr__ : { get_param: vweb_private_ip_1 }
428             __cpe_public_ipaddr__: { get_param: vweb_private_ip_0 }
429             __oam_cidr__: { get_param: onap_private_net_cidr }
430             __cpe_public_net_cidr__: { get_param: cpe_public_net_cidr }
431             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
432             __install_script_version__ : { get_param: install_script_version }
433             __cloud_env__ : { get_param: cloud_env }
434             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
435           template: |
436             #!/bin/bash
437
438             # Create configuration files
439             mkdir /opt/config
440             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
441             echo "__cpe_public_ipaddr__" > /opt/config/cpe_public_ipaddr.txt
442             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
443             echo "__cpe_public_net_cidr__" > /opt/config/cpe_public_net_cidr.txt
444             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
445             echo "__install_script_version__" > /opt/config/install_script_version.txt
446             echo "__cloud_env__" > /opt/config/cloud_env.txt
447             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
448
449             # Download and run install script
450             apt-get -y install unzip
451             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
452             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
453             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_web_install.sh
454             cd /opt
455             chmod +x v_web_install.sh
456             ./v_web_install.sh