Correct path of JAR files
[demo.git] / heat / vLBMS / base_vlb.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 to deploy vLoadBalancer/vDNS demo app for ONAP
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   vlb_image_name:
37     type: string
38     label: Image name or ID
39     description: Image to be used for compute instance
40   vlb_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   vlb_private_net_id:
49     type: string
50     label: vLoadBalancer private network name or ID
51     description: Private network that connects vLoadBalancer with vDNSs
52   pktgen_private_net_id:
53     type: string
54     label: vPacketGen private network name or ID
55     description: Private network that connects vLoadBalancer with vPacketGen
56   onap_private_net_id:
57     type: string
58     label: ECOMP management network name or ID
59     description: Private network that connects ONAP component and the VNF
60   onap_private_subnet_id:
61     type: string
62     label: ECOMP management sub-network name or ID
63     description: Private sub-network that connects ONAP component and the VNF
64   vlb_private_net_cidr:
65     type: string
66     label: vLoadBalancer private network CIDR
67     description: The CIDR of the vLoadBalancer private network
68   pktgen_private_net_cidr:
69     type: string
70     label: vPacketGen private network CIDR
71     description: The CIDR of the vPacketGen 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   vlb_private_ip_0:
77     type: string
78     label: vLoadBalancer private IP address towards the private network
79     description: Private IP address that is assigned to the vLoadBalancer to communicate with the vDNSs
80   vlb_private_ip_1:
81     type: string
82     label: vLoadBalancer private IP address towards the ONAP management network
83     description: Private IP address that is assigned to the vLoadBalancer to communicate with ONAP components
84   vlb_private_ip_2:
85     type: string
86     label: vLoadBalancer private IP address towards the vPacketGen network
87     description: Private IP address that is assigned to the vLoadBalancer to communicate with vPacketGen
88   vdns_private_ip_0:
89     type: string
90     label: vDNS private IP address towards the private network
91     description: Private IP address that is assigned to the vDNS to communicate with the vLoadBalancer
92   vdns_private_ip_1:
93     type: string
94     label: vDNS private IP address towards the ONAP management network
95     description: Private IP address that is assigned to the vDNS to communicate with ONAP components
96   vpg_private_ip_0:
97     type: string
98     label: vPacketGen private IP address towards the vPacketGen private network
99     description: Private IP address that is assigned to the vPacketGen to communicate with the vLoadBalancer
100   vpg_private_ip_1:
101     type: string
102     label: vPacketGen private IP address towards the ONAP management network
103     description: Private IP address that is assigned to the vPacketGen to communicate with ONAP components
104   vip:
105     type: string
106     label: Virtual Private IP of the vLoadBalancer
107     description: Virtual Private IP that is assigned to the vLoadBalancer's VPP layer
108   gre_ipaddr:
109     type: string
110     label: IP Address of the GRE tunnel
111     description: IP address assigned to the GRE tunnel on the vLoadBalancer
112   pg_int:
113     type: string
114     label: IP Address of the output vPacketGen interface
115     description: IP address assigned to the output interface of the vPacketGen's VPP layer
116   vlb_name_0:
117     type: string
118     label: vLoadBalancer name
119     description: Name of the vLoadBalancer
120   vdns_name_0:
121     type: string
122     label: vDNS name
123     description: Name of the vDNS
124   vpg_name_0:
125     type: string
126     label: vPKTGEN name
127     description: Name of the vPKTGEN
128   vnf_id:
129     type: string
130     label: VNF ID
131     description: The VNF ID is provided by ONAP
132   vf_module_id:
133     type: string
134     label: vFirewall module ID
135     description: The vLoadBalancer Module ID is provided by ONAP
136   dcae_collector_ip:
137     type: string
138     label: DCAE collector IP address
139     description: IP address of the DCAE collector
140   dcae_collector_port:
141     type: string
142     label: DCAE collector port
143     description: Port of the DCAE collector
144   key_name:
145     type: string
146     label: Key pair name
147     description: Public/Private key pair name
148   pub_key:
149     type: string
150     label: Public key
151     description: Public key to be installed on the compute instance
152   demo_artifacts_version:
153     type: string
154     label: Artifacts version used in demo vnfs
155     description: Version number for downloading the vPacketGen streams for VPP and VES
156   nb_api_version:
157     type: string
158     label: Northbound API version
159     description: Version number of the health check and config APIs
160   install_script_version:
161     type: string
162     label: Installation script version number
163     description: Version number of the scripts that install the vLB demo app
164   cloud_env:
165     type: string
166     label: Cloud environment
167     description: Cloud environment (e.g., openstack, rackspace)
168   nexus_artifact_repo:
169     type: string
170     description: Root URL for the Nexus repository for Maven artifacts.
171     default: "https://nexus.onap.org"
172   sec_group:
173     type: string
174     description: ONAP Security Group
175   dns_enabled:
176     type: string
177     description: Enable/disable DNS (by default use true)
178
179 #############
180 #           #
181 # RESOURCES #
182 #           #
183 #############
184
185 resources:
186
187   random-str:
188     type: OS::Heat::RandomString
189     properties:
190       length: 4
191
192   my_keypair:
193     type: OS::Nova::KeyPair
194     properties:
195       name: 
196         str_replace:
197           template: base_rand
198           params:
199             base: { get_param: key_name }
200             rand: { get_resource: random-str }  
201       public_key: { get_param: pub_key }
202       save_private_key: false
203
204   vlb_private_network:
205     type: OS::Neutron::Net
206     properties:
207       name: { get_param: vlb_private_net_id }
208
209   vlb_private_subnet:
210     type: OS::Neutron::Subnet
211     properties:
212       name: { get_param: vlb_private_net_id }
213       network_id: { get_resource: vlb_private_network }
214       cidr: { get_param: vlb_private_net_cidr }
215
216   pktgen_private_network:
217     type: OS::Neutron::Net
218     properties:
219       name: { get_param: pktgen_private_net_id }
220
221   pktgen_private_subnet:
222     type: OS::Neutron::Subnet
223     properties:
224       name: { get_param: pktgen_private_net_id }
225       network_id: { get_resource: pktgen_private_network }
226       cidr: { get_param: pktgen_private_net_cidr }
227
228   vlb_private_0_port:
229     type: OS::Neutron::Port
230     properties:
231       network: { get_resource: vlb_private_network }
232       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vlb_private_ip_0 }}]
233       security_groups:
234       - { get_param: sec_group }
235
236   vlb_private_1_port:
237     type: OS::Neutron::Port
238     properties:
239       network: { get_param: onap_private_net_id }
240       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_private_ip_1 }}]
241       security_groups:
242       - { get_param: sec_group }
243
244   vlb_private_2_port:
245     type: OS::Neutron::Port
246     properties:
247       network: { get_resource: pktgen_private_network }
248       fixed_ips: [{"subnet": { get_resource: pktgen_private_subnet }, "ip_address": { get_param: vlb_private_ip_2 }}]
249       security_groups:
250       - { get_param: sec_group }
251
252   vlb_0:
253     type: OS::Nova::Server
254     properties:
255       image: { get_param: vlb_image_name }
256       flavor: { get_param: vlb_flavor_name }
257       name: { get_param: vlb_name_0 }
258       key_name: { get_resource: my_keypair }
259       networks:
260         - network: { get_param: public_net_id }
261         - port: { get_resource: vlb_private_0_port }
262         - port: { get_resource: vlb_private_1_port }
263         - port: { get_resource: vlb_private_2_port }
264       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
265       user_data_format: RAW
266       user_data:
267         str_replace:
268           params:
269             __dcae_collector_ip__: { get_param: dcae_collector_ip }
270             __dcae_collector_port__: { get_param: dcae_collector_port }
271             __ip_to_dns_net__: { get_param: vlb_private_ip_0 }
272             __ip_to_pktgen_net__: { get_param: vlb_private_ip_2 }
273             __oam_vpktgen_ip__: { get_param: vpg_private_ip_1 }
274             __oam_vdns_ip__: { get_param: vdns_private_ip_1 }
275             __vip__: { get_param: vip }
276             __gre_ipaddr__: { get_param: gre_ipaddr }
277             __pktgen_ipaddr__: { get_param: vpg_private_ip_0 }
278             __vdns_ipaddr__: { get_param: vdns_private_ip_0 }
279             __oam_private_ipaddr__: { get_param: vlb_private_ip_1 }
280             __demo_artifacts_version__: { get_param: demo_artifacts_version }
281             __nb_api_version__: { get_param: nb_api_version }
282             __install_script_version__: { get_param: install_script_version }
283             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
284             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
285             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
286             __pktgen_mac__: { get_attr: [vpg_private_0_port, mac_address] }
287             __cloud_env__: { get_param: cloud_env }
288             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
289           template: |
290             #!/bin/bash
291
292             # Create configuration files
293             mkdir /opt/config
294             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
295             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
296             echo "__ip_to_dns_net__" > /opt/config/ip_to_dns_net.txt
297             echo "__ip_to_pktgen_net__" > /opt/config/ip_to_pktgen_net.txt
298             echo "__oam_vpktgen_ip__" > /opt/config/oam_vpktgen_ip.txt
299             echo "__oam_vdns_ip__" > /opt/config/oam_vdns_ip.txt
300             echo "__vip__" > /opt/config/vip.txt
301             echo "__gre_ipaddr__" > /opt/config/gre_ipaddr.txt
302             echo "__pktgen_ipaddr__" > /opt/config/pktgen_ipaddr.txt
303             echo "__vdns_ipaddr__" > /opt/config/vdns_ipaddr.txt
304             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
305             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
306             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
307             echo "__install_script_version__" > /opt/config/install_script_version.txt
308             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
309             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
310             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
311             echo "__pktgen_mac__" > /opt/config/pktgen_mac.txt
312             echo "__cloud_env__" > /opt/config/cloud_env.txt
313             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
314
315             # Download and run install script
316             apt-get update
317             apt-get -y install unzip
318             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
319             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vlbms&a=vlbms-scripts&e=zip&v=__install_script_version__" -o /opt/vlbms-scripts-__install_script_version__.zip
320             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_lb_install.sh
321             cd /opt
322             chmod +x v_lb_install.sh
323             ./v_lb_install.sh
324
325
326   vdns_private_0_port:
327     type: OS::Neutron::Port
328     properties:
329       network: { get_resource: vlb_private_network }
330       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vdns_private_ip_0 }}]
331       security_groups:
332       - { get_param: sec_group }
333
334   vdns_private_1_port:
335     type: OS::Neutron::Port
336     properties:
337       network: { get_param: onap_private_net_id }
338       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]
339       security_groups:
340       - { get_param: sec_group }
341
342   vdns_0:
343     type: OS::Nova::Server
344     properties:
345       image: { get_param: vlb_image_name }
346       flavor: { get_param: vlb_flavor_name }
347       name: { get_param: vdns_name_0 }
348       key_name: { get_resource: my_keypair }
349       networks:
350         - network: { get_param: public_net_id }
351         - port: { get_resource: vdns_private_0_port }
352         - port: { get_resource: vdns_private_1_port }
353       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
354       user_data_format: RAW
355       user_data:
356         str_replace:
357           params:
358             __lb_oam_int__: { get_param: vlb_private_ip_1 }
359             __lb_private_ipaddr__: { get_param: vlb_private_ip_0 }
360             __lb_to_pktgen_if__: { get_param: vlb_private_ip_2}
361             __local_private_ipaddr__: { get_param: vdns_private_ip_0 }
362             __oam_private_ipaddr__: { get_param: vdns_private_ip_1 }
363             __nb_api_version__: { get_param: nb_api_version }
364             __install_script_version__: { get_param: install_script_version }
365             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
366             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
367             __cloud_env__: { get_param: cloud_env }
368             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
369           template: |
370             #!/bin/bash
371
372             # Create configuration files
373             mkdir /opt/config
374             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
375             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
376             echo "__lb_to_pktgen_if__" > /opt/config/lb_to_pktgen_if.txt
377             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
378             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
379             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
380             echo "__install_script_version__" > /opt/config/install_script_version.txt
381             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
382             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
383             echo "__cloud_env__" > /opt/config/cloud_env.txt
384             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
385
386             # Download and run install script
387             apt-get update
388             apt-get -y install unzip
389             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
390             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vlbms&a=vlbms-scripts&e=zip&v=__install_script_version__" -o /opt/vlbms-scripts-__install_script_version__.zip
391             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_dns_install.sh
392             cd /opt
393             chmod +x v_dns_install.sh
394             ./v_dns_install.sh
395
396
397   vpg_private_0_port:
398     type: OS::Neutron::Port
399     properties:
400       network: { get_resource: pktgen_private_network }
401       fixed_ips: [{"subnet": { get_resource: pktgen_private_subnet }, "ip_address": { get_param: vpg_private_ip_0 }}]
402       security_groups:
403       - { get_param: sec_group }
404
405   vpg_private_1_port:
406     type: OS::Neutron::Port
407     properties:
408       network: { get_param: onap_private_net_id }
409       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]
410       security_groups:
411       - { get_param: sec_group }
412
413   vpg_0:
414     type: OS::Nova::Server
415     properties:
416       image: { get_param: vlb_image_name }
417       flavor: { get_param: vlb_flavor_name }
418       name: { get_param: vpg_name_0 }
419       key_name: { get_resource: my_keypair }
420       networks:
421         - network: { get_param: public_net_id }
422         - port: { get_resource: vpg_private_0_port }
423         - port: { get_resource: vpg_private_1_port }
424       user_data_format: RAW
425       user_data:
426         str_replace:
427           params:
428             __local_private_ipaddr__: { get_param: vpg_private_ip_0 }
429             __oam_private_ipaddr__: { get_param: vpg_private_ip_1 }
430             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
431             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
432             __vlb_ipaddr__: { get_param: vlb_private_ip_2 }
433             __demo_artifacts_version__: { get_param: demo_artifacts_version }
434             __nb_api_version__: { get_param: nb_api_version }
435             __install_script_version__: { get_param: install_script_version }
436             __pg_int__: { get_param: pg_int }
437             __vlb_mac__: { get_attr: [vlb_private_2_port, mac_address] }
438             __cloud_env__: { get_param: cloud_env }
439             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
440           template: |
441             #!/bin/bash
442
443             # Create configuration files
444             mkdir /opt/config
445             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
446             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
447             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
448             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
449             echo "__vlb_ipaddr__" > /opt/config/vlb_ipaddr.txt
450             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
451             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
452             echo "__install_script_version__" > /opt/config/install_script_version.txt
453             echo "__pg_int__" > /opt/config/pg_int.txt
454             echo "__vlb_mac__" > /opt/config/vlb_mac.txt
455             echo "__cloud_env__" > /opt/config/cloud_env.txt
456             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
457
458             # Download and run install script
459             apt-get update
460             apt-get -y install unzip
461             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
462             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vlbms&a=vlbms-scripts&e=zip&v=__install_script_version__" -o /opt/vlbms-scripts-__install_script_version__.zip
463             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
464             cd /opt
465             chmod +x v_packetgen_install.sh
466             ./v_packetgen_install.sh