0847b69d27232be1530b080c68f594e006bfa58c
[demo.git] / heat / vCPE / vgw / base_vcpe_vgw.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright 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 vCPE vGateway (vG)
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   vcpe_image_name:
37     type: string
38     label: Image name or ID
39     description: Image to be used for compute instance
40   vcpe_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   mux_gw_private_net_id:
49     type: string
50     label: vGMUX private network name or ID
51     description: Private network that connects vGMUX to vGWs
52   mux_gw_private_subnet_id:
53     type: string
54     label: vGMUX private sub-network name or ID
55     description: vGMUX private sub-network name or ID
56   mux_gw_private_net_cidr:
57     type: string
58     label: vGMUX private network CIDR
59     description: The CIDR of the vGMUX private network
60   onap_private_net_id:
61     type: string
62     label: ONAP management network name or ID
63     description: Private network that connects ONAP components and the VNF
64   onap_private_subnet_id:
65     type: string
66     label: ONAP management sub-network name or ID
67     description: Private sub-network that connects ONAP components and the VNF
68   onap_private_net_cidr:
69     type: string
70     label: ONAP private network CIDR
71     description: The CIDR of the protected private network
72   cpe_public_net_id:
73     type: string
74     label: vCPE network that emulates internetmanagement name or ID
75     description: Private network that connects vGW to emulated internet
76   cpe_public_subnet_id:
77     type: string
78     label: vCPE Public subnet
79     description: vCPE Public subnet
80   cpe_public_net_cidr:
81     type: string
82     label: vCPE public network CIDR
83     description: The CIDR of the vCPE public
84   vgw_private_ip_0:
85     type: string
86     label: vGW private IP address towards the vGMUX
87     description: Private IP address that is assigned to the vGW to communicate with vGMUX
88   vgw_private_ip_1:
89     type: string
90     label: vGW private IP address towards the ONAP management network
91     description: Private IP address that is assigned to the vGW to communicate with ONAP components
92   ## VPP will use DHCP to get the vgw_private_ip_2 on the CPE_PUBLIC  subnet
93   #vgw_private_ip_2:
94   #  type: string
95   #  label: vGW private IP address towards the vCPE public network
96   #  description: Private IP address that is assigned to the vGW to communicate with vCPE public network
97   vgw_name_0:
98     type: string
99     label: vGW  name
100     description: Name of the vGW
101   vnf_id:
102     type: string
103     label: VNF ID
104     description: The VNF ID is provided by ONAP
105   vf_module_id:
106     type: string
107     label: vCPE module ID
108     description: The vCPE Module ID is provided by ONAP
109   dcae_collector_ip:
110     type: string
111     label: DCAE collector IP address
112     description: IP address of the DCAE collector
113   dcae_collector_port:
114     type: string
115     label: DCAE collector port
116     description: Port of the DCAE collector
117   key_name:
118     type: string
119     label: Key pair name
120     description: Public/Private key pair name
121   pub_key:
122     type: string
123     label: Public key
124     description: Public key to be installed on the compute instance
125   repo_url_artifacts:
126     type: string
127     label: Repository URL
128     description: URL of the repository that hosts the demo packages
129   install_script_version:
130     type: string
131     label: Installation script version number
132     description: Version number of the scripts that install the vFW demo app
133   demo_artifacts_version:
134     type: string
135     label: Artifacts version used in demo vnfs
136     description: Artifacts (jar, tar.gz) version used in demo vnfs
137   nexus_artifact_repo:
138     type: string
139     description: Root URL for the Nexus repository for Maven artifacts.
140     default: "https://nexus.onap.org"
141   cloud_env:
142     type: string
143     label: Cloud environment
144     description: Cloud environment (e.g., openstack, rackspace)
145   vpp_source_repo_url:
146     type: string
147     label: VPP Source Git Repo
148     description: URL for VPP source codes
149   vpp_source_repo_release_tag:
150     type: string
151     label: VPP Source Git Release tag
152     description: Git release tag for the VPP source codes
153   hc2vpp_source_repo_url:
154     type: string
155     label: Honeycomb Source Git Repo
156     description: URL for Honeycomb source codes
157   hc2vpp_source_repo_release_tag:
158     type: string
159     label: Honeycomb Source Git release tag
160     description: Git release tag for the Honeycomb source codes
161   mux_ip_addr:
162     type: string
163     label: vGMUX IP address
164     description: IP address of vGMUX
165   vg_vgmux_tunnel_vni:
166     type: number
167     label: vG-vGMUX tunnel vni
168     description: vni value of vG-vGMUX vxlan tunnel
169
170 #############
171 #           #
172 # RESOURCES #
173 #           #
174 #############
175
176 resources:
177
178   random-str:
179     type: OS::Heat::RandomString
180     properties:
181       length: 4
182
183   my_keypair:
184     type: OS::Nova::KeyPair
185     properties:
186       name:
187         str_replace:
188           template: base_rand
189           params:
190             base: { get_param: key_name }
191             rand: { get_resource: random-str }
192       public_key: { get_param: pub_key }
193       save_private_key: false
194
195   # Virtual GW Instantiation
196   vgw_private_0_port:
197     type: OS::Neutron::Port
198     properties:
199       network: { get_param: mux_gw_private_net_id }
200       fixed_ips: [{"subnet": { get_param: mux_gw_private_subnet_id }, "ip_address": { get_param: vgw_private_ip_0 }}]
201
202   vgw_private_1_port:
203     type: OS::Neutron::Port
204     properties:
205       network: { get_param: onap_private_net_id }
206       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vgw_private_ip_1 }}]
207
208   vgw_private_2_port:
209     type: OS::Neutron::Port
210     properties:
211       network: { get_param: cpe_public_net_id}
212       fixed_ips: [{"subnet": { get_param: cpe_public_subnet_id }}]
213       ##fixed_ips: [{"subnet": { get_param: cpe_public_subnet_id }, "ip_address": { get_param: vgw_private_ip_2 }}]
214
215   vgw_0:
216     type: OS::Nova::Server
217     properties:
218       image: { get_param: vcpe_image_name }
219       flavor: { get_param: vcpe_flavor_name }
220       name: { get_param: vgw_name_0 }
221       key_name: { get_resource: my_keypair }
222       networks:
223         - network: { get_param: public_net_id }
224         - port: { get_resource: vgw_private_0_port }
225         - port: { get_resource: vgw_private_1_port }
226         - port: { get_resource: vgw_private_2_port }
227       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
228       user_data_format: RAW
229       user_data:
230         str_replace:
231           params:
232             __mux_gw_private_net_ipaddr__ : { get_param: vgw_private_ip_0 }
233             __oam_ipaddr__ : { get_param: vgw_private_ip_1 }
234             __oam_cidr__ : { get_param: onap_private_net_cidr }
235             __cpe_public_net_cidr__ : { get_param: cpe_public_net_cidr }
236             __mux_gw_private_net_cidr__ : { get_param: mux_gw_private_net_cidr }
237             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
238             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
239             __install_script_version__ : { get_param: install_script_version }
240             __cloud_env__ : { get_param: cloud_env }
241             __vpp_source_repo_url__ : { get_param: vpp_source_repo_url }
242             __vpp_source_repo_release_tag__ : { get_param: vpp_source_repo_release_tag }
243             __hc2vpp_source_repo_url__ : { get_param: hc2vpp_source_repo_url }
244             __hc2vpp_source_repo_release_tag__ : { get_param: hc2vpp_source_repo_release_tag }
245             __mux_ip_addr__: { get_param: mux_ip_addr }
246             __vg_vgmux_tunnel_vni__: { get_param: vg_vgmux_tunnel_vni }
247             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
248           template: |
249             #!/bin/bash
250
251             # Create configuration files
252             mkdir /opt/config
253             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
254             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
255             echo "__cpe_public_net_cidr__" > /opt/config/cpe_public_net_cidr.txt
256             echo "__mux_gw_private_net_ipaddr__" > /opt/config/mux_gw_private_net_ipaddr.txt
257             echo "__mux_gw_private_net_cidr__" > /opt/config/mux_gw_private_net_cidr.txt
258             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
259             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
260             echo "__install_script_version__" > /opt/config/install_script_version.txt
261             echo "__cloud_env__" > /opt/config/cloud_env.txt
262             echo "__vpp_source_repo_url__" > /opt/config/vpp_source_repo_url.txt
263             echo "__vpp_source_repo_release_tag__" > /opt/config/vpp_source_repo_release_tag.txt
264             echo "__hc2vpp_source_repo_url__" > /opt/config/hc2vpp_source_repo_url.txt
265             echo "__hc2vpp_source_repo_release_tag__" > /opt/config/hc2vpp_source_repo_release_tag.txt
266             echo "__mux_ip_addr__" > /opt/config/mux_ip_addr.txt
267             echo "__vg_vgmux_tunnel_vni__" > /opt/config/vg_vgmux_tunnel_vni.txt
268             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
269
270             # Download and run install script
271             apt-get -y install unzip
272             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
273             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vcpe&a=vcpe-scripts&e=zip&v=__install_script_version__" -o /opt/vcpe-scripts-__install_script_version__.zip
274             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_gw_install.sh
275             cd /opt
276             chmod +x v_gw_install.sh
277             ./v_gw_install.sh
278