74fa490b23ebb9800b9dd1cb1613e77473b07b60
[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   script_version:
126     type: string
127     label: Script version number
128     description: Version number of the scripts that install the vGW
129   nexus_artifact_repo:
130     type: string
131     description: Root URL for the Nexus repository for Maven artifacts.
132     default: "https://nexus.onap.org"
133   cloud_env:
134     type: string
135     label: Cloud environment
136     description: Cloud environment (e.g., openstack, rackspace)
137   mux_ip_addr:
138     type: string
139     label: vGMUX IP address
140     description: IP address of vGMUX
141   vg_vgmux_tunnel_vni:
142     type: number
143     label: vG-vGMUX tunnel vni
144     description: vni value of vG-vGMUX vxlan tunnel
145
146 #############
147 #           #
148 # RESOURCES #
149 #           #
150 #############
151
152 resources:
153
154   random-str:
155     type: OS::Heat::RandomString
156     properties:
157       length: 4
158
159   my_keypair:
160     type: OS::Nova::KeyPair
161     properties:
162       name:
163         str_replace:
164           template: base_rand
165           params:
166             base: { get_param: key_name }
167             rand: { get_resource: random-str }
168       public_key: { get_param: pub_key }
169       save_private_key: false
170
171   # Virtual GW Instantiation
172   vgw_private_0_port:
173     type: OS::Neutron::Port
174     properties:
175       network: { get_param: mux_gw_private_net_id }
176       fixed_ips: [{"subnet": { get_param: mux_gw_private_subnet_id }, "ip_address": { get_param: vgw_private_ip_0 }}]
177
178   vgw_private_1_port:
179     type: OS::Neutron::Port
180     properties:
181       network: { get_param: onap_private_net_id }
182       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vgw_private_ip_1 }}]
183
184   vgw_private_2_port:
185     type: OS::Neutron::Port
186     properties:
187       network: { get_param: cpe_public_net_id}
188       fixed_ips: [{"subnet": { get_param: cpe_public_subnet_id }}]
189       ##fixed_ips: [{"subnet": { get_param: cpe_public_subnet_id }, "ip_address": { get_param: vgw_private_ip_2 }}]
190
191   vgw_0:
192     type: OS::Nova::Server
193     properties:
194       image: { get_param: vcpe_image_name }
195       flavor: { get_param: vcpe_flavor_name }
196       name: { get_param: vgw_name_0 }
197       key_name: { get_resource: my_keypair }
198       networks:
199         - network: { get_param: public_net_id }
200         - port: { get_resource: vgw_private_0_port }
201         - port: { get_resource: vgw_private_1_port }
202         - port: { get_resource: vgw_private_2_port }
203       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
204       user_data_format: RAW
205       user_data:
206         str_replace:
207           params:
208             __mux_gw_private_net_ipaddr__ : { get_param: vgw_private_ip_0 }
209             __oam_ipaddr__ : { get_param: vgw_private_ip_1 }
210             __oam_cidr__ : { get_param: onap_private_net_cidr }
211             __cpe_public_net_cidr__ : { get_param: cpe_public_net_cidr }
212             __mux_gw_private_net_cidr__ : { get_param: mux_gw_private_net_cidr }
213             __script_version__ : { get_param: script_version }
214             __cloud_env__ : { get_param: cloud_env }
215             __mux_ip_addr__: { get_param: mux_ip_addr }
216             __vg_vgmux_tunnel_vni__: { get_param: vg_vgmux_tunnel_vni }
217             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
218           template: |
219             #!/bin/bash
220
221             # Create configuration files
222             mkdir /opt/config
223             echo "__oam_ipaddr__" > /opt/config/oam_ipaddr.txt
224             echo "__oam_cidr__" > /opt/config/oam_cidr.txt
225             echo "__cpe_public_net_cidr__" > /opt/config/cpe_public_net_cidr.txt
226             echo "__mux_gw_private_net_ipaddr__" > /opt/config/mux_gw_private_net_ipaddr.txt
227             echo "__mux_gw_private_net_cidr__" > /opt/config/mux_gw_private_net_cidr.txt
228             echo "__script_version__" > /opt/config/script_version.txt
229             echo "__cloud_env__" > /opt/config/cloud_env.txt
230             echo "__mux_ip_addr__" > /opt/config/mux_ip_addr.txt
231             echo "__vg_vgmux_tunnel_vni__" > /opt/config/vg_vgmux_tunnel_vni.txt
232             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
233
234             # Download and run install script
235             apt-get update
236             apt-get -y install unzip
237             if [[ "__script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
238             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=__script_version__" -o /opt/vcpe-scripts-__script_version__.zip
239             unzip -j /opt/vcpe-scripts-__script_version__.zip -d /opt v_gw_install.sh
240             cd /opt
241             chmod +x v_gw_install.sh
242             ./v_gw_install.sh
243