Fix spacing issues in YAML files in heat
[demo.git] / heat / vCPE_build / vgw / build_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 build 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   vgw_name_0:
49     type: string
50     label: vGW  name
51     description: Name of the vGW
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   script_version:
77     type: string
78     label: Script version number
79     description: Version number of the scripts that build the vGW
80   demo_artifacts_version:
81     type: string
82     label: Artifacts version used in demo vnfs
83     description: Artifacts (jar, tar.gz) version used in demo vnfs
84   nexus_artifact_repo:
85     type: string
86     description: Root URL for the Nexus repository for Maven artifacts.
87     default: "https://nexus.onap.org"
88   cloud_env:
89     type: string
90     label: Cloud environment
91     description: Cloud environment (e.g., openstack, rackspace)
92   vpp_source_repo_url:
93     type: string
94     label: VPP Source Git Repo
95     description: URL for VPP source codes
96   vpp_source_repo_release_tag:
97     type: string
98     label: VPP Source Git Release tag
99     description: Git release tag for the VPP source codes
100   hc2vpp_source_repo_url:
101     type: string
102     label: Honeycomb Source Git Repo
103     description: URL for Honeycomb source codes
104   hc2vpp_source_repo_release_tag:
105     type: string
106     label: Honeycomb Source Git release tag
107     description: Git release tag for the Honeycomb source codes
108   # Compile_state parameter is added to provide backward compatibility for Beijing and Amsterdam releases
109   compile_state:
110     type: string
111     label: Compile State
112     description: State to compile code or not
113     default: "done"
114
115 #############
116 #           #
117 # RESOURCES #
118 #           #
119 #############
120
121 resources:
122
123   random-str:
124     type: OS::Heat::RandomString
125     properties:
126       length: 4
127
128   my_keypair:
129     type: OS::Nova::KeyPair
130     properties:
131       name:
132         str_replace:
133           template: base_rand
134           params:
135             base: { get_param: key_name }
136             rand: { get_resource: random-str }
137       public_key: { get_param: pub_key }
138       save_private_key: false
139
140   # Virtual GW Instantiation
141
142   vgw_0:
143     type: OS::Nova::Server
144     properties:
145       image: { get_param: vcpe_image_name }
146       flavor: { get_param: vcpe_flavor_name }
147       name: { get_param: vgw_name_0 }
148       key_name: { get_resource: my_keypair }
149       networks:
150         - network: { get_param: public_net_id }
151       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
152       user_data_format: RAW
153       user_data:
154         str_replace:
155           params:
156             __demo_artifacts_version__: { get_param: demo_artifacts_version }
157             __script_version__: { get_param: script_version }
158             __cloud_env__: { get_param: cloud_env }
159             __vpp_source_repo_url__: { get_param: vpp_source_repo_url }
160             __vpp_source_repo_release_tag__: { get_param: vpp_source_repo_release_tag }
161             __hc2vpp_source_repo_url__: { get_param: hc2vpp_source_repo_url }
162             __hc2vpp_source_repo_release_tag__: { get_param: hc2vpp_source_repo_release_tag }
163             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
164             __compile_state__: {get_param: compile_state}
165           template: |
166             #!/bin/bash
167
168             # Create configuration files
169             mkdir /opt/config
170             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
171             echo "__script_version__" > /opt/config/script_version.txt
172             echo "__cloud_env__" > /opt/config/cloud_env.txt
173             echo "__vpp_source_repo_url__" > /opt/config/vpp_source_repo_url.txt
174             echo "__vpp_source_repo_release_tag__" > /opt/config/vpp_source_repo_release_tag.txt
175             echo "__hc2vpp_source_repo_url__" > /opt/config/hc2vpp_source_repo_url.txt
176             echo "__hc2vpp_source_repo_release_tag__" > /opt/config/hc2vpp_source_repo_release_tag.txt
177             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
178             echo "__compile_state__" > /opt/config/compile_state.txt
179
180             # Download and run install script
181             apt-get update
182             apt-get -y install unzip
183             if [[ "__script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
184             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
185             unzip -j /opt/vcpe-scripts-__script_version__.zip -d /opt v_gw_build.sh
186             cd /opt
187             chmod +x v_gw_build.sh
188             ./v_gw_build.sh