ff5da41639f65179c5192121f05b7baccd560d2c
[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
176 #############
177 #           #
178 # RESOURCES #
179 #           #
180 #############
181
182 resources:
183
184   random-str:
185     type: OS::Heat::RandomString
186     properties:
187       length: 4
188
189   my_keypair:
190     type: OS::Nova::KeyPair
191     properties:
192       name: 
193         str_replace:
194           template: base_rand
195           params:
196             base: { get_param: key_name }
197             rand: { get_resource: random-str }  
198       public_key: { get_param: pub_key }
199       save_private_key: false
200
201   vlb_private_network:
202     type: OS::Neutron::Net
203     properties:
204       name: { get_param: vlb_private_net_id }
205
206   vlb_private_subnet:
207     type: OS::Neutron::Subnet
208     properties:
209       name: { get_param: vlb_private_net_id }
210       network_id: { get_resource: vlb_private_network }
211       cidr: { get_param: vlb_private_net_cidr }
212
213   pktgen_private_network:
214     type: OS::Neutron::Net
215     properties:
216       name: { get_param: pktgen_private_net_id }
217
218   pktgen_private_subnet:
219     type: OS::Neutron::Subnet
220     properties:
221       name: { get_param: pktgen_private_net_id }
222       network_id: { get_resource: pktgen_private_network }
223       cidr: { get_param: pktgen_private_net_cidr }
224
225   vlb_private_0_port:
226     type: OS::Neutron::Port
227     properties:
228       network: { get_resource: vlb_private_network }
229       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vlb_private_ip_0 }}]
230       security_groups:
231       - { get_param: sec_group }
232
233   vlb_private_1_port:
234     type: OS::Neutron::Port
235     properties:
236       network: { get_param: onap_private_net_id }
237       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_private_ip_1 }}]
238       security_groups:
239       - { get_param: sec_group }
240
241   vlb_private_2_port:
242     type: OS::Neutron::Port
243     properties:
244       network: { get_resource: pktgen_private_network }
245       fixed_ips: [{"subnet": { get_resource: pktgen_private_subnet }, "ip_address": { get_param: vlb_private_ip_2 }}]
246       security_groups:
247       - { get_param: sec_group }
248
249   vlb_0:
250     type: OS::Nova::Server
251     properties:
252       image: { get_param: vlb_image_name }
253       flavor: { get_param: vlb_flavor_name }
254       name: { get_param: vlb_name_0 }
255       key_name: { get_resource: my_keypair }
256       networks:
257         - network: { get_param: public_net_id }
258         - port: { get_resource: vlb_private_0_port }
259         - port: { get_resource: vlb_private_1_port }
260         - port: { get_resource: vlb_private_2_port }
261       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
262       user_data_format: RAW
263       user_data:
264         str_replace:
265           params:
266             __dcae_collector_ip__: { get_param: dcae_collector_ip }
267             __dcae_collector_port__: { get_param: dcae_collector_port }
268             __ip_to_dns_net__: { get_param: vlb_private_ip_0 }
269             __ip_to_pktgen_net__: { get_param: vlb_private_ip_2 }
270             __oam_vpktgen_ip__: { get_param: vpg_private_ip_1 }
271             __oam_vdns_ip__: { get_param: vdns_private_ip_1 }
272             __vip__: { get_param: vip }
273             __gre_ipaddr__: { get_param: gre_ipaddr }
274             __pktgen_ipaddr__: { get_param: vpg_private_ip_0 }
275             __vdns_ipaddr__: { get_param: vdns_private_ip_0 }
276             __oam_private_ipaddr__: { get_param: vlb_private_ip_1 }
277             __demo_artifacts_version__: { get_param: demo_artifacts_version }
278             __nb_api_version__: { get_param: nb_api_version }
279             __install_script_version__: { get_param: install_script_version }
280             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
281             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
282             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
283             __pktgen_mac__: { get_attr: [vpg_private_0_port, mac_address] }
284             __cloud_env__: { get_param: cloud_env }
285             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
286           template: |
287             #!/bin/bash
288
289             # Create configuration files
290             mkdir /opt/config
291             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
292             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
293             echo "__ip_to_dns_net__" > /opt/config/ip_to_dns_net.txt
294             echo "__ip_to_pktgen_net__" > /opt/config/ip_to_pktgen_net.txt
295             echo "__oam_vpktgen_ip__" > /opt/config/oam_vpktgen_ip.txt
296             echo "__oam_vdns_ip__" > /opt/config/oam_vdns_ip.txt
297             echo "__vip__" > /opt/config/vip.txt
298             echo "__gre_ipaddr__" > /opt/config/gre_ipaddr.txt
299             echo "__pktgen_ipaddr__" > /opt/config/pktgen_ipaddr.txt
300             echo "__vdns_ipaddr__" > /opt/config/vdns_ipaddr.txt
301             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
302             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
303             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
304             echo "__install_script_version__" > /opt/config/install_script_version.txt
305             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
306             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
307             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
308             echo "__pktgen_mac__" > /opt/config/pktgen_mac.txt
309             echo "__cloud_env__" > /opt/config/cloud_env.txt
310             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
311
312             # Download and run install script
313             apt-get update
314             apt-get -y install unzip
315             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
316             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
317             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_lb_install.sh
318             cd /opt
319             chmod +x v_lb_install.sh
320             ./v_lb_install.sh
321
322
323   vdns_private_0_port:
324     type: OS::Neutron::Port
325     properties:
326       network: { get_resource: vlb_private_network }
327       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vdns_private_ip_0 }}]
328       security_groups:
329       - { get_param: sec_group }
330
331   vdns_private_1_port:
332     type: OS::Neutron::Port
333     properties:
334       network: { get_param: onap_private_net_id }
335       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]
336       security_groups:
337       - { get_param: sec_group }
338
339   vdns_0:
340     type: OS::Nova::Server
341     properties:
342       image: { get_param: vlb_image_name }
343       flavor: { get_param: vlb_flavor_name }
344       name: { get_param: vdns_name_0 }
345       key_name: { get_resource: my_keypair }
346       networks:
347         - network: { get_param: public_net_id }
348         - port: { get_resource: vdns_private_0_port }
349         - port: { get_resource: vdns_private_1_port }
350       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
351       user_data_format: RAW
352       user_data:
353         str_replace:
354           params:
355             __lb_oam_int__: { get_param: vlb_private_ip_1 }
356             __lb_private_ipaddr__: { get_param: vlb_private_ip_0 }
357             __lb_to_pktgen_if__: { get_param: vlb_private_ip_2}
358             __local_private_ipaddr__: { get_param: vdns_private_ip_0 }
359             __oam_private_ipaddr__: { get_param: vdns_private_ip_1 }
360             __nb_api_version__: { get_param: nb_api_version }
361             __install_script_version__: { get_param: install_script_version }
362             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
363             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
364             __cloud_env__: { get_param: cloud_env }
365             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
366           template: |
367             #!/bin/bash
368
369             # Create configuration files
370             mkdir /opt/config
371             echo "__lb_oam_int__" > /opt/config/lb_oam_int.txt
372             echo "__lb_private_ipaddr__" > /opt/config/lb_private_ipaddr.txt
373             echo "__lb_to_pktgen_if__" > /opt/config/lb_to_pktgen_if.txt
374             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
375             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
376             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
377             echo "__install_script_version__" > /opt/config/install_script_version.txt
378             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
379             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
380             echo "__cloud_env__" > /opt/config/cloud_env.txt
381             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
382
383             # Download and run install script
384             apt-get update
385             apt-get -y install unzip
386             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
387             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
388             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_dns_install.sh
389             cd /opt
390             chmod +x v_dns_install.sh
391             ./v_dns_install.sh
392
393
394   vpg_private_0_port:
395     type: OS::Neutron::Port
396     properties:
397       network: { get_resource: pktgen_private_network }
398       fixed_ips: [{"subnet": { get_resource: pktgen_private_subnet }, "ip_address": { get_param: vpg_private_ip_0 }}]
399       security_groups:
400       - { get_param: sec_group }
401
402   vpg_private_1_port:
403     type: OS::Neutron::Port
404     properties:
405       network: { get_param: onap_private_net_id }
406       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]
407       security_groups:
408       - { get_param: sec_group }
409
410   vpg_0:
411     type: OS::Nova::Server
412     properties:
413       image: { get_param: vlb_image_name }
414       flavor: { get_param: vlb_flavor_name }
415       name: { get_param: vpg_name_0 }
416       key_name: { get_resource: my_keypair }
417       networks:
418         - network: { get_param: public_net_id }
419         - port: { get_resource: vpg_private_0_port }
420         - port: { get_resource: vpg_private_1_port }
421       user_data_format: RAW
422       user_data:
423         str_replace:
424           params:
425             __local_private_ipaddr__: { get_param: vpg_private_ip_0 }
426             __oam_private_ipaddr__: { get_param: vpg_private_ip_1 }
427             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
428             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
429             __vlb_ipaddr__: { get_param: vlb_private_ip_2 }
430             __demo_artifacts_version__: { get_param: demo_artifacts_version }
431             __nb_api_version__: { get_param: nb_api_version }
432             __install_script_version__: { get_param: install_script_version }
433             __pg_int__: { get_param: pg_int }
434             __vlb_mac__: { get_attr: [vlb_private_2_port, mac_address] }
435             __cloud_env__: { get_param: cloud_env }
436             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
437           template: |
438             #!/bin/bash
439
440             # Create configuration files
441             mkdir /opt/config
442             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
443             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
444             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
445             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
446             echo "__vlb_ipaddr__" > /opt/config/vlb_ipaddr.txt
447             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
448             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
449             echo "__install_script_version__" > /opt/config/install_script_version.txt
450             echo "__pg_int__" > /opt/config/pg_int.txt
451             echo "__vlb_mac__" > /opt/config/vlb_mac.txt
452             echo "__cloud_env__" > /opt/config/cloud_env.txt
453             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
454
455             # Download and run install script
456             apt-get update
457             apt-get -y install unzip
458             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
459             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
460             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
461             cd /opt
462             chmod +x v_packetgen_install.sh
463             ./v_packetgen_install.sh