vFW templates for OpenStack
[demo.git] / heat / vFW / base_vfw_rackspace.yaml
1 heat_template_version: 2013-05-23
2
3 description: Heat template that deploys vFirewall demo app for ONAP
4
5 parameters:
6   vfw_image_name:
7     type: string
8     label: Image name or ID
9     description: Image to be used for compute instance
10   vfw_flavor_name:
11     type: string
12     label: Flavor
13     description: Type of instance (flavor) to be used
14   public_net_id:
15     type: string
16     label: Public network name or ID
17     description: Public network that enables remote connection to VNF
18   unprotected_private_net_id:
19     type: string
20     label: Unprotected private network name or ID
21     description: Private network that connects vPacketGenerator with vFirewall
22   protected_private_net_id:
23     type: string
24     label: Protected private network name or ID
25     description: Private network that connects vFirewall with vSink
26   onap_private_net_id:
27     type: string
28     label: ONAP management network name or ID
29     description: Private network that connects ONAP components and the VNF
30   onap_private_subnet_id:
31     type: string
32     label: ONAP management sub-network name or ID
33     description: Private sub-network that connects ONAP components and the VNF
34   unprotected_private_net_cidr:
35     type: string
36     label: Unprotected private network CIDR
37     description: The CIDR of the unprotected private network
38   protected_private_net_cidr:
39     type: string
40     label: Protected private network CIDR
41     description: The CIDR of the protected private network
42   onap_private_net_cidr:
43     type: string
44     label: ONAP private network CIDR
45     description: The CIDR of the protected private network
46   vfw_private_ip_0:
47     type: string
48     label: vFirewall private IP address towards the unprotected network
49     description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator
50   vfw_private_ip_1:
51     type: string
52     label: vFirewall private IP address towards the protected network
53     description: Private IP address that is assigned to the vFirewall to communicate with the vSink
54   vfw_private_ip_2:
55     type: string
56     label: vFirewall private IP address towards the ONAP management network
57     description: Private IP address that is assigned to the vFirewall to communicate with ONAP components
58   vpg_private_ip_0:
59     type: string
60     label: vPacketGenerator private IP address towards the unprotected network
61     description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall
62   vpg_private_ip_1:
63     type: string
64     label: vPacketGenerator private IP address towards the ONAP management network
65     description: Private IP address that is assigned to the vPacketGenerator to communicate with ONAP components
66   vsn_private_ip_0:
67     type: string
68     label: vSink private IP address towards the protected network
69     description: Private IP address that is assigned to the vSink to communicate with the vFirewall
70   vsn_private_ip_1:
71     type: string
72     label: vSink private IP address towards the ONAP management network
73     description: Private IP address that is assigned to the vSink to communicate with ONAP components
74   vfw_name_0:
75     type: string
76     label: vFirewall name
77     description: Name of the vFirewall
78   vpg_name_0:
79     type: string
80     label: vPacketGenerator name
81     description: Name of the vPacketGenerator
82   vsn_name_0:
83     type: string
84     label: vSink name
85     description: Name of the vSink
86   vnf_id:
87     type: string
88     label: VNF ID
89     description: The VNF ID is provided by ECOMP
90   vf_module_id:
91     type: string
92     label: vFirewall module ID
93     description: The vFirewall Module ID is provided by ECOMP
94   dcae_collector_ip:
95     type: string
96     label: DCAE collector IP address
97     description: IP address of the DCAE collector
98   dcae_collector_port:
99     type: string
100     label: DCAE collector port
101     description: Port of the DCAE collector
102   key_name:
103     type: string
104     label: Key pair name
105     description: Public/Private key pair name
106   pub_key:
107     type: string
108     label: Public key
109     description: Public key to be installed on the compute instance
110   repo_url_blob:
111     type: string
112     label: Repository URL
113     description: URL of the repository that hosts the demo packages
114   repo_url_artifacts:
115     type: string
116     label: Repository URL
117     description: URL of the repository that hosts the demo packages
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   cloud_env:
127     type: string
128     label: Cloud environment
129     description: Cloud environment (e.g., openstack, rackspace)
130
131 resources:
132   random-str:
133     type: OS::Heat::RandomString
134     properties:
135       length: 4
136
137   my_keypair:
138     type: OS::Nova::KeyPair
139     properties:
140       name:
141         str_replace:
142           template: base_rand
143           params:
144             base: { get_param: key_name }
145             rand: { get_resource: random-str }
146       public_key: { get_param: pub_key }
147       save_private_key: false
148
149   unprotected_private_network:
150     type: OS::Neutron::Net
151     properties:
152       name: { get_param: unprotected_private_net_id }
153
154   protected_private_network:
155     type: OS::Neutron::Net
156     properties:
157       name: { get_param: protected_private_net_id }
158
159   unprotected_private_subnet:
160     type: OS::Neutron::Subnet
161     properties:
162       network_id: { get_resource: unprotected_private_network }
163       cidr: { get_param: unprotected_private_net_cidr }
164
165   protected_private_subnet:
166     type: OS::Neutron::Subnet
167     properties:
168       network_id: { get_resource: protected_private_network }
169       cidr: { get_param: protected_private_net_cidr }
170
171   # Virtual Firewall instantiation
172   vfw_private_0_port:
173     type: OS::Neutron::Port
174     properties:
175       network: { get_resource: unprotected_private_network }
176       fixed_ips: [{"subnet": { get_resource: unprotected_private_subnet }, "ip_address": { get_param: vfw_private_ip_0 }}]
177
178   vfw_private_1_port:
179     type: OS::Neutron::Port
180     properties:
181       network: { get_resource: protected_private_network }
182       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vfw_private_ip_1 }}]
183
184   vfw_private_2_port:
185     type: OS::Neutron::Port
186     properties:
187       network: { get_param: onap_private_net_id }
188       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vfw_private_ip_2 }}]
189
190   vfw_0:
191     type: OS::Nova::Server
192     properties:
193       image: { get_param: vfw_image_name }
194       flavor: { get_param: vfw_flavor_name }
195       name: { get_param: vfw_name_0 }
196       key_name: { get_resource: my_keypair }
197       networks:
198         - network: { get_param: public_net_id }
199         - port: { get_resource: vfw_private_0_port }
200         - port: { get_resource: vfw_private_1_port }
201         - port: { get_resource: vfw_private_2_port }
202       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
203       user_data_format: RAW
204       user_data:
205         str_replace:
206           params:
207             __dcae_collector_ip__ : { get_param: dcae_collector_ip }
208             __dcae_collector_port__ : { get_param: dcae_collector_port }
209             __repo_url_blob__ : { get_param: repo_url_blob }
210             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
211             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
212             __install_script_version__ : { get_param: install_script_version }
213             __cloud_env__ : { get_param: cloud_env }
214           template: |
215             #!/bin/bash
216
217             # Create configuration files
218             mkdir /opt/config
219             echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
220             echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
221             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
222             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
223             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
224             echo "__install_script_version__" > /opt/config/install_script_version.txt
225             echo "__cloud_env__" > /opt/config/cloud_env.txt
226             
227             # Download and run install script
228             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vfw/__install_script_version__/v_firewall_install.sh -o /opt/v_firewall_install.sh
229             cd /opt
230             chmod +x v_firewall_install.sh
231             ./v_firewall_install.sh
232
233
234   # Virtual Packet Generator instantiation
235   vpg_private_0_port:
236     type: OS::Neutron::Port
237     properties:
238       network: { get_resource: unprotected_private_network }
239       fixed_ips: [{"subnet": { get_resource: unprotected_private_subnet }, "ip_address": { get_param: vpg_private_ip_0 }}]
240
241   vpg_private_1_port:
242     type: OS::Neutron::Port
243     properties:
244       network: { get_param: onap_private_net_id }
245       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_1 }}]
246
247   vpg_0:
248     type: OS::Nova::Server
249     properties:
250       image: { get_param: vfw_image_name }
251       flavor: { get_param: vfw_flavor_name }
252       name: { get_param: vpg_name_0 }
253       key_name: { get_resource: my_keypair }
254       networks:
255         - network: { get_param: public_net_id }
256         - port: { get_resource: vpg_private_0_port }
257         - port: { get_resource: vpg_private_1_port }
258       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
259       user_data_format: RAW
260       user_data:
261         str_replace:
262           params:
263             __fw_ipaddr__: { get_param: vfw_private_ip_0 }
264             __protected_net_cidr__: { get_param: protected_private_net_cidr }
265             __sink_ipaddr__: { get_param: vsn_private_ip_0 }
266             __repo_url_blob__ : { get_param: repo_url_blob }
267             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
268             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
269             __install_script_version__ : { get_param: install_script_version }
270             __cloud_env__ : { get_param: cloud_env }
271           template: |
272             #!/bin/bash
273
274             # Create configuration files
275             mkdir /opt/config
276             echo "__fw_ipaddr__" > /opt/config/fw_ipaddr.txt
277             echo "__protected_net_cidr__" > /opt/config/protected_net_cidr.txt
278             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt
279             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
280             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
281             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
282             echo "__install_script_version__" > /opt/config/install_script_version.txt
283             echo "__cloud_env__" > /opt/config/cloud_env.txt
284             
285             # Download and run install script
286             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vfw/__install_script_version__/v_packetgen_install.sh -o /opt/v_packetgen_install.sh
287             cd /opt
288             chmod +x v_packetgen_install.sh
289             ./v_packetgen_install.sh
290
291
292   # Virtual Sink instantiation
293   vsn_private_0_port:
294     type: OS::Neutron::Port
295     properties:
296       network: { get_resource: protected_private_network }
297       fixed_ips: [{"subnet": { get_resource: protected_private_subnet }, "ip_address": { get_param: vsn_private_ip_0 }}]
298
299   vsn_private_1_port:
300     type: OS::Neutron::Port
301     properties:
302       network: { get_param: onap_private_net_id }
303       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_1 }}]
304
305   vsn_0:
306     type: OS::Nova::Server
307     properties:
308       image: { get_param: vfw_image_name }
309       flavor: { get_param: vfw_flavor_name }
310       name: { get_param: vsn_name_0 }
311       key_name: { get_resource: my_keypair }
312       networks:
313         - network: { get_param: public_net_id }
314         - port: { get_resource: vsn_private_0_port }
315         - port: { get_resource: vsn_private_1_port }
316       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
317       user_data_format: RAW
318       user_data:
319         str_replace:
320           params:
321             __protected_net_gw__: { get_param: vfw_private_ip_1 }
322             __unprotected_net__: { get_param: unprotected_private_net_cidr }
323             __repo_url_blob__ : { get_param: repo_url_blob }
324             __install_script_version__ : { get_param: install_script_version }
325             __cloud_env__ : { get_param: cloud_env }
326           template: |
327             #!/bin/bash
328
329             # Create configuration files
330             mkdir /opt/config
331             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt
332             echo "__unprotected_net__" > /opt/config/unprotected_net.txt
333             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
334             echo "__install_script_version__" > /opt/config/install_script_version.txt
335             echo "__cloud_env__" > /opt/config/cloud_env.txt
336             
337             # Download and run install script
338             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vfw/__install_script_version__/v_sink_install.sh -o /opt/v_sink_install.sh
339             cd /opt
340             chmod +x v_sink_install.sh
341             ./v_sink_install.sh