e0330df449e24fb680ebe3b36f2565ba3b4362f7
[demo.git] / heat / vLB_CDS / vlb.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright (c) 2019 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 that deploys a vLB 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   int_private_net_id:
49     type: string
50     label: vLoadBalancer private network name or ID
51     description: Private network that connects vLoadBalancer with vDNSs
52   int_private_subnet_id:
53     type: string
54     label: vLoadBalancer private subnet name or ID
55     description: Private subnet of the network that connects vLoadBalancer with vDNSs
56   int_pktgen_private_net_id:
57     type: string
58     label: vPacketGen private network name or ID
59     description: Private network that connects vLoadBalancer with vPacketGen
60   int_pktgen_private_subnet_id:
61     type: string
62     label: vPacketGen private subnet name or ID
63     description: Private subnet of the 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_int_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_onap_private_ip_0:
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_int_pktgen_private_ip_0:
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_int_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_onap_private_ip_0:
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_int_pktgen_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_onap_private_ip_0:
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   vlb_0_mac_address:
113     type: string
114     label: vLB MAC address
115     description: MAC address of the vLB used by the vPacketGen VM
116   vpg_0_mac_address:
117     type: string
118     label: vPacketGen MAC address
119     description: MAC address of the vPacketGen used by the vLB VM
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   vlb_name_0:
129     type: string
130     label: vLoadBalancer name
131     description: Name of the vLoadBalancer
132   vnf_id:
133     type: string
134     label: VNF ID
135     description: The VNF ID is provided by ONAP
136   vnf_name:
137     type: string
138     label: VNF NAME
139     description: The VNF NAME 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   keypair:
153     type: string
154     label: Key pair name
155     description: Public/Private key pair name
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   sec_group:
176     type: string
177     description: ONAP Security Group
178
179 #############
180 #           #
181 # RESOURCES #
182 #           #
183 #############
184
185 resources:
186
187   # NETWORK_ROLE: private
188   # VM_TYPE: vlb
189   vlb_0_int_private_port_0:
190     type: OS::Neutron::Port
191     properties:
192       network: { get_param: int_private_net_id }
193       fixed_ips: [{"subnet": { get_param: int_private_subnet_id }, "ip_address": { get_param: vlb_int_private_ip_0 }}]
194       security_groups:
195       - { get_param: sec_group }
196
197   # NETWORK_ROLE: onap_private
198   # VM_TYPE: vlb
199   vlb_0_onap_private_port_0:
200     type: OS::Neutron::Port
201     properties:
202       network: { get_param: onap_private_net_id }
203       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vlb_onap_private_ip_0 }}]
204       security_groups:
205       - { get_param: sec_group }
206
207   # NETWORK_ROLE: pktgen_private
208   # VM_TYPE: vlb
209   vlb_0_int_pktgen_private_port_0:
210     type: OS::Neutron::Port
211     properties:
212       network: { get_param: int_pktgen_private_net_id }
213       fixed_ips: [{"subnet": { get_param: int_pktgen_private_subnet_id }, "ip_address": { get_param: vlb_int_pktgen_private_ip_0 }}]
214       mac_address: { get_param: vlb_0_mac_address }
215       security_groups:
216       - { get_param: sec_group }
217
218   # VM_TYPE: vlb
219   vlb_server_0:
220     type: OS::Nova::Server
221     properties:
222       image: { get_param: vlb_image_name }
223       flavor: { get_param: vlb_flavor_name }
224       name: { get_param: vlb_name_0 }
225       key_name: { get_param: keypair }
226       networks:
227         - network: { get_param: public_net_id }
228         - port: { get_resource: vlb_0_int_private_port_0 }
229         - port: { get_resource: vlb_0_onap_private_port_0 }
230         - port: { get_resource: vlb_0_int_pktgen_private_port_0 }
231       metadata:
232         vnf_id: { get_param: vnf_id }
233         vf_module_id: { get_param: vf_module_id }
234         vnf_name: { get_param: vnf_name }
235       user_data_format: RAW
236       user_data:
237         str_replace:
238           params:
239             __dcae_collector_ip__: { get_param: dcae_collector_ip }
240             __dcae_collector_port__: { get_param: dcae_collector_port }
241             __ip_to_dns_net__: { get_param: vlb_int_private_ip_0 }
242             __ip_to_pktgen_net__: { get_param: vlb_int_pktgen_private_ip_0 }
243             __oam_vpktgen_ip__: { get_param: vpg_onap_private_ip_0 }
244             __oam_vdns_ip__: { get_param: vdns_onap_private_ip_0 }
245             __vip__: { get_param: vip }
246             __gre_ipaddr__: { get_param: gre_ipaddr }
247             __pktgen_ipaddr__: { get_param: vpg_int_pktgen_private_ip_0 }
248             __vdns_ipaddr__: { get_param: vdns_int_private_ip_0 }
249             __oam_private_ipaddr__: { get_param: vlb_onap_private_ip_0 }
250             __demo_artifacts_version__: { get_param: demo_artifacts_version }
251             __nb_api_version__: { get_param: nb_api_version }
252             __install_script_version__: { get_param: install_script_version }
253             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
254             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
255             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
256             __pktgen_mac__: { get_param: vpg_0_mac_address }
257             __cloud_env__: { get_param: cloud_env }
258             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
259           template: |
260             #!/bin/bash
261
262             # Create configuration files
263             mkdir /opt/config
264             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
265             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
266             echo "__ip_to_dns_net__" > /opt/config/ip_to_dns_net.txt
267             echo "__ip_to_pktgen_net__" > /opt/config/ip_to_pktgen_net.txt
268             echo "__oam_vpktgen_ip__" > /opt/config/oam_vpktgen_ip.txt
269             echo "__oam_vdns_ip__" > /opt/config/oam_vdns_ip.txt
270             echo "__vip__" > /opt/config/vip.txt
271             echo "__gre_ipaddr__" > /opt/config/gre_ipaddr.txt
272             echo "__pktgen_ipaddr__" > /opt/config/pktgen_ipaddr.txt
273             echo "__vdns_ipaddr__" > /opt/config/vdns_ipaddr.txt
274             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
275             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
276             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
277             echo "__install_script_version__" > /opt/config/install_script_version.txt
278             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
279             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
280             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
281             echo "__pktgen_mac__" > /opt/config/pktgen_mac.txt
282             echo "__cloud_env__" > /opt/config/cloud_env.txt
283             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
284
285             # Download and run install script
286             apt-get update
287             apt-get -y install unzip
288             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
289             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
290             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_lb_install.sh
291             cd /opt
292             chmod +x v_lb_install.sh
293             ./v_lb_install.sh