980a3be4a297366c7a118ed49412a4547e40c340
[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   sec_group:
192     type: string
193     description: ONAP Security Group
194
195 #############
196 #           #
197 # RESOURCES #
198 #           #
199 #############
200
201 resources:
202
203   random-str_0:
204     type: OS::Heat::RandomString
205     properties:
206       length: 4
207
208   my_keypair_0:
209     type: OS::Nova::KeyPair
210     properties:
211       name:
212         str_replace:
213           template: vnfname_base_rand
214           params:
215             base: { get_param: key_name }
216             rand: { get_resource: random-str_0 }
217             vnfname: { get_param: vnf_name }
218       public_key: { get_param: pub_key }
219       save_private_key: false
220
221   # NETWORK_ROLE: private
222   int_private_network:
223     type: OS::Neutron::Net
224     properties:
225       name:
226         str_replace:
227           template: vnfname_privatenetid
228           params:
229             privatenetid: { get_param: vlb_private_net_id }
230             vnfname: { get_param: vnf_name }
231
232   # NETWORK_ROLE: private
233   int_private_subnet_0:
234     type: OS::Neutron::Subnet
235     properties:
236       name:
237         str_replace:
238           template: vnfname_privatenetid_subnet
239           params:
240             privatenetid: { get_param: vlb_private_net_id }
241             vnfname: { get_param: vnf_name }
242       network: { get_resource: int_private_network }
243       cidr: { get_param: vlb_private_net_cidr }
244
245   # NETWORK_ROLE: pktgen_private
246   int_pktgen_private_network:
247     type: OS::Neutron::Net
248     properties:
249       name:
250         str_replace:
251           template: vnfname_privatenetid
252           params:
253             privatenetid: { get_param: pktgen_private_net_id }
254             vnfname: { get_param: vnf_name }
255
256   # NETWORK_ROLE: pktgen_private
257   int_pktgen_private_subnet_0:
258     type: OS::Neutron::Subnet
259     properties:
260       name:
261         str_replace:
262           template: vnfname_privatenetid_subnet
263           params:
264             privatenetid: { get_param: pktgen_private_net_id }
265             vnfname: { get_param: vnf_name }
266       network: { get_resource: int_pktgen_private_network }
267       cidr: { get_param: pktgen_private_net_cidr }
268
269   # NETWORK_ROLE: private
270   # VM_TYPE: vlb
271   vlb_0_int_private_port_0:
272     type: OS::Neutron::Port
273     properties:
274       network: { get_resource: int_private_network }
275       fixed_ips: [{"subnet": { get_resource: int_private_subnet_0 }, "ip_address": { get_param: vlb_int_private_ip_0 }}]
276       security_groups:
277       - { get_param: sec_group }
278
279   # NETWORK_ROLE: onap_private
280   # VM_TYPE: vlb
281   vlb_0_onap_private_port_0:
282     type: OS::Neutron::Port
283     properties:
284       network: { get_param: onap_private_net_id }
285       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_onap_private_ip_0 }}]
286       security_groups:
287       - { get_param: sec_group }
288
289   # NETWORK_ROLE: pktgen_private
290   # VM_TYPE: vlb
291   vlb_0_int_pktgen_private_port_0:
292     type: OS::Neutron::Port
293     properties:
294       network: { get_resource: int_pktgen_private_network }
295       fixed_ips: [{"subnet": { get_resource: int_pktgen_private_subnet_0 }, "ip_address": { get_param: vlb_int_pktgen_private_ip_0 }}]
296       security_groups:
297       - { get_param: sec_group }
298
299   # VM_TYPE: vlb
300   vlb_server_0:
301     type: OS::Nova::Server
302     properties:
303       image: { get_param: vlb_image_name }
304       flavor: { get_param: vlb_flavor_name }
305       name: { get_param: vlb_name_0 }
306       key_name: { get_resource: my_keypair_0 }
307       networks:
308         - network: { get_param: public_net_id }
309         - port: { get_resource: vlb_0_int_private_port_0 }
310         - port: { get_resource: vlb_0_onap_private_port_0 }
311         - port: { get_resource: vlb_0_int_pktgen_private_port_0 }
312       metadata:
313         vnf_id: { get_param: vnf_id }
314         vf_module_id: { get_param: vf_module_id }
315         vnf_name: { get_param: vnf_name }
316       user_data_format: RAW
317       user_data:
318         str_replace:
319           params:
320             __dcae_collector_ip__: { get_param: dcae_collector_ip }
321             __dcae_collector_port__: { get_param: dcae_collector_port }
322             __ip_to_dns_net__: { get_param: vlb_int_private_ip_0 }
323             __ip_to_pktgen_net__: { get_param: vlb_int_pktgen_private_ip_0 }
324             __oam_vpktgen_ip__: { get_param: vpg_onap_private_ip_0 }
325             __oam_vdns_ip__: { get_param: vdns_onap_private_ip_0 }
326             __vip__: { get_param: vip }
327             __gre_ipaddr__: { get_param: gre_ipaddr }
328             __pktgen_ipaddr__: { get_param: vpg_int_pktgen_private_ip_0 }
329             __vdns_ipaddr__: { get_param: vdns_int_private_ip_0 }
330             __oam_private_ipaddr__: { get_param: vlb_onap_private_ip_0 }
331             __demo_artifacts_version__: { get_param: demo_artifacts_version }
332             __nb_api_version__: { get_param: nb_api_version }
333             __install_script_version__: { get_param: install_script_version }
334             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
335             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
336             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
337             __pktgen_mac__: { get_attr: [vpg_0_int_pktgen_private_port_0, mac_address] }
338             __cloud_env__: { get_param: cloud_env }
339             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
340           template: |
341             #!/bin/bash
342
343             # Create configuration files
344             mkdir /opt/config
345             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
346             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
347             echo "__ip_to_dns_net__" > /opt/config/ip_to_dns_net.txt
348             echo "__ip_to_pktgen_net__" > /opt/config/ip_to_pktgen_net.txt
349             echo "__oam_vpktgen_ip__" > /opt/config/oam_vpktgen_ip.txt
350             echo "__oam_vdns_ip__" > /opt/config/oam_vdns_ip.txt
351             echo "__vip__" > /opt/config/vip.txt
352             echo "__gre_ipaddr__" > /opt/config/gre_ipaddr.txt
353             echo "__pktgen_ipaddr__" > /opt/config/pktgen_ipaddr.txt
354             echo "__vdns_ipaddr__" > /opt/config/vdns_ipaddr.txt
355             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
356             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
357             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
358             echo "__install_script_version__" > /opt/config/install_script_version.txt
359             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
360             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
361             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
362             echo "__pktgen_mac__" > /opt/config/pktgen_mac.txt
363             echo "__cloud_env__" > /opt/config/cloud_env.txt
364             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
365
366             # Download and run install script
367             apt-get update
368             apt-get -y install unzip
369             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
370             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
371             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_lb_install.sh
372             cd /opt
373             chmod +x v_lb_install.sh
374             ./v_lb_install.sh
375
376
377   # NETWORK_ROLE: private
378   # VM_TYPE: vdns
379   vdns_0_int_private_port_0:
380     type: OS::Neutron::Port
381     properties:
382       network: { get_resource: int_private_network }
383       fixed_ips: [{"subnet": { get_resource: int_private_subnet_0 }, "ip_address": { get_param: vdns_int_private_ip_0 }}]
384       security_groups:
385       - { get_param: sec_group }
386
387   # NETWORK_ROLE: onap_private
388   # VM_TYPE: vdns
389   vdns_0_onap_private_port_0:
390     type: OS::Neutron::Port
391     properties:
392       network: { get_param: onap_private_net_id }
393       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_onap_private_ip_0 }}]
394       security_groups:
395       - { get_param: sec_group }
396
397   # VM_TYPE: vdns
398   vdns_server_0:
399     type: OS::Nova::Server
400     properties:
401       image: { get_param: vdns_image_name }
402       flavor: { get_param: vdns_flavor_name }
403       name: { get_param: vdns_name_0 }
404       key_name: { get_resource: my_keypair_0 }
405       networks:
406         - network: { get_param: public_net_id }
407         - port: { get_resource: vdns_0_int_private_port_0 }
408         - port: { get_resource: vdns_0_onap_private_port_0 }
409       metadata:
410         vnf_id: { get_param: vnf_id }
411         vf_module_id: { get_param: vf_module_id }
412         vnf_name: { get_param: vnf_name }
413       user_data_format: RAW
414       user_data:
415         str_replace:
416           params:
417             __lb_oam_int__: { get_param: vlb_onap_private_ip_0 }
418             __lb_private_ipaddr__: { get_param: vlb_int_private_ip_0 }
419             __lb_to_pktgen_if__: { get_param: vlb_int_pktgen_private_ip_0}
420             __local_private_ipaddr__: { get_param: vdns_int_private_ip_0 }
421             __oam_private_ipaddr__: { get_param: vdns_onap_private_ip_0 }
422             __nb_api_version__: { get_param: nb_api_version }
423             __install_script_version__: { get_param: install_script_version }
424             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
425             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
426             __cloud_env__: { get_param: cloud_env }
427             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
428           template: |
429             #!/bin/bash
430
431             # Create configuration files
432             mkdir /opt/config
433             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
434             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
435             echo "__lb_to_pktgen_if__" > /opt/config/lb_to_pktgen_if.txt
436             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
437             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
438             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
439             echo "__install_script_version__" > /opt/config/install_script_version.txt
440             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
441             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
442             echo "__cloud_env__" > /opt/config/cloud_env.txt
443             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
444
445             # Download and run install script
446             apt-get update
447             apt-get -y install unzip
448             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
449             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
450             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_dns_install.sh
451             cd /opt
452             chmod +x v_dns_install.sh
453             ./v_dns_install.sh
454
455
456   # NETWORK_ROLE: pktgen_private
457   # VM_TYPE: vpg
458   vpg_0_int_pktgen_private_port_0:
459     type: OS::Neutron::Port
460     properties:
461       network: { get_resource: int_pktgen_private_network }
462       fixed_ips: [{"subnet": { get_resource: int_pktgen_private_subnet_0 }, "ip_address": { get_param: vpg_int_pktgen_private_ip_0 }}]
463       security_groups:
464       - { get_param: sec_group }
465
466   # NETWORK_ROLE: onap_private
467   # VM_TYPE: vpg
468   vpg_0_onap_private_port_0:
469     type: OS::Neutron::Port
470     properties:
471       network: { get_param: onap_private_net_id }
472       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_onap_private_ip_0 }}]
473       security_groups:
474       - { get_param: sec_group }
475
476   # VM_TYPE: vpg
477   vpg_server_0:
478     type: OS::Nova::Server
479     properties:
480       image: { get_param: vpg_image_name }
481       flavor: { get_param: vpg_flavor_name }
482       name: { get_param: vpg_name_0 }
483       key_name: { get_resource: my_keypair_0 }
484       metadata:
485         vnf_id: { get_param: vnf_id }
486         vf_module_id: { get_param: vf_module_id }
487         vnf_name: { get_param: vnf_name }
488       networks:
489         - network: { get_param: public_net_id }
490         - port: { get_resource: vpg_0_int_pktgen_private_port_0 }
491         - port: { get_resource: vpg_0_onap_private_port_0 }
492       user_data_format: RAW
493       user_data:
494         str_replace:
495           params:
496             __local_private_ipaddr__: { get_param: vpg_int_pktgen_private_ip_0 }
497             __oam_private_ipaddr__: { get_param: vpg_onap_private_ip_0 }
498             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
499             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
500             __vlb_ipaddr__: { get_param: vlb_int_pktgen_private_ip_0 }
501             __demo_artifacts_version__: { get_param: demo_artifacts_version }
502             __nb_api_version__: { get_param: nb_api_version }
503             __install_script_version__: { get_param: install_script_version }
504             __pg_int__: { get_param: pg_int }
505             __vlb_mac__: { get_attr: [vlb_0_int_pktgen_private_port_0, mac_address] }
506             __cloud_env__: { get_param: cloud_env }
507             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
508           template: |
509             #!/bin/bash
510
511             # Create configuration files
512             mkdir /opt/config
513             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
514             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
515             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
516             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
517             echo "__vlb_ipaddr__" > /opt/config/vlb_ipaddr.txt
518             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
519             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
520             echo "__install_script_version__" > /opt/config/install_script_version.txt
521             echo "__pg_int__" > /opt/config/pg_int.txt
522             echo "__vlb_mac__" > /opt/config/vlb_mac.txt
523             echo "__cloud_env__" > /opt/config/cloud_env.txt
524             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
525
526             # Download and run install script
527             apt-get update
528             apt-get -y install unzip
529             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
530             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
531             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
532             cd /opt
533             chmod +x v_packetgen_install.sh
534             ./v_packetgen_install.sh
535
536 outputs:
537   int_private_subnet_id:
538     value: { get_resource: int_private_subnet_0 }
539   int_private_net_id:
540     value: { get_resource: int_private_network }