75e7c7a717f560bfe761515e5ff793d4e72515cc
[demo.git] / heat / vFWDT / vPKG / base_vpkg.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
7 # Copyright (c) 2018 Orange Intellectual Property. All rights reserved.
8 #
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #        http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20 #==================LICENSE_END============================================
21 #
22 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 #
24 ##########################################################################
25
26 heat_template_version: 2013-05-23
27
28 description: Customized Heat template that deploys the vFirewall Traffic Generator demo app for ONAP
29
30 ##############
31 #            #
32 # PARAMETERS #
33 #            #
34 ##############
35
36 parameters:
37   image_name:
38     type: string
39     label: Image name or ID
40     description: Image to be used for compute instance
41   flavor_name:
42     type: string
43     label: Flavor
44     description: Type of instance (flavor) to be used
45   public_net_id:
46     type: string
47     label: Public network name or ID
48     description: Public network that enables remote connection to VNF
49   unprotected_private_net_id:
50     type: string
51     label: Unprotected private network name or ID
52     description: Private network that connects vPacketGenerator with vFirewall
53   unprotected_private_subnet_id:
54     type: string
55     label: Unprotected private sub-network name or ID
56     description: Private subnetwork for the unprotected network
57   unprotected_private_net_cidr:
58     type: string
59     label: Unprotected private network CIDR
60     description: The CIDR of the unprotected private network
61   protected_private_net_id:
62     type: string
63     label: Protected private network name or ID
64     description: Private network that connects vFirewall with vSink
65   protected_private_subnet_id:
66     type: string
67     label: Protected private subnetwork name or ID
68     description: Private subnetwork of the unprotected network
69   protected_private_net_cidr:
70     type: string
71     label: Protected private network CIDR
72     description: The CIDR of the protected private network
73   onap_private_net_id:
74     type: string
75     label: ONAP management network name or ID
76     description: Private network that connects ONAP components and the VNF
77   onap_private_subnet_id:
78     type: string
79     label: ONAP management sub-network name or ID
80     description: Private sub-network that connects ONAP components and the VNF
81   onap_private_net_cidr:
82     type: string
83     label: ONAP private network CIDR
84     description: The CIDR of the protected private network
85   ext_private_net_id:
86     type: string
87     label: external private network name or ID
88     description: Private network that enables connection to the public network
89   ext_private_subnet_id:
90     type: string
91     label: External private subnetwork name or ID
92     description: Private subnetwork that enables connection to the public network
93   ext_private_net_cidr:
94     type: string
95     label: External private network CIDR
96     description: The CIDR of the external private network
97   vfw_private_ip_0:
98     type: string
99     label: vFirewall private IP address towards the unprotected network
100     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator
101   vsn_private_ip_0:
102     type: string
103     label: vSink private IP address towards the protected network
104     description: Private IP address that is assigned to the vSink to communicate with the vFirewall
105   vpg_private_ip_0:
106     type: string
107     label: vPacketGenerator private IP address towards the unprotected network
108     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall
109   vpg_private_ip_1:
110     type: string
111     label: vPacketGenerator private IP address towards the ONAP management network
112     description: Private IP address that is assigned to the vPacketGenerator to communicate with ONAP components
113   vpg_private_ip_2:
114     type: string
115     label: vPacketGenerator private IP address towards public network
116     description: Private IP address that is assigned to the vPacketGenerator to communicate with internet
117   vpg_name_0:
118     type: string
119     label: vPacketGenerator name
120     description: Name of the vPacketGenerator
121   vnf_id:
122     type: string
123     label: VNF ID
124     description: The VNF ID is provided by ONAP
125   vf_module_id:
126     type: string
127     label: vPNG Traffic Generator module ID
128     description: The vPNG Module ID is provided by ONAP
129   key_name:
130     type: string
131     label: Key pair name
132     description: Public/Private key pair name
133   pub_key:
134     type: string
135     label: Public key
136     description: Public key to be installed on the compute instance
137   nexus_artifact_repo:
138     type: string
139     description: Root URL for the Nexus repository for Maven artifacts.
140   install_script_version:
141     type: string
142     label: Installation script version number
143     description: Version number of the scripts that install the vFW demo app
144   demo_artifacts_version:
145     type: string
146     label: Artifacts version used in demo vnfs
147     description: Artifacts (jar, tar.gz) version used in demo vnfs
148   cloud_env:
149     type: string
150     label: Cloud environment
151     description: Cloud environment (e.g., openstack, rackspace)
152   sec_group:
153     type: string
154     description: ONAP Security Group
155
156 #############
157 #           #
158 # RESOURCES #
159 #           #
160 #############
161
162 resources:
163   random-str:
164     type: OS::Heat::RandomString
165     properties:
166       length: 4
167
168   my_keypair:
169     type: OS::Nova::KeyPair
170     properties:
171       name:
172         str_replace:
173           template: base_rand
174           params:
175             base: { get_param: key_name }
176             rand: { get_resource: random-str }
177       public_key: { get_param: pub_key }
178       save_private_key: false
179
180
181   unprotected_private_network:
182     type: OS::Neutron::Net
183     properties:
184       name: { get_param: unprotected_private_net_id }
185
186   unprotected_private_subnet:
187     type: OS::Neutron::Subnet
188     properties:
189       name: { get_param: unprotected_private_subnet_id }
190       network_id: { get_resource: unprotected_private_network }
191       cidr: { get_param: unprotected_private_net_cidr }
192
193   protected_private_network:
194     type: OS::Neutron::Net
195     properties:
196       name: { get_param: protected_private_net_id }
197
198   protected_private_subnet:
199     type: OS::Neutron::Subnet
200     properties:
201       name: { get_param: protected_private_subnet_id }
202       network_id: { get_resource: protected_private_network }
203       cidr: { get_param: protected_private_net_cidr }
204
205   # Virtual Packet Generator instantiation
206   vpg_private_0_port:
207     type: OS::Neutron::Port
208     properties:
209       network: { get_resource: unprotected_private_network }
210       fixed_ips: [{"subnet": { get_resource: unprotected_private_subnet }, "ip_address": { get_param: vpg_private_ip_0 }}]
211       security_groups:
212       - { get_param: sec_group }
213
214   vpg_private_1_port:
215     type: OS::Neutron::Port
216     properties:
217       network: { get_param: onap_private_net_id }
218       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]
219       security_groups:
220       - { get_param: sec_group }
221
222   vpg_private_2_port:
223     type: OS::Neutron::Port
224     properties:
225       network: { get_param: ext_private_net_id }
226       fixed_ips: [{"subnet": { get_param: ext_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_2 }}]
227       security_groups:
228       - { get_param: sec_group }
229
230   vpg_ext_floatingip:
231     type: OS::Neutron::FloatingIP
232     properties:
233       floating_network: { get_param: public_net_id }
234       port_id: { get_resource: vpg_private_2_port }
235
236   vpg_0:
237     type: OS::Nova::Server
238     properties:
239       image: { get_param: image_name }
240       flavor: { get_param: flavor_name }
241       name: { get_param: vpg_name_0 }
242       key_name: { get_resource: my_keypair }
243       networks:
244         - port: { get_resource: vpg_private_2_port }
245         - port: { get_resource: vpg_private_0_port }
246         - port: { get_resource: vpg_private_1_port }
247       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
248       user_data_format: RAW
249       user_data:
250         str_replace:
251           params:
252             __fw_ipaddr__: { get_param: vfw_private_ip_0 }
253             __protected_net_cidr__: { get_param: protected_private_net_cidr }
254             __sink_ipaddr__: { get_param: vsn_private_ip_0 }
255             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
256             __install_script_version__ : { get_param: install_script_version }
257             __vpg_private_ip_0__ : { get_param: vpg_private_ip_0 }
258             __vpg_private_ip_1__ : { get_param: vpg_private_ip_1 }
259             __vpg_private_ip_2__ : { get_param: vpg_private_ip_2 }
260             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
261             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
262             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
263             __cloud_env__ : { get_param: cloud_env }
264           template: |
265             #!/bin/bash
266
267             # Create configuration files
268             mkdir /opt/config
269             echo "__fw_ipaddr__" > /opt/config/fw_ipaddr.txt
270             echo "__protected_net_cidr__" > /opt/config/protected_net_cidr.txt
271             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt
272             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
273             echo "__install_script_version__" > /opt/config/install_script_version.txt
274             echo "__vpg_private_ip_0__" > /opt/config/vpg_private_ip_0.txt
275             echo "__vpg_private_ip_1__" > /opt/config/vpg_private_ip_1.txt
276             echo "__vpg_private_ip_2__" > /opt/config/vpg_private_ip_2.txt
277             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
278             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
279             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
280             echo "__cloud_env__" > /opt/config/cloud_env.txt
281
282             # Download and run install script
283             apt-get update
284             apt-get -y install unzip
285             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
286             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vfw&a=vfw-scripts&e=zip&v=__install_script_version__" -o /opt/vfw-scripts-__install_script_version__.zip
287             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
288             cd /opt
289             chmod +x v_packetgen_install.sh
290             ./v_packetgen_install.sh