cf4fce1a6c223d64bf8cefe2ae381b83f29d0a59
[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   vdns_image_name:
45     type: string
46     label: Image name or ID
47     description: Image to be used for compute instance
48   vdns_flavor_name:
49     type: string
50     label: Flavor
51     description: Type of instance (flavor) to be used
52   vpg_image_name:
53     type: string
54     label: Image name or ID
55     description: Image to be used for compute instance
56   vpg_flavor_name:
57     type: string
58     label: Flavor
59     description: Type of instance (flavor) to be used
60   public_net_id:
61     type: string
62     label: Public network name or ID
63     description: Public network that enables remote connection to VNF
64   vlb_private_net_id:
65     type: string
66     label: vLoadBalancer private network name or ID
67     description: Private network that connects vLoadBalancer with vDNSs
68   pktgen_private_net_id:
69     type: string
70     label: vPacketGen private network name or ID
71     description: Private network that connects vLoadBalancer with vPacketGen
72   onap_private_net_id:
73     type: string
74     label: ECOMP management network name or ID
75     description: Private network that connects ONAP component and the VNF
76   onap_private_subnet_id:
77     type: string
78     label: ECOMP management sub-network name or ID
79     description: Private sub-network that connects ONAP component and the VNF
80   vlb_private_net_cidr:
81     type: string
82     label: vLoadBalancer private network CIDR
83     description: The CIDR of the vLoadBalancer private network
84   pktgen_private_net_cidr:
85     type: string
86     label: vPacketGen private network CIDR
87     description: The CIDR of the vPacketGen private network
88   onap_private_net_cidr:
89     type: string
90     label: ONAP private network CIDR
91     description: The CIDR of the protected private network
92   vlb_int_private_ip_0:
93     type: string
94     label: vLoadBalancer private IP address towards the private network
95     description: Private IP address that is assigned to the vLoadBalancer to communicate with the vDNSs
96   vlb_onap_private_ip_0:
97     type: string
98     label: vLoadBalancer private IP address towards the ONAP management network
99     description: Private IP address that is assigned to the vLoadBalancer to communicate with ONAP components
100   vlb_int_pktgen_private_ip_0:
101     type: string
102     label: vLoadBalancer private IP address towards the vPacketGen network
103     description: Private IP address that is assigned to the vLoadBalancer to communicate with vPacketGen
104   vdns_int_private_ip_0:
105     type: string
106     label: vDNS private IP address towards the private network
107     description: Private IP address that is assigned to the vDNS to communicate with the vLoadBalancer
108   vdns_onap_private_ip_0:
109     type: string
110     label: vDNS private IP address towards the ONAP management network
111     description: Private IP address that is assigned to the vDNS to communicate with ONAP components
112   vpg_int_pktgen_private_ip_0:
113     type: string
114     label: vPacketGen private IP address towards the vPacketGen private network
115     description: Private IP address that is assigned to the vPacketGen to communicate with the vLoadBalancer
116   vpg_onap_private_ip_0:
117     type: string
118     label: vPacketGen private IP address towards the ONAP management network
119     description: Private IP address that is assigned to the vPacketGen to communicate with ONAP components
120   vip:
121     type: string
122     label: Virtual Private IP of the vLoadBalancer
123     description: Virtual Private IP that is assigned to the vLoadBalancer's VPP layer
124   gre_ipaddr:
125     type: string
126     label: IP Address of the GRE tunnel
127     description: IP address assigned to the GRE tunnel on the vLoadBalancer
128   pg_int:
129     type: string
130     label: IP Address of the output vPacketGen interface
131     description: IP address assigned to the output interface of the vPacketGen's VPP layer
132   vlb_name_0:
133     type: string
134     label: vLoadBalancer name
135     description: Name of the vLoadBalancer
136   vdns_name_0:
137     type: string
138     label: vDNS name
139     description: Name of the vDNS
140   vpg_name_0:
141     type: string
142     label: vPKTGEN name
143     description: Name of the vPKTGEN
144   vnf_id:
145     type: string
146     label: VNF ID
147     description: The VNF ID is provided by ONAP
148   vnf_name:
149     type: string
150     label: VNF NAME
151     description: The VNF NAME is provided by ONAP
152   vf_module_id:
153     type: string
154     label: vFirewall module ID
155     description: The vLoadBalancer Module ID is provided by ONAP
156   dcae_collector_ip:
157     type: string
158     label: DCAE collector IP address
159     description: IP address of the DCAE collector
160   dcae_collector_port:
161     type: string
162     label: DCAE collector port
163     description: Port of the DCAE collector
164   key_name:
165     type: string
166     label: Key pair name
167     description: Public/Private key pair name
168   pub_key:
169     type: string
170     label: Public key
171     description: Public key to be installed on the compute instance
172   demo_artifacts_version:
173     type: string
174     label: Artifacts version used in demo vnfs
175     description: Version number for downloading the vPacketGen streams for VPP and VES
176   nb_api_version:
177     type: string
178     label: Northbound API version
179     description: Version number of the health check and config APIs
180   install_script_version:
181     type: string
182     label: Installation script version number
183     description: Version number of the scripts that install the vLB demo app
184   cloud_env:
185     type: string
186     label: Cloud environment
187     description: Cloud environment (e.g., openstack, rackspace)
188   nexus_artifact_repo:
189     type: string
190     description: Root URL for the Nexus repository for Maven artifacts.
191     # Default parameters prohibited
192     # default: "https://nexus.onap.org"
193   sec_group:
194     type: string
195     description: ONAP Security Group
196   # all params must be used
197   #dns_enabled:
198   #  type: string
199   #  description: Enable/disable DNS (by default use true)
200
201 #############
202 #           #
203 # RESOURCES #
204 #           #
205 #############
206
207 resources:
208
209   random-str_0:
210     type: OS::Heat::RandomString
211     properties:
212       length: 4
213
214   my_keypair_0:
215     type: OS::Nova::KeyPair
216     properties:
217       name:
218         str_replace:
219           template: vnfname_base_rand
220           params:
221             base: { get_param: key_name }
222             rand: { get_resource: random-str_0 }
223             vnfname: { get_param: vnf_name }
224       public_key: { get_param: pub_key }
225       save_private_key: false
226
227   # NETWORK_ROLE: private
228   int_private_network:
229     type: OS::Neutron::Net
230     properties:
231       name:
232         str_replace:
233           template: vnfname_privatenetid
234           params:
235             privatenetid: { get_param: vlb_private_net_id }
236             vnfname: { get_param: vnf_name }
237
238   # NETWORK_ROLE: private
239   int_private_subnet_0:
240     type: OS::Neutron::Subnet
241     properties:
242       name:
243         str_replace:
244           template: vnfname_privatenetid_subnet
245           params:
246             privatenetid: { get_param: vlb_private_net_id }
247             vnfname: { get_param: vnf_name }
248       network: { get_resource: int_private_network }
249       cidr: { get_param: vlb_private_net_cidr }
250
251   # NETWORK_ROLE: pktgen_private
252   int_pktgen_private_network:
253     type: OS::Neutron::Net
254     properties:
255       name:
256         str_replace:
257           template: vnfname_privatenetid
258           params:
259             privatenetid: { get_param: pktgen_private_net_id }
260             vnfname: { get_param: vnf_name }
261
262   # NETWORK_ROLE: pktgen_private
263   int_pktgen_private_subnet_0:
264     type: OS::Neutron::Subnet
265     properties:
266       name:
267         str_replace:
268           template: vnfname_privatenetid_subnet
269           params:
270             privatenetid: { get_param: pktgen_private_net_id }
271             vnfname: { get_param: vnf_name }
272       network: { get_resource: int_pktgen_private_network }
273       cidr: { get_param: pktgen_private_net_cidr }
274
275   # NETWORK_ROLE: private
276   # VM_TYPE: vlb
277   vlb_0_int_private_port_0:
278     type: OS::Neutron::Port
279     properties:
280       network: { get_resource: int_private_network }
281       fixed_ips: [{"subnet": { get_resource: int_private_subnet_0 }, "ip_address": { get_param: vlb_int_private_ip_0 }}]
282       security_groups:
283       - { get_param: sec_group }
284
285   # NETWORK_ROLE: onap_private
286   # VM_TYPE: vlb
287   vlb_0_onap_private_port_0:
288     type: OS::Neutron::Port
289     properties:
290       network: { get_param: onap_private_net_id }
291       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_onap_private_ip_0 }}]
292       security_groups:
293       - { get_param: sec_group }
294
295   # NETWORK_ROLE: pktgen_private
296   # VM_TYPE: vlb
297   vlb_0_int_pktgen_private_port_0:
298     type: OS::Neutron::Port
299     properties:
300       network: { get_resource: int_pktgen_private_network }
301       fixed_ips: [{"subnet": { get_resource: int_pktgen_private_subnet_0 }, "ip_address": { get_param: vlb_int_pktgen_private_ip_0 }}]
302       security_groups:
303       - { get_param: sec_group }
304
305   # VM_TYPE: vlb
306   vlb_server_0:
307     type: OS::Nova::Server
308     properties:
309       image: { get_param: vlb_image_name }
310       flavor: { get_param: vlb_flavor_name }
311       name: { get_param: vlb_name_0 }
312       key_name: { get_resource: my_keypair_0 }
313       networks:
314         - network: { get_param: public_net_id }
315         - port: { get_resource: vlb_0_int_private_port_0 }
316         - port: { get_resource: vlb_0_onap_private_port_0 }
317         - port: { get_resource: vlb_0_int_pktgen_private_port_0 }
318       metadata:
319         vnf_id: { get_param: vnf_id }
320         vf_module_id: { get_param: vf_module_id }
321         vnf_name: { get_param: vnf_name }
322       user_data_format: RAW
323       user_data:
324         str_replace:
325           params:
326             __dcae_collector_ip__: { get_param: dcae_collector_ip }
327             __dcae_collector_port__: { get_param: dcae_collector_port }
328             __ip_to_dns_net__: { get_param: vlb_int_private_ip_0 }
329             __ip_to_pktgen_net__: { get_param: vlb_int_pktgen_private_ip_0 }
330             __oam_vpktgen_ip__: { get_param: vpg_onap_private_ip_0 }
331             __oam_vdns_ip__: { get_param: vdns_onap_private_ip_0 }
332             __vip__: { get_param: vip }
333             __gre_ipaddr__: { get_param: gre_ipaddr }
334             __pktgen_ipaddr__: { get_param: vpg_int_pktgen_private_ip_0 }
335             __vdns_ipaddr__: { get_param: vdns_int_private_ip_0 }
336             __oam_private_ipaddr__: { get_param: vlb_onap_private_ip_0 }
337             __demo_artifacts_version__: { get_param: demo_artifacts_version }
338             __nb_api_version__: { get_param: nb_api_version }
339             __install_script_version__: { get_param: install_script_version }
340             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
341             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
342             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
343             __pktgen_mac__: { get_attr: [vpg_0_int_pktgen_private_port_0, mac_address] }
344             __cloud_env__: { get_param: cloud_env }
345             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
346           template: |
347             #!/bin/bash
348
349             # Create configuration files
350             mkdir /opt/config
351             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
352             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
353             echo "__ip_to_dns_net__" > /opt/config/ip_to_dns_net.txt
354             echo "__ip_to_pktgen_net__" > /opt/config/ip_to_pktgen_net.txt
355             echo "__oam_vpktgen_ip__" > /opt/config/oam_vpktgen_ip.txt
356             echo "__oam_vdns_ip__" > /opt/config/oam_vdns_ip.txt
357             echo "__vip__" > /opt/config/vip.txt
358             echo "__gre_ipaddr__" > /opt/config/gre_ipaddr.txt
359             echo "__pktgen_ipaddr__" > /opt/config/pktgen_ipaddr.txt
360             echo "__vdns_ipaddr__" > /opt/config/vdns_ipaddr.txt
361             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
362             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
363             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
364             echo "__install_script_version__" > /opt/config/install_script_version.txt
365             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
366             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
367             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
368             echo "__pktgen_mac__" > /opt/config/pktgen_mac.txt
369             echo "__cloud_env__" > /opt/config/cloud_env.txt
370             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
371
372             # Download and run install script
373             apt-get update
374             apt-get -y install unzip
375             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
376             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
377             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_lb_install.sh
378             cd /opt
379             chmod +x v_lb_install.sh
380             ./v_lb_install.sh
381
382
383   # NETWORK_ROLE: private
384   # VM_TYPE: vdns
385   vdns_0_int_private_port_0:
386     type: OS::Neutron::Port
387     properties:
388       network: { get_resource: int_private_network }
389       fixed_ips: [{"subnet": { get_resource: int_private_subnet_0 }, "ip_address": { get_param: vdns_int_private_ip_0 }}]
390       security_groups:
391       - { get_param: sec_group }
392
393   # NETWORK_ROLE: onap_private
394   # VM_TYPE: vdns
395   vdns_0_onap_private_port_0:
396     type: OS::Neutron::Port
397     properties:
398       network: { get_param: onap_private_net_id }
399       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_onap_private_ip_0 }}]
400       security_groups:
401       - { get_param: sec_group }
402
403   # VM_TYPE: vdns
404   vdns_server_0:
405     type: OS::Nova::Server
406     properties:
407       image: { get_param: vdns_image_name }
408       flavor: { get_param: vdns_flavor_name }
409       name: { get_param: vdns_name_0 }
410       key_name: { get_resource: my_keypair_0 }
411       networks:
412         - network: { get_param: public_net_id }
413         - port: { get_resource: vdns_0_int_private_port_0 }
414         - port: { get_resource: vdns_0_onap_private_port_0 }
415       metadata:
416         vnf_id: { get_param: vnf_id }
417         vf_module_id: { get_param: vf_module_id }
418         vnf_name: { get_param: vnf_name }
419       user_data_format: RAW
420       user_data:
421         str_replace:
422           params:
423             __lb_oam_int__: { get_param: vlb_onap_private_ip_0 }
424             __lb_private_ipaddr__: { get_param: vlb_int_private_ip_0 }
425             __lb_to_pktgen_if__: { get_param: vlb_int_pktgen_private_ip_0}
426             __local_private_ipaddr__: { get_param: vdns_int_private_ip_0 }
427             __oam_private_ipaddr__: { get_param: vdns_onap_private_ip_0 }
428             __nb_api_version__: { get_param: nb_api_version }
429             __install_script_version__: { get_param: install_script_version }
430             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
431             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
432             __cloud_env__: { get_param: cloud_env }
433             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
434           template: |
435             #!/bin/bash
436
437             # Create configuration files
438             mkdir /opt/config
439             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
440             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
441             echo "__lb_to_pktgen_if__" > /opt/config/lb_to_pktgen_if.txt
442             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
443             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
444             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
445             echo "__install_script_version__" > /opt/config/install_script_version.txt
446             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
447             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
448             echo "__cloud_env__" > /opt/config/cloud_env.txt
449             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
450
451             # Download and run install script
452             apt-get update
453             apt-get -y install unzip
454             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
455             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
456             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_dns_install.sh
457             cd /opt
458             chmod +x v_dns_install.sh
459             ./v_dns_install.sh
460
461
462   # NETWORK_ROLE: pktgen_private
463   # VM_TYPE: vpg
464   vpg_0_int_pktgen_private_port_0:
465     type: OS::Neutron::Port
466     properties:
467       network: { get_resource: int_pktgen_private_network }
468       fixed_ips: [{"subnet": { get_resource: int_pktgen_private_subnet_0 }, "ip_address": { get_param: vpg_int_pktgen_private_ip_0 }}]
469       security_groups:
470       - { get_param: sec_group }
471
472   # NETWORK_ROLE: onap_private
473   # VM_TYPE: vpg
474   vpg_0_onap_private_port_0:
475     type: OS::Neutron::Port
476     properties:
477       network: { get_param: onap_private_net_id }
478       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_onap_private_ip_0 }}]
479       security_groups:
480       - { get_param: sec_group }
481
482   # VM_TYPE: vpg
483   vpg_server_0:
484     type: OS::Nova::Server
485     properties:
486       image: { get_param: vpg_image_name }
487       flavor: { get_param: vpg_flavor_name }
488       name: { get_param: vpg_name_0 }
489       key_name: { get_resource: my_keypair_0 }
490       metadata:
491         vnf_id: { get_param: vnf_id }
492         vf_module_id: { get_param: vf_module_id }
493         vnf_name: { get_param: vnf_name }
494       networks:
495         - network: { get_param: public_net_id }
496         - port: { get_resource: vpg_0_int_pktgen_private_port_0 }
497         - port: { get_resource: vpg_0_onap_private_port_0 }
498       user_data_format: RAW
499       user_data:
500         str_replace:
501           params:
502             __local_private_ipaddr__: { get_param: vpg_int_pktgen_private_ip_0 }
503             __oam_private_ipaddr__: { get_param: vpg_onap_private_ip_0 }
504             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
505             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
506             __vlb_ipaddr__: { get_param: vlb_int_pktgen_private_ip_0 }
507             __demo_artifacts_version__: { get_param: demo_artifacts_version }
508             __nb_api_version__: { get_param: nb_api_version }
509             __install_script_version__: { get_param: install_script_version }
510             __pg_int__: { get_param: pg_int }
511             __vlb_mac__: { get_attr: [vlb_0_int_pktgen_private_port_0, mac_address] }
512             __cloud_env__: { get_param: cloud_env }
513             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
514           template: |
515             #!/bin/bash
516
517             # Create configuration files
518             mkdir /opt/config
519             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
520             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
521             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
522             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
523             echo "__vlb_ipaddr__" > /opt/config/vlb_ipaddr.txt
524             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
525             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
526             echo "__install_script_version__" > /opt/config/install_script_version.txt
527             echo "__pg_int__" > /opt/config/pg_int.txt
528             echo "__vlb_mac__" > /opt/config/vlb_mac.txt
529             echo "__cloud_env__" > /opt/config/cloud_env.txt
530             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
531
532             # Download and run install script
533             apt-get update
534             apt-get -y install unzip
535             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
536             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
537             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
538             cd /opt
539             chmod +x v_packetgen_install.sh
540             ./v_packetgen_install.sh
541
542 outputs:
543   int_private_subnet_id:
544     value: { get_resource: int_private_subnet_0 }
545   int_private_net_id:
546     value: { get_resource: int_private_network }