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