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