61871df2af99e5ebadbff6c8962823f5588d5d1a
[demo.git] / heat / vFW_NextGen / templates / vfw.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright (c) 2018 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 that deploys vFirewall for ONAP
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   image_name:
37     type: string
38     label: Image name or ID
39     description: Image to be used for compute instance
40   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   unprotected_private_net_id:
49     type: string
50     label: Unprotected private network name or ID
51     description: Private network that connects vPacketGenerator with vFirewall
52   unprotected_private_subnet_id:
53     type: string
54     label: Unprotected private subnetwork name or ID
55     description: Private subnetwork of the protected network
56   unprotected_private_net_cidr:
57     type: string
58     label: Unprotected private network CIDR
59     description: The CIDR of the unprotected private network
60   protected_private_net_id:
61     type: string
62     label: Protected private network name or ID
63     description: Private network that connects vFirewall with vSink
64   protected_private_subnet_id:
65     type: string
66     label: Protected private subnetwork name or ID
67     description: Private subnetwork of the unprotected network
68   protected_private_net_cidr:
69     type: string
70     label: Protected private network CIDR
71     description: The CIDR of the protected private network
72   onap_private_net_id:
73     type: string
74     label: ONAP management network name or ID
75     description: Private network that connects ONAP components and the VNF
76   onap_private_subnet_id:
77     type: string
78     label: ONAP management sub-network name or ID
79     description: Private sub-network that connects ONAP components and the VNF
80   onap_private_net_cidr:
81     type: string
82     label: ONAP private network CIDR
83     description: The CIDR of the protected private network
84   vfw_private_ip_0:
85     type: string
86     label: vFirewall private IP address towards the unprotected network
87     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator
88   vfw_private_ip_1:
89     type: string
90     label: vFirewall private IP address towards the protected network
91     description: Private IP address that is assigned to the vFirewall to communicate with the vSink
92   vfw_private_ip_2:
93     type: string
94     label: vFirewall private IP address towards the ONAP management network
95     description: Private IP address that is assigned to the vFirewall to communicate with ONAP components
96   vpg_private_ip_0:
97     type: string
98     label: vPacketGenerator private IP address towards the unprotected network
99     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall
100   vfw_name_0:
101     type: string
102     label: vFirewall name
103     description: Name of the vFirewall
104   vnf_id:
105     type: string
106     label: VNF ID
107     description: The VNF ID is provided by ONAP
108   vf_module_id:
109     type: string
110     label: VF Module ID
111     description: The VF Module ID is provided by ONAP
112   dcae_collector_ip:
113     type: string
114     label: DCAE collector IP address
115     description: IP address of the DCAE collector
116   dcae_collector_port:
117     type: string
118     label: DCAE collector port
119     description: Port of the DCAE collector
120   key_name:
121     type: string
122     label: Key pair name
123     description: Public/Private key pair name
124   install_script_version:
125     type: string
126     label: Installation script version number
127     description: Version number of the scripts that install the vFW demo app
128   demo_artifacts_version:
129     type: string
130     label: Artifacts version used in demo vnfs
131     description: Artifacts (jar, tar.gz) version used in demo vnfs
132   nexus_artifact_repo:
133     type: string
134     description: Root URL for the Nexus repository for Maven artifacts.
135     default: "https://nexus.onap.org"
136   cloud_env:
137     type: string
138     label: Cloud environment
139     description: Cloud environment (e.g., openstack, rackspace)
140   sec_group:
141     type: string
142     description: ONAP Security Group
143   sdnc_model_name:
144     type: string
145     description: SDNC Model Name metatada
146   sdnc_model_version:
147     type: string
148     description: SDNC Model Version metatada
149   sdnc_artifact_name:
150     type: string
151     description: SDNC Artifact Name metatada
152
153
154 #############
155 #           #
156 # RESOURCES #
157 #           #
158 #############
159
160 resources:
161
162   # Virtual Firewall instantiation
163   vfw_private_0_port:
164     type: OS::Neutron::Port
165     properties:
166       network: { get_param: unprotected_private_net_id }
167       fixed_ips: [{"subnet": { get_param: unprotected_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_0 }}]
168       security_groups:
169       - { get_param: sec_group }
170
171   vfw_private_1_port:
172     type: OS::Neutron::Port
173     properties:
174       allowed_address_pairs: [{ "ip_address": { get_param: vpg_private_ip_0 }}]
175       network: { get_param: protected_private_net_id }
176       fixed_ips: [{"subnet": { get_param: protected_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_1 }}]
177       security_groups:
178       - { get_param: sec_group }
179
180   vfw_private_2_port:
181     type: OS::Neutron::Port
182     properties:
183       network: { get_param: onap_private_net_id }
184       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_2 }}]
185       security_groups:
186       - { get_param: sec_group }
187
188   vfw_0:
189     type: OS::Nova::Server
190     properties:
191       image: { get_param: image_name }
192       flavor: { get_param: flavor_name }
193       name: { get_param: vfw_name_0 }
194       key_name: { get_param: key_name }
195       networks:
196         - network: { get_param: public_net_id }
197         - port: { get_resource: vfw_private_0_port }
198         - port: { get_resource: vfw_private_1_port }
199         - port: { get_resource: vfw_private_2_port }
200       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }, sdnc_model_name: { get_param: sdnc_model_name }, sdnc_model_version: { get_param: sdnc_model_version }, sdnc_artifact_name: { get_param: sdnc_artifact_name }}
201       user_data_format: RAW
202       user_data:
203         str_replace:
204           params:
205             __dcae_collector_ip__ : { get_param: dcae_collector_ip }
206             __dcae_collector_port__ : { get_param: dcae_collector_port }
207             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
208             __install_script_version__ : { get_param: install_script_version }
209             __vfw_private_ip_0__ : { get_param: vfw_private_ip_0 }
210             __vfw_private_ip_1__ : { get_param: vfw_private_ip_1 }
211             __vfw_private_ip_2__ : { get_param: vfw_private_ip_2 }
212             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
213             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
214             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
215             __cloud_env__ : { get_param: cloud_env }
216             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
217           template: |
218             #!/bin/bash
219
220             # Create configuration files
221             mkdir /opt/config
222             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
223             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
224             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
225             echo "__install_script_version__" > /opt/config/install_script_version.txt
226             echo "__vfw_private_ip_0__" > /opt/config/vfw_private_ip_0.txt
227             echo "__vfw_private_ip_1__" > /opt/config/vfw_private_ip_1.txt
228             echo "__vfw_private_ip_2__" > /opt/config/vfw_private_ip_2.txt
229             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
230             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
231             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
232             echo "__cloud_env__" > /opt/config/cloud_env.txt
233             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
234
235             # Download and run install script
236             apt-get update
237             apt-get -y install unzip
238             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
239             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
240             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_firewall_install.sh
241             cd /opt
242             chmod +x v_firewall_install.sh
243             ./v_firewall_install.sh