Merge "Create 2 VNF form of vFW"
[demo.git] / heat / vFWCL / vPKG / base_vpkg.yaml
1 ##########################################################################\r
2 #\r
3 #==================LICENSE_START==========================================\r
4 #\r
5 #\r
6 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
7 #\r
8 # Licensed under the Apache License, Version 2.0 (the "License");\r
9 # you may not use this file except in compliance with the License.\r
10 # You may obtain a copy of the License at\r
11 #        http://www.apache.org/licenses/LICENSE-2.0\r
12 #\r
13 # Unless required by applicable law or agreed to in writing, software\r
14 # distributed under the License is distributed on an "AS IS" BASIS,\r
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 # See the License for the specific language governing permissions and\r
17 # limitations under the License.\r
18 #\r
19 #==================LICENSE_END============================================\r
20 #\r
21 # ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
22 #\r
23 ##########################################################################\r
24 \r
25 heat_template_version: 2013-05-23\r
26 \r
27 description: Heat template that deploys the vFirewall Traffic Generator demo app for ONAP\r
28 \r
29 ##############\r
30 #            #\r
31 # PARAMETERS #\r
32 #            #\r
33 ##############\r
34 \r
35 parameters:\r
36   image_name:\r
37     type: string\r
38     label: Image name or ID\r
39     description: Image to be used for compute instance\r
40   flavor_name:\r
41     type: string\r
42     label: Flavor\r
43     description: Type of instance (flavor) to be used\r
44   public_net_id:\r
45     type: string\r
46     label: Public network name or ID\r
47     description: Public network that enables remote connection to VNF\r
48   unprotected_private_net_id:\r
49     type: string\r
50     label: Unprotected private network name or ID\r
51     description: Private network that connects vPacketGenerator with vFirewall\r
52   unprotected_private_subnet_id:\r
53     type: string\r
54     label: Unprotected private sub-network name or ID\r
55     description: Private subnetwork for the unprotected network\r
56   unprotected_private_net_cidr:\r
57     type: string\r
58     label: Unprotected private network CIDR\r
59     description: The CIDR of the unprotected private network\r
60   protected_private_net_cidr:\r
61     type: string\r
62     label: Protected private network CIDR\r
63     description: The CIDR of the protected private network\r
64   onap_private_net_id:\r
65     type: string\r
66     label: ONAP management network name or ID\r
67     description: Private network that connects ONAP components and the VNF\r
68   onap_private_subnet_id:\r
69     type: string\r
70     label: ONAP management sub-network name or ID\r
71     description: Private sub-network that connects ONAP components and the VNF\r
72   onap_private_net_cidr:\r
73     type: string\r
74     label: ONAP private network CIDR\r
75     description: The CIDR of the protected private network\r
76   vfw_private_ip_0:\r
77     type: string\r
78     label: vFirewall private IP address towards the unprotected network\r
79     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator\r
80   vsn_private_ip_0:\r
81     type: string\r
82     label: vSink private IP address towards the protected network\r
83     description: Private IP address that is assigned to the vSink to communicate with the vFirewall\r
84   vpg_private_ip_0:\r
85     type: string\r
86     label: vPacketGenerator private IP address towards the unprotected network\r
87     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall\r
88   vpg_private_ip_1:\r
89     type: string\r
90     label: vPacketGenerator private IP address towards the ONAP management network\r
91     description: Private IP address that is assigned to the vPacketGenerator to communicate with ONAP components\r
92   vpg_name_0:\r
93     type: string\r
94     label: vPacketGenerator name\r
95     description: Name of the vPacketGenerator\r
96   vnf_id:\r
97     type: string\r
98     label: VNF ID\r
99     description: The VNF ID is provided by ONAP\r
100   vf_module_id:\r
101     type: string\r
102     label: vPNG Traffic Generator module ID\r
103     description: The vPNG Module ID is provided by ONAP\r
104   key_name:\r
105     type: string\r
106     label: Key pair name\r
107     description: Public/Private key pair name\r
108   pub_key:\r
109     type: string\r
110     label: Public key\r
111     description: Public key to be installed on the compute instance\r
112   repo_url_blob:\r
113     type: string\r
114     label: Repository URL\r
115     description: URL of the repository that hosts the demo packages\r
116   repo_url_artifacts:\r
117     type: string\r
118     label: Repository URL\r
119     description: URL of the repository that hosts the demo packages\r
120   install_script_version:\r
121     type: string\r
122     label: Installation script version number\r
123     description: Version number of the scripts that install the vFW demo app\r
124   demo_artifacts_version:\r
125     type: string\r
126     label: Artifacts version used in demo vnfs\r
127     description: Artifacts (jar, tar.gz) version used in demo vnfs\r
128   cloud_env:\r
129     type: string\r
130     label: Cloud environment\r
131     description: Cloud environment (e.g., openstack, rackspace)\r
132 \r
133 #############\r
134 #           #\r
135 # RESOURCES #\r
136 #           #\r
137 #############\r
138 \r
139 resources:\r
140   random-str:\r
141     type: OS::Heat::RandomString\r
142     properties:\r
143       length: 4\r
144 \r
145   my_keypair:\r
146     type: OS::Nova::KeyPair\r
147     properties:\r
148       name:\r
149         str_replace:\r
150           template: base_rand\r
151           params:\r
152             base: { get_param: key_name }\r
153             rand: { get_resource: random-str }\r
154       public_key: { get_param: pub_key }\r
155       save_private_key: false\r
156 \r
157 \r
158   # Virtual Packet Generator instantiation\r
159   vpg_private_0_port:\r
160     type: OS::Neutron::Port\r
161     properties:\r
162       network: { get_param: unprotected_private_net_id }\r
163       fixed_ips: [{"subnet": { get_param: unprotected_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_0 }}]\r
164 \r
165   vpg_private_1_port:\r
166     type: OS::Neutron::Port\r
167     properties:\r
168       network: { get_param: onap_private_net_id }\r
169       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]\r
170 \r
171   vpg_0:\r
172     type: OS::Nova::Server\r
173     properties:\r
174       image: { get_param: image_name }\r
175       flavor: { get_param: flavor_name }\r
176       name: { get_param: vpg_name_0 }\r
177       key_name: { get_resource: my_keypair }\r
178       networks:\r
179         - network: { get_param: public_net_id }\r
180         - port: { get_resource: vpg_private_0_port }\r
181         - port: { get_resource: vpg_private_1_port }\r
182       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\r
183       user_data_format: RAW\r
184       user_data:\r
185         str_replace:\r
186           params:\r
187             __fw_ipaddr__: { get_param: vfw_private_ip_0 }\r
188             __protected_net_cidr__: { get_param: protected_private_net_cidr }\r
189             __sink_ipaddr__: { get_param: vsn_private_ip_0 }\r
190             __repo_url_blob__ : { get_param: repo_url_blob }\r
191             __repo_url_artifacts__ : { get_param: repo_url_artifacts }\r
192             __demo_artifacts_version__ : { get_param: demo_artifacts_version }\r
193             __install_script_version__ : { get_param: install_script_version }\r
194             __vpg_private_ip_0__ : { get_param: vpg_private_ip_0 }\r
195             __vpg_private_ip_1__ : { get_param: vpg_private_ip_1 }\r
196             __unprotected_private_net_cidr__ : { get_param: unprotected_private_net_cidr }\r
197             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }\r
198             __cloud_env__ : { get_param: cloud_env }\r
199           template: |\r
200             #!/bin/bash\r
201 \r
202             # Create configuration files\r
203             mkdir /opt/config\r
204             echo "__fw_ipaddr__" > /opt/config/fw_ipaddr.txt\r
205             echo "__protected_net_cidr__" > /opt/config/protected_net_cidr.txt\r
206             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt\r
207             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt\r
208             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt\r
209             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt\r
210             echo "__install_script_version__" > /opt/config/install_script_version.txt\r
211             echo "__vpg_private_ip_0__" > /opt/config/vpg_private_ip_0.txt\r
212             echo "__vpg_private_ip_1__" > /opt/config/vpg_private_ip_1.txt\r
213             echo "__unprotected_private_net_cidr__" > /opt/config/unprotected_private_net_cidr.txt\r
214             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt\r
215             echo "__cloud_env__" > /opt/config/cloud_env.txt\r
216 \r
217             # Download and run install script\r
218             curl -k __repo_url_blob__/org.onap.demo/vnfs/vfw/__install_script_version__/v_packetgen_install.sh -o /opt/v_packetgen_install.sh\r
219             cd /opt\r
220             chmod +x v_packetgen_install.sh\r
221             ./v_packetgen_install.sh\r