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