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