59cc29118cc0e9568509e75f3c164c59b629bd74
[demo.git] / heat / vCPE_build / vbng / build_vcpe_vbng.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 virtual Broadband Network Gateway (vBNG)
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   vbng_name_0:
49     type: string
50     label: vBNG name
51     description: Name of the vBNG
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   key_name:
61     type: string
62     label: Key pair name
63     description: Public/Private key pair name
64   pub_key:
65     type: string
66     label: Public key
67     description: Public key to be installed on the compute instance
68   repo_url_artifacts:
69     type: string
70     label: Repository URL
71     description: URL of the repository that hosts the demo packages
72   script_version:
73     type: string
74     label: Build script version number
75     description: Version number of the scripts that build the vFW demo app
76   demo_artifacts_version:
77     type: string
78     label: Artifacts version used in demo vnfs
79     description: Artifacts (jar, tar.gz) version used in demo vnfs
80   nexus_artifact_repo:
81     type: string
82     description: Root URL for the Nexus repository for Maven artifacts.
83     default: "https://nexus.onap.org"
84   cloud_env:
85     type: string
86     label: Cloud environment
87     description: Cloud environment (e.g., openstack, rackspace)
88   vpp_source_repo_url:
89     type: string
90     label: VPP Source Git Repo
91     description: URL for VPP source codes
92   vpp_source_repo_release_tag:
93     type: string
94     label: VPP Source Git Release Tag
95     description: Git Release Tag for the VPP source codes
96   vpp_patch_url:
97     type: string
98     label: VPP Patch URL
99     description: URL for VPP patch for vBNG
100   compile_state:
101     type: string
102     label: Compile State
103     description: State to compile code or not; included for backwards compatibility
104     default: "done"
105
106 #############
107 #           #
108 # RESOURCES #
109 #           #
110 #############
111
112 resources:
113
114   random-str:
115     type: OS::Heat::RandomString
116     properties:
117       length: 4
118
119   my_keypair:
120     type: OS::Nova::KeyPair
121     properties:
122       name:
123         str_replace:
124           template: base_rand
125           params:
126             base: { get_param: key_name }
127             rand: { get_resource: random-str }
128       public_key: { get_param: pub_key }
129       save_private_key: false
130
131
132   vbng_0:
133     type: OS::Nova::Server
134     properties:
135       image: { get_param: vcpe_image_name }
136       flavor: { get_param: vcpe_flavor_name }
137       name: { get_param: vbng_name_0 }
138       key_name: { get_resource: my_keypair }
139       networks:
140         - network: { get_param: public_net_id }
141       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
142       user_data_format: RAW
143       user_data:
144         str_replace:
145           params:
146             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
147             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
148             __script_version__ : { get_param: script_version }
149             __cloud_env__ : { get_param: cloud_env }
150             __vpp_source_repo_url__ : { get_param: vpp_source_repo_url }
151             __vpp_source_repo_release_tag__ : { get_param: vpp_source_repo_release_tag }
152             __vpp_patch_url__ : { get_param: vpp_patch_url }
153             __compile_state__ : { get_param: compile_state }
154             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
155           template: |
156             #!/bin/bash
157
158             # Create configuration files
159             mkdir /opt/config
160             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
161             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
162             echo "__script_version__" > /opt/config/script_version.txt
163             echo "__cloud_env__" > /opt/config/cloud_env.txt
164             echo "__vpp_source_repo_url__" > /opt/config/vpp_source_repo_url.txt
165             echo "__vpp_source_repo_release_tag__" > /opt/config/vpp_source_repo_release_tag.txt
166             echo "__vpp_patch_url__" > /opt/config/vpp_patch_url.txt
167             echo "__compile_state__" > /opt/config/compile_state.txt
168             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
169
170             # Download and run install script
171             apt-get -y install unzip
172             if [[ "__script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
173             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
174             unzip -j /opt/vcpe-scripts-__script_version__.zip -d /opt v_bng_build.sh
175             cd /opt
176             chmod +x v_bng_build.sh
177             ./v_bng_build.sh