0af21ef72d75b3495597725aa0cb0711a3cf5d8f
[demo.git] / heat / vCPE / vbrgemu / base_vcpe_vbrgemu.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 vBRG Emulator (vBRGEMU)
28
29 #######################################################################
30 #                                                                     #
31 # PARAMETERS                                                                                                #
32 #                                                                     #
33 #     0_port should get IP address from DHCP discover through vBNG    #
34 #     DCAE is not monitoring the BRGEMULATOR                          #
35 #######################################################################
36
37 parameters:
38   vcpe_image_name:
39     type: string
40     label: Image name or ID
41     description: Image to be used for compute instance
42   vcpe_flavor_name:
43     type: string
44     label: Flavor
45     description: Type of instance (flavor) to be used
46   public_net_id:
47     type: string
48     label: Public network name or ID
49     description: Public network that enables remote connection to VNF
50   vbrgemu_bng_private_net_id:
51     type: string
52     label: vBNG private network name or ID
53     description: Private network that connects vBRGEMU to vBNG
54   vbrgemu_bng_private_subnet_id:
55     type: string
56     label: vBNG private sub-network name or ID
57     description: vBNG private sub-network name or ID
58   vbrgemu_bng_private_net_cidr:
59     type: string
60     label: vBNG IN private network CIDR
61     description: The CIDR of the input side of vBNG private network
62  # vbrgemu_private_net_id:
63  #   type: string
64  #   label: vBRGEMU Home private network name or ID
65  #   description: Private network that connects vBRGEMU to local devices
66   #vbrgemu_private_net_cidr:
67   #  type: string
68   #  label: vBRGEMU Home private network CIDR
69   #  description: The CIDR of the input side of vBRGEMU Home private network
70 ##  vbrgemu_private_ip_0:
71 ##    type: string
72 ##    label: vGW private IP address
73 ##    description: Private IP address towards the BRGEMU-BNG network
74 ##    VPP will use DHCP so does not need to be provided by preload
75   #vbrgemu_private_ip_1:
76   #  type: string
77   #  label: vGW private IP address
78   #  description: Private IP address towards the BRGEMU private network
79   vbrgemu_name_0:
80     type: string
81     label: vGW  name
82     description: Name of the vGW
83   vnf_id:
84     type: string
85     label: VNF ID
86     description: The VNF ID is provided by ONAP
87   vf_module_id:
88     type: string
89     label: vCPE module ID
90     description: The vCPE Module ID is provided by ONAP
91   key_name:
92     type: string
93     label: Key pair name
94     description: Public/Private key pair name
95   pub_key:
96     type: string
97     label: Public key
98     description: Public key to be installed on the compute instance
99   repo_url_artifacts:
100     type: string
101     label: Repository URL
102     description: URL of the repository that hosts the demo packages
103   install_script_version:
104     type: string
105     label: Installation script version number
106     description: Version number of the scripts that install the vFW demo app
107   demo_artifacts_version:
108     type: string
109     label: Artifacts version used in demo vnfs
110     description: Artifacts (jar, tar.gz) version used in demo vnfs
111   nexus_artifact_repo:
112     type: string
113     description: Root URL for the Nexus repository for Maven artifacts.
114     default: "https://nexus.onap.org"
115   cloud_env:
116     type: string
117     label: Cloud environment
118     description: Cloud environment (e.g., openstack, rackspace)
119   vpp_source_repo_url:
120     type: string
121     label: VPP Source Git Repo
122     description: URL for VPP source codes
123   vpp_source_repo_release_tag:
124     type: string
125     label: VPP Source Git Release Tag
126     description: Git Release Tag for the VPP source codes
127   hc2vpp_source_repo_url:
128     type: string
129     label: Honeycomb Source Git Repo
130     description: URL for Honeycomb source codes
131   hc2vpp_source_repo_release_tag:
132     type: string
133     label: Honeycomb Source Git Release Tag
134     description: Git Release Tag for the Honeycomb source codes
135   vpp_patch_url:
136     type: string
137     label: VPP Patch URL
138     description: URL for VPP patch for vBRG Emulator
139   sdnc_ip:
140     type: string
141     label: SDNC ip address
142     description: SDNC ip address used to set NAT
143   compile_state:
144     type: string
145     label: Compile State
146     description: State to compile code or not
147
148
149 #############
150 #           #
151 # RESOURCES #
152 #           #
153 #############
154
155 resources:
156
157   random-str:
158     type: OS::Heat::RandomString
159     properties:
160       length: 4
161
162   my_keypair:
163     type: OS::Nova::KeyPair
164     properties:
165       name:
166         str_replace:
167           template: base_rand
168           params:
169             base: { get_param: key_name }
170             rand: { get_resource: random-str }
171       public_key: { get_param: pub_key }
172       save_private_key: false
173
174   #vbrgemu_private_network:
175   #  type: OS::Neutron::Net
176   #  properties:
177   #    name: { get_param: vbrgemu_private_net_id }
178
179   #vbrgemu_private_subnet:
180   #  type: OS::Neutron::Subnet
181   #  properties:
182   #    name: { get_param: vbrgemu_private_net_id }
183   #    network_id: { get_resource: vbrgemu_private_network }
184   #    cidr: { get_param: vbrgemu_private_net_cidr }
185
186   # Virtual BRG Emulator Instantiation
187   # 0_port should get IP address from DHCP discover through vBNG once the VNF is running
188   vbrgemu_private_0_port:
189     type: OS::Neutron::Port
190     properties:
191       network: { get_param: vbrgemu_bng_private_net_id }
192       fixed_ips: [{"subnet": { get_param: vbrgemu_bng_private_subnet_id }}]
193   ##    fixed_ips: [{"subnet": { get_param: vbrgemu_bng_private_subnet_id }, "ip_address": { get_param: vbrgemu_private_ip_0 }}]
194
195   #vbrgemu_private_1_port:
196   #  type: OS::Neutron::Port
197   #  properties:
198   #    network: { get_resource: vbrgemu_private_network }
199   #    fixed_ips: [{"subnet": { get_resource: vbrgemu_private_subnet }, "ip_address": { get_param: vbrgemu_private_ip_1 }}]
200
201   vbrgemu_0:
202     type: OS::Nova::Server
203     properties:
204       image: { get_param: vcpe_image_name }
205       flavor: { get_param: vcpe_flavor_name }
206       name: { get_param: vbrgemu_name_0 }
207       key_name: { get_resource: my_keypair }
208       networks:
209         - network: { get_param: public_net_id }
210         - port: { get_resource: vbrgemu_private_0_port }
211         #- port: { get_resource: vbrgemu_private_1_port }
212       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
213       user_data_format: RAW
214       user_data:
215         str_replace:
216           params:
217            # __brgemu_net_ipaddr__: { get_param: vbrgemu_private_ip_1 }
218            # __brgemu_cidr__: { get_param: vbrgemu_private_net_cidr }
219             __brgemu_bng_private_net_cidr__: { get_param: vbrgemu_bng_private_net_cidr }
220             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
221             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
222             __install_script_version__ : { get_param: install_script_version }
223             __cloud_env__ : { get_param: cloud_env }
224             __vpp_source_repo_url__ : { get_param: vpp_source_repo_url }
225             __vpp_source_repo_release_tag__ : { get_param: vpp_source_repo_release_tag }
226             __hc2vpp_source_repo_url__ : { get_param: hc2vpp_source_repo_url }
227             __hc2vpp_source_repo_release_tag__ : { get_param: hc2vpp_source_repo_release_tag }
228             __vpp_patch_url__ : { get_param: vpp_patch_url }
229             __sdnc_ip__ : { get_param: sdnc_ip }
230             __compile_state__ : { get_param: compile_state }
231             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
232           template: |
233             #!/bin/bash
234
235             # Create configuration files
236             mkdir /opt/config
237             #echo "__brgemu_net_ipaddr__" > /opt/config/brgemu_net_ipaddr.txt
238             #echo "__brgemu_cidr__" > /opt/config/brgemu_net_cidr.txt
239             echo "__brgemu_bng_private_net_cidr__" > /opt/config/brgemu_bng_private_net_cidr.txt
240             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
241             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
242             echo "__install_script_version__" > /opt/config/install_script_version.txt
243             echo "__cloud_env__" > /opt/config/cloud_env.txt
244             echo "__vpp_source_repo_url__" > /opt/config/vpp_source_repo_url.txt
245             echo "__vpp_source_repo_release_tag__" > /opt/config/vpp_source_repo_release_tag.txt
246             echo "__hc2vpp_source_repo_url__" > /opt/config/hc2vpp_source_repo_url.txt
247             echo "__hc2vpp_source_repo_release_tag__" > /opt/config/hc2vpp_source_repo_release_tag.txt
248             echo "__vpp_patch_url__" > /opt/config/vpp_patch_url.txt
249             echo "__sdnc_ip__" > /opt/config/sdnc_ip.txt
250             echo "__compile_state__" > /opt/config/compile_state.txt
251             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
252
253             # Download and run install script
254             apt-get -y install unzip
255             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
256             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
257             unzip -j /opt/vcpe-scripts-__install_script_version__.zip -d /opt v_brgemu_install.sh
258             cd /opt
259             chmod +x v_brgemu_install.sh
260             ./v_brgemu_install.sh