Fixed CDR_IMAGE_VERSION in portal script
[demo.git] / heat / 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   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_name_0:
93     type: string
94     label: vPacketGenerator name
95     description: Name of the vPacketGenerator
96   vnf_id:
97     type: string
98     label: VNF ID
99     description: The VNF ID is provided by ONAP
100   vf_module_id:
101     type: string
102     label: vPNG Traffic Generator module ID
103     description: The vPNG Module ID is provided by ONAP
104   key_name:
105     type: string
106     label: Key pair name
107     description: Public/Private key pair name
108   pub_key:
109     type: string
110     label: Public key
111     description: Public key to be installed on the compute instance
112   repo_url_blob:
113     type: string
114     label: Repository URL
115     description: URL of the repository that hosts the demo packages
116   repo_url_artifacts:
117     type: string
118     label: Repository URL
119     description: URL of the repository that hosts the demo packages
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   cloud_env:
129     type: string
130     label: Cloud environment
131     description: Cloud environment (e.g., openstack, rackspace)
132
133 #############
134 #           #
135 # RESOURCES #
136 #           #
137 #############
138
139 resources:
140   random-str:
141     type: OS::Heat::RandomString
142     properties:
143       length: 4
144
145   my_keypair:
146     type: OS::Nova::KeyPair
147     properties:
148       name:
149         str_replace:
150           template: base_rand
151           params:
152             base: { get_param: key_name }
153             rand: { get_resource: random-str }
154       public_key: { get_param: pub_key }
155       save_private_key: false
156
157
158   # Virtual Packet Generator instantiation
159   vpg_private_0_port:
160     type: OS::Neutron::Port
161     properties:
162       network: { get_param: unprotected_private_net_id }
163       fixed_ips: [{"subnet": { get_param: unprotected_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_0 }}]
164
165   vpg_private_1_port:
166     type: OS::Neutron::Port
167     properties:
168       network: { get_param: onap_private_net_id }
169       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]
170
171   vpg_0:
172     type: OS::Nova::Server
173     properties:
174       image: { get_param: image_name }
175       flavor: { get_param: flavor_name }
176       name: { get_param: vpg_name_0 }
177       key_name: { get_resource: my_keypair }
178       networks:
179         - network: { get_param: public_net_id }
180         - port: { get_resource: vpg_private_0_port }
181         - port: { get_resource: vpg_private_1_port }
182       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
183       user_data_format: RAW
184       user_data:
185         str_replace:
186           params:
187             __fw_ipaddr__: { get_param: vfw_private_ip_0 }
188             __protected_net_cidr__: { get_param: protected_private_net_cidr }
189             __sink_ipaddr__: { get_param: vsn_private_ip_0 }
190             __repo_url_blob__ : { get_param: repo_url_blob }
191             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
192             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
193             __install_script_version__ : { get_param: install_script_version }
194             __vpg_private_ip_0__ : { get_param: vpg_private_ip_0 }
195             __vpg_private_ip_1__ : { get_param: vpg_private_ip_1 }
196             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }
197             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
198             __cloud_env__ : { get_param: cloud_env }
199           template: |
200             #!/bin/bash
201
202             # Create configuration files
203             mkdir /opt/config
204             echo "__fw_ipaddr__" > /opt/config/fw_ipaddr.txt
205             echo "__protected_net_cidr__" > /opt/config/protected_net_cidr.txt
206             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt
207             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
208             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
209             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
210             echo "__install_script_version__" > /opt/config/install_script_version.txt
211             echo "__vpg_private_ip_0__" > /opt/config/vpg_private_ip_0.txt
212             echo "__vpg_private_ip_1__" > /opt/config/vpg_private_ip_1.txt
213             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt
214             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
215             echo "__cloud_env__" > /opt/config/cloud_env.txt
216
217             # Download and run install script
218             curl -k __repo_url_blob__/org.onap.demo/vnfs/vfw/__install_script_version__/v_packetgen_install.sh -o /opt/v_packetgen_install.sh
219             cd /opt
220             chmod +x v_packetgen_install.sh
221             ./v_packetgen_install.sh