upload heat templates
[demo.git] / heat / vLB / base_vlb.yaml
1 heat_template_version: 2013-05-23
2
3 description: Heat template to deploy vLoadBalancer/vDNS demo app for OpenECOMP
4
5 parameters:
6   vlb_image_name:
7     type: string
8     label: Image name or ID
9     description: Image to be used for compute instance
10   vlb_flavor_name:
11     type: string
12     label: Flavor
13     description: Type of instance (flavor) to be used
14   public_net_id:
15     type: string
16     label: Public network name or ID
17     description: Public network that enables remote connection to VNF
18   vlb_private_net_id:
19     type: string
20     label: vLoadBalancer private network name or ID
21     description: Private network that connects vLoadBalancer with vDNSs
22   ecomp_private_net_id:
23     type: string
24     label: ECOMP management network name or ID
25     description: Private network that connects ECOMP component and the VNF
26   ecomp_private_subnet_id:
27     type: string
28     label: ECOMP management sub-network name or ID
29     description: Private sub-network that connects ECOMP component and the VNF
30   vlb_private_net_cidr:
31     type: string
32     label: vLoadBalancer private network CIDR
33     description: The CIDR of the vLoadBalancer private network
34   ecomp_private_net_cidr:
35     type: string
36     label: ECOMP private network CIDR
37     description: The CIDR of the protected private network
38   vlb_private_ip_0:
39     type: string
40     label: vLoadBalancer private IP address towards the private network
41     description: Private IP address that is assigned to the vLoadBalancer to communicate with the vDNSs
42   vlb_private_ip_1:
43     type: string
44     label: vLoadBalancer private IP address towards the ECOMP management network
45     description: Private IP address that is assigned to the vLoadBalancer to communicate with ECOMP components
46   vdns_private_ip_0:
47     type: string
48     label: vDNS private IP address towards the private network
49     description: Private IP address that is assigned to the vDNS to communicate with the vLoadBalancer
50   vdns_private_ip_1:
51     type: string
52     label: vDNS private IP address towards the ECOMP management network
53     description: Private IP address that is assigned to the vDNS to communicate with ECOMP components
54   vlb_name_0:
55     type: string
56     label: vLoadBalancer name
57     description: Name of the vLoadBalancer
58   vdns_name_0:
59     type: string
60     label: vDNS name
61     description: Name of the vDNS
62   vnf_id:
63     type: string
64     label: VNF ID
65     description: The VNF ID is provided by ECOMP
66   vf_module_id:
67     type: string
68     label: vFirewall module ID
69     description: The vLoadBalancer Module ID is provided by ECOMP
70   dcae_collector_ip:
71     type: string
72     label: DCAE collector IP address
73     description: IP address of the DCAE collector
74   dcae_collector_port:
75     type: string
76     label: DCAE collector port
77     description: Port of the DCAE collector
78   key_name:
79     type: string
80     label: Key pair name
81     description: Public/Private key pair name
82   pub_key:
83     type: string
84     label: Public key
85     description: Public key to be installed on the compute instance
86   repo_url_blob:
87     type: string
88     label: Repository URL
89     description: URL of the repository that hosts the demo packages
90   repo_url_artifacts:
91     type: string
92     label: Repository URL
93     description: URL of the repository that hosts the demo packages
94   demo_artifacts_version:
95     type: string
96     label: Artifacts version used in demo vnfs
97     description: Artifacts (jar, tar.gz) version used in demo vnfs
98
99 resources:
100
101   random-str:
102     type: OS::Heat::RandomString
103     properties:
104       length: 4
105   
106   my_keypair:
107     type: OS::Nova::KeyPair
108     properties:
109       name: 
110         str_replace:
111           template: base_rand
112           params:
113             base: { get_param: key_name }
114             rand: { get_resource: random-str }  
115       public_key: { get_param: pub_key }
116       save_private_key: false
117
118   vlb_private_network:
119     type: OS::Neutron::Net
120     properties:
121       name: { get_param: vlb_private_net_id }
122
123   vlb_private_subnet:
124     type: OS::Neutron::Subnet
125     properties:
126       name: { get_param: vlb_private_net_id }
127       network_id: { get_resource: vlb_private_network }
128       cidr: { get_param: vlb_private_net_cidr }
129
130   vlb_0:
131     type: OS::Nova::Server
132     properties:
133       image: { get_param: vlb_image_name }
134       flavor: { get_param: vlb_flavor_name }
135       name: { get_param: vlb_name_0 }
136       key_name: { get_resource: my_keypair }
137       networks:
138         - network: { get_param: public_net_id }
139         - port: { get_resource: vlb_private_0_port }
140         - port: { get_resource: vlb_private_1_port }
141       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
142       user_data_format: RAW
143       user_data:
144         str_replace:
145           params:
146             __dcae_collector_ip__: { get_param: dcae_collector_ip }
147             __dcae_collector_port__: { get_param: dcae_collector_port }
148             __local_private_ipaddr__: { get_param: vlb_private_ip_0 }
149             __repo_url_blob__ : { get_param: repo_url_blob }
150             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
151             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
152           template: |
153             #!/bin/bash
154
155             DCAE_COLLECTOR_IP=__dcae_collector_ip__
156             DCAE_COLLECTOR_PORT=__dcae_collector_port__
157             LOCAL_PRIVATE_IPADDR=__local_private_ipaddr__
158             REPO_URL_BLOB=__repo_url_blob__
159             REPO_URL_ARTIFACTS=__repo_url_artifacts__
160             DEMO_ARTIFACTS_VERSION=__demo_artifacts_version__
161
162             # Download required dependencies
163             add-apt-repository -y ppa:openjdk-r/ppa
164             apt-get update
165             apt-get install -y make gcc wget openjdk-8-jdk bridge-utils libcurl4-openssl-dev apt-transport-https ca-certificates
166             apt-get install -y maven
167             sleep 1
168
169             # Download vLB demo code for load balancer
170             mkdir /opt/config
171             mkdir /opt/FDserver
172             cd /opt
173
174             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/v_lb_init.sh
175             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/vlb.sh
176             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/dnsmembership.sh
177             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/add_dns.sh
178             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/remove_dns.sh
179
180             mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get -DremoteRepositories=$REPO_URL_ARTIFACTS -Dartifact=org.openecomp.demo.vnf.vlb:dns-manager:$DEMO_ARTIFACTS_VERSION:jar -Dtransitive=false -Ddest=.
181             mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get -DremoteRepositories=$REPO_URL_ARTIFACTS -Dartifact=org.openecomp.demo.vnf.ves:ves:$DEMO_ARTIFACTS_VERSION:tar.gz:demo -Dtransitive=false -Ddest=.
182             mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get -DremoteRepositories=$REPO_URL_ARTIFACTS -Dartifact=org.openecomp.demo.vnf.ves:ves_vlb_reporting:$DEMO_ARTIFACTS_VERSION:tar.gz:demo -Dtransitive=false -Ddest=.
183
184             tar -zxvf ves-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
185             mv ves-$DEMO_ARTIFACTS_VERSION VES
186             tar -zxvf ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
187             mv ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION VESreporting_vLB
188
189             mv VESreporting_vLB /opt/VES/code/evel_training/VESreporting
190             mv dns-manager-$DEMO_ARTIFACTS_VERSION.jar /opt/FDserver/dns-manager-$DEMO_ARTIFACTS_VERSION.jar
191             mv dnsmembership.sh /opt/FDserver/dnsmembership.sh
192             mv add_dns.sh /opt/FDserver/add_dns.sh
193             mv remove_dns.sh /opt/FDserver/remove_dns.sh
194             rm *.tar.gz
195
196             chmod +x v_lb_init.sh
197             chmod +x vlb.sh
198             chmod +x /opt/VES/code/evel_training/VESreporting/go-client.sh
199             chmod +x /opt/FDserver/dnsmembership.sh
200             chmod +x /opt/FDserver/add_dns.sh
201             chmod +x /opt/FDserver/remove_dns.sh
202
203             echo $DCAE_COLLECTOR_IP > config/dcae_collector_ip.txt
204             echo $DCAE_COLLECTOR_PORT > config/dcae_collector_port.txt
205             echo $LOCAL_PRIVATE_IPADDR > config/local_private_ipaddr.txt
206             LOCAL_PUBLIC_IPADDR=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
207             echo $LOCAL_PUBLIC_IPADDR > config/local_public_ipaddr.txt
208             echo $DEMO_ARTIFACTS_VERSION > config/artifacts_version.txt
209
210             # Install VPP
211             export UBUNTU="trusty"
212             export RELEASE=".stable.1609"
213             rm /etc/apt/sources.list.d/99fd.io.list
214             echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io$RELEASE.ubuntu.$UBUNTU.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
215             apt-get update
216             apt-get install -y vpp vpp-dpdk-dkms vpp-lib vpp-dbg vpp-plugins vpp-dev
217             sleep 1
218
219             # Install VES
220             cd /opt/VES/bldjobs/
221             make clean
222             make
223             sleep 1
224
225             # Run instantiation script
226             cd /opt            
227             mv vlb.sh /etc/init.d
228             update-rc.d vlb.sh defaults
229             ./v_lb_init.sh
230
231   vlb_private_0_port:
232     type: OS::Neutron::Port
233     properties:
234       network: { get_resource: vlb_private_network }
235       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vlb_private_ip_0 }}]
236
237   vlb_private_1_port:
238     type: OS::Neutron::Port
239     properties:
240       network: { get_param: ecomp_private_net_id }
241       fixed_ips: [{"subnet": { get_param: ecomp_private_subnet_id }, "ip_address": { get_param: vlb_private_ip_1 }}]
242
243   vdns_0:
244     type: OS::Nova::Server
245     properties:
246       image: { get_param: vlb_image_name }
247       flavor: { get_param: vlb_flavor_name }
248       name: { get_param: vdns_name_0 }
249       key_name: { get_resource: my_keypair }
250       networks:
251         - network: { get_param: public_net_id }
252         - port: { get_resource: vdns_private_0_port }
253         - port: { get_resource: vdns_private_0_port }
254         - port: { get_resource: vdns_private_1_port }
255       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
256       user_data_format: RAW
257       user_data:
258         str_replace:
259           params:
260             __lb_oam_int__ : { get_param: vlb_private_ip_1 }
261             __lb_private_ipaddr__: { get_param: vlb_private_ip_0 }
262             __local_private_ipaddr__: { get_param: vdns_private_ip_0 }
263             __repo_url_blob__ : { get_param: repo_url_blob }
264             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
265             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
266           template: |
267             #!/bin/bash
268
269             LB_OAM_INT=__lb_oam_int__
270             LB_PRIVATE_IPADDR=__lb_private_ipaddr__
271             LOCAL_PRIVATE_IPADDR=__local_private_ipaddr__
272             REPO_URL_BLOB=__repo_url_blob__
273             REPO_URL_ARTIFACTS=__repo_url_artifacts__
274             DEMO_ARTIFACTS_VERSION=__demo_artifacts_version__
275
276             # Download required dependencies
277             add-apt-repository -y ppa:openjdk-r/ppa
278             apt-get update
279             apt-get install -y wget openjdk-8-jdk bind9 bind9utils bind9-doc apt-transport-https ca-certificates
280             apt-get install -y maven
281             sleep 1
282
283             # Download vDNS demo code for DNS Server
284             mkdir /opt/config
285             mkdir /opt/FDclient
286             cd /opt
287             
288             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/v_dns_init.sh
289             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/vdns.sh
290             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/dnsclient.sh
291             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/set_gre_tunnel.sh
292             
293             mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get -DremoteRepositories=$REPO_URL_ARTIFACTS -Dartifact=org.openecomp.demo.vnf.vlb:dns-client:$DEMO_ARTIFACTS_VERSION:jar -Dtransitive=false -Ddest=.
294
295             mv dns-client-$DEMO_ARTIFACTS_VERSION.jar /opt/FDclient/
296             mv dnsclient.sh /opt/FDclient/
297             mv set_gre_tunnel.sh /opt/FDclient/
298
299             chmod +x v_dns_init.sh
300             chmod +x vdns.sh
301             chmod +x /opt/FDclient/dnsclient.sh
302             chmod +x /opt/FDclient/set_gre_tunnel.sh
303
304             echo $LB_OAM_INT > config/lb_oam_int.txt
305             echo $LB_PRIVATE_IPADDR > config/lb_private_ipaddr.txt
306             echo $LOCAL_PRIVATE_IPADDR > config/local_private_ipaddr.txt
307             echo $DEMO_ARTIFACTS_VERSION > config/artifacts_version.txt
308
309             # Download Bind config files
310             cd /opt/config
311             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/db_dnsdemo_openecomp_org
312             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/named.conf.options
313             wget $REPO_URL_BLOB/org.openecomp.demo/vnfs/vlb/$DEMO_ARTIFACTS_VERSION/named.conf.local
314
315             # Configure Bind
316             modprobe ip_gre
317             mkdir /etc/bind/zones
318             sed -i "s/OPTIONS=.*/OPTIONS=\"-4 -u bind\"/g" /etc/default/bind9
319             mv db_dnsdemo_openecomp_org /etc/bind/zones/db.dnsdemo.openecomp.org
320             mv named.conf.options /etc/bind/
321             mv named.conf.local /etc/bind/
322             sleep 1
323
324             # Run instantiation script
325             cd /opt
326             mv vdns.sh /etc/init.d
327             update-rc.d vdns.sh defaults
328             ./v_dns_init.sh
329
330   vdns_private_0_port:
331     type: OS::Neutron::Port
332     properties:
333       network: { get_resource: vlb_private_network }
334       fixed_ips: [{"subnet": { get_resource: vlb_private_subnet }, "ip_address": { get_param: vdns_private_ip_0 }}]
335
336   vdns_private_1_port:
337     type: OS::Neutron::Port
338     properties:
339       network: { get_param: ecomp_private_net_id }
340       fixed_ips: [{"subnet": { get_param: ecomp_private_subnet_id }, "ip_address": { get_param: vdns_private_ip_1 }}]