vCPE - move build template files to own directory
[demo.git] / heat / vCPE_build / vgmux / build_vcpe_vgmux.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 build vCPE Infrastructue Metro vGMUX
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   vgmux_name_0:
49     type: string
50     label: vGMUX name
51     description: Name of the vGMUX
52   vnf_id:
53     type: string
54     label: VNF ID
55     description: The VNF ID is provided by ONAP
56   vf_module_id:
57     type: string
58     label: vCPE module ID
59     description: The vCPE Module ID is provided by ONAP
60   dcae_collector_ip:
61     type: string
62     label: DCAE collector IP address
63     description: IP address of the DCAE collector
64   dcae_collector_port:
65     type: string
66     label: DCAE collector port
67     description: Port of the DCAE collector
68   key_name:
69     type: string
70     label: Key pair name
71     description: Public/Private key pair name
72   pub_key:
73     type: string
74     label: Public key
75     description: Public key to be installed on the compute instance
76   repo_url_artifacts:
77     type: string
78     label: Repository URL
79     description: URL of the repository that hosts the demo packages
80   script_version:
81     type: string
82     label: Script version number
83     description: Version number of the scripts that build the vGMUX
84   demo_artifacts_version:
85     type: string
86     label: Artifacts version used in demo vnfs
87     description: Artifacts (jar, tar.gz) version used in demo vnfs
88   nexus_artifact_repo:
89     type: string
90     description: Root URL for the Nexus repository for Maven artifacts.
91     default: "https://nexus.onap.org"
92   cloud_env:
93     type: string
94     label: Cloud environment
95     description: Cloud environment (e.g., openstack, rackspace)
96   vpp_source_repo_url:
97     type: string
98     label: VPP Source Git Repo
99     description: URL for VPP source codes
100   vpp_source_repo_release_tag:
101     type: string
102     label: VPP Source Git Release Tag
103     description: Git Tag for the VPP source codes
104   hc2vpp_source_repo_url:
105     type: string
106     label: Honeycomb Source Git Repo
107     description: URL for Honeycomb source codes
108   hc2vpp_source_repo_release_tag:
109     type: string
110     label: Honeycomb Source Git Release Tag
111     description: Git Tag for the Honeycomb source codes
112   vpp_patch_url:
113     type: string
114     label: VPP Patch URL
115     description: URL for VPP patch for vG-MUX
116   hc2vpp_patch_url:
117     type: string
118     label: Honeycomb Patch URL
119     description: URL for Honeycomb patch for vG-MUX
120   libevel_patch_url:
121     type: string
122     label: libevel Patch URL
123     description: URL for libevel patch for vG-MUX
124  # Compile_state parameter is added to provide backward compatibility for Beijing and Amsterdam releases
125   compile_state:
126     type: string
127     label: Compile State
128     description: State to compile code or not
129     default: "done"
130
131 #############
132 #           #
133 # RESOURCES #
134 #           #
135 #############
136
137 resources:
138
139   random-str:
140     type: OS::Heat::RandomString
141     properties:
142       length: 4
143
144   my_keypair:
145     type: OS::Nova::KeyPair
146     properties:
147       name:
148         str_replace:
149           template: base_rand
150           params:
151             base: { get_param: key_name }
152             rand: { get_resource: random-str }
153       public_key: { get_param: pub_key }
154       save_private_key: false
155
156
157   # Virtual GMUX Instantiation
158   vgmux_0:
159     type: OS::Nova::Server
160     properties:
161       image: { get_param: vcpe_image_name }
162       flavor: { get_param: vcpe_flavor_name }
163       name: { get_param: vgmux_name_0 }
164       key_name: { get_resource: my_keypair }
165       networks:
166         - network: { get_param: public_net_id }
167       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
168       user_data_format: RAW
169       user_data:
170         str_replace:
171           params:
172             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
173             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
174             __script_version__ : { get_param: script_version }
175             __cloud_env__ : { get_param: cloud_env }
176             __vpp_source_repo_url__ : { get_param: vpp_source_repo_url }
177             __vpp_source_repo_release_tag__ : { get_param: vpp_source_repo_release_tag }
178             __hc2vpp_source_repo_url__ : { get_param: hc2vpp_source_repo_url }
179             __hc2vpp_source_repo_release_tag__ : { get_param: hc2vpp_source_repo_release_tag }
180             __vpp_patch_url__ : { get_param: vpp_patch_url }
181             __hc2vpp_patch_url__ : { get_param: hc2vpp_patch_url }
182             __libevel_patch_url__ : { get_param: libevel_patch_url }
183             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
184             __compile_state__ : {get_param : compile_state}
185           template: |
186             #!/bin/bash
187
188             # Create configuration files
189             mkdir /opt/config
190             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
191             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
192             echo "__script_version__" > /opt/config/script_version.txt
193             echo "__cloud_env__" > /opt/config/cloud_env.txt
194             echo "__vpp_source_repo_url__" > /opt/config/vpp_source_repo_url.txt
195             echo "__vpp_source_repo_release_tag__" > /opt/config/vpp_source_repo_release_tag.txt
196             echo "__vpp_patch_url__" > /opt/config/vpp_patch_url.txt
197             echo "__hc2vpp_source_repo_url__" > /opt/config/hc2vpp_source_repo_url.txt
198             echo "__hc2vpp_source_repo_release_tag__" > /opt/config/hc2vpp_source_repo_release_tag.txt
199             echo "__hc2vpp_patch_url__" > /opt/config/hc2vpp_patch_url.txt
200             echo "__libevel_patch_url__" > /opt/config/libevel_patch_url.txt
201             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
202             echo "__compile_state__" > /opt/config/compile_state.txt
203
204             # Download and run install script
205             apt-get -y install unzip
206             if [[ "__script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
207             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
208             unzip -j /opt/vcpe-scripts-__script_version__.zip -d /opt v_gmux_build.sh
209             cd /opt
210             chmod +x v_gmux_build.sh
211             ./v_gmux_build.sh