vFW and vFWCL templates for HPA
[demo.git] / heat / vFW_HPA / vFWCL / vPKG / base_vpkg.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright (c) 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 that deploys the vFirewall Traffic Generator demo app 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   packetgen_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 sub-network name or ID
55     description: Private subnetwork for the unprotected 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_cidr:
61     type: string
62     label: Protected private network CIDR
63     description: The CIDR of the protected private network
64   onap_private_net_id:
65     type: string
66     label: ONAP management network name or ID
67     description: Private network that connects ONAP components and the VNF
68   onap_private_subnet_id:
69     type: string
70     label: ONAP management sub-network name or ID
71     description: Private sub-network that connects ONAP components and the VNF
72   onap_private_net_cidr:
73     type: string
74     label: ONAP private network CIDR
75     description: The CIDR of the protected private network
76   vfw_private_ip_0:
77     type: string
78     label: vFirewall private IP address towards the unprotected network
79     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator
80   vsn_private_ip_0:
81     type: string
82     label: vSink private IP address towards the protected network
83     description: Private IP address that is assigned to the vSink to communicate with the vFirewall
84   vpg_private_ip_0:
85     type: string
86     label: vPacketGenerator private IP address towards the unprotected network
87     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall
88   vpg_private_ip_1:
89     type: string
90     label: vPacketGenerator private IP address towards the ONAP management network
91     description: Private IP address that is assigned to the vPacketGenerator to communicate with ONAP components
92   vpg_private_0_port_vnic_type:
93     type: string
94     description: vpg port 0 vnic type (normal, direct)
95   vpg_private_1_port_vnic_type:
96     type: string
97     description: vpg port 1 vnic type (normal, direct)
98   vpg_name_0:
99     type: string
100     label: vPacketGenerator name
101     description: Name of the vPacketGenerator
102   vnf_id:
103     type: string
104     label: VNF ID
105     description: The VNF ID is provided by ONAP
106   vf_module_id:
107     type: string
108     label: vPNG Traffic Generator module ID
109     description: The vPNG Module ID is provided by ONAP
110   key_name:
111     type: string
112     label: Key pair name
113     description: Public/Private key pair name
114   pub_key:
115     type: string
116     label: Public key
117     description: Public key to be installed on the compute instance
118   install_script_version:
119     type: string
120     label: Installation script version number
121     description: Version number of the scripts that install the vFW demo app
122   demo_artifacts_version:
123     type: string
124     label: Artifacts version used in demo vnfs
125     description: Artifacts (jar, tar.gz) version used in demo vnfs
126   nexus_artifact_repo:
127     type: string
128     description: Root URL for the Nexus repository for Maven artifacts.
129     default: "https://nexus.onap.org"
130   cloud_env:
131     type: string
132     label: Cloud environment
133     description: Cloud environment (e.g., openstack, rackspace)
134   sec_group:
135     type: string
136     description: ONAP Security Group
137
138 #############
139 #           #
140 # RESOURCES #
141 #           #
142 #############
143
144 resources:
145   random-str:
146     type: OS::Heat::RandomString
147     properties:
148       length: 4
149
150   my_keypair:
151     type: OS::Nova::KeyPair
152     properties:
153       name:
154         str_replace:
155           template: base_rand
156           params:
157             base: { get_param: key_name }
158             rand: { get_resource: random-str }
159       public_key: { get_param: pub_key }
160       save_private_key: false
161
162
163   # Virtual Packet Generator instantiation
164   vpg_private_0_port:
165     type: OS::Neutron::Port
166     properties:
167       network: { get_param: unprotected_private_net_id }
168       binding:vnic_type: { get_param: vpg_private_0_port_vnic_type}
169       fixed_ips: [{"subnet": { get_param: unprotected_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_0 }}]
170       security_groups:
171       - { get_param: sec_group }
172
173   vpg_private_1_port:
174     type: OS::Neutron::Port
175     properties:
176       network: { get_param: onap_private_net_id }
177       binding:vnic_type: { get_param: vpg_private_1_port_vnic_type}
178       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]
179       security_groups:
180       - { get_param: sec_group }
181
182   vpg_0:
183     type: OS::Nova::Server
184     properties:
185       image: { get_param: image_name }
186       flavor: { get_param: packetgen_flavor_name }
187       name: { get_param: vpg_name_0 }
188       key_name: { get_resource: my_keypair }
189       networks:
190         - network: { get_param: public_net_id }
191         - port: { get_resource: vpg_private_0_port }
192         - port: { get_resource: vpg_private_1_port }
193       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
194       user_data_format: RAW
195       user_data:
196         str_replace:
197           params:
198             __fw_ipaddr__: { get_param: vfw_private_ip_0 }
199             __protected_net_cidr__: { get_param: protected_private_net_cidr }
200             __sink_ipaddr__: { get_param: vsn_private_ip_0 }
201             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
202             __install_script_version__ : { get_param: install_script_version }
203             __vpg_private_ip_0__ : { get_param: vpg_private_ip_0 }
204             __vpg_private_ip_1__ : { get_param: vpg_private_ip_1 }
205             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
206             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
207             __cloud_env__ : { get_param: cloud_env }
208             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
209           template: |
210             #!/bin/bash
211
212             # Create configuration files
213             mkdir /opt/config
214             echo "__fw_ipaddr__" > /opt/config/fw_ipaddr.txt
215             echo "__protected_net_cidr__" > /opt/config/protected_net_cidr.txt
216             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt
217             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
218             echo "__install_script_version__" > /opt/config/install_script_version.txt
219             echo "__vpg_private_ip_0__" > /opt/config/vpg_private_ip_0.txt
220             echo "__vpg_private_ip_1__" > /opt/config/vpg_private_ip_1.txt
221             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
222             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
223             echo "__cloud_env__" > /opt/config/cloud_env.txt
224             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
225
226             # Download and run install script
227             apt-get update
228             apt-get -y install unzip
229             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
230             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
231             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
232             cd /opt
233             chmod +x v_packetgen_install.sh
234             ./v_packetgen_install.sh