88bf267cac0e1e4a9de53903ebf3ce8d0fda20c8
[demo.git] / heat / vFW_NextGen / templates / vsn.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright (c) 2018 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 vSink 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_cidr:
49     type: string
50     label: Unprotected private network CIDR
51     description: The CIDR of the unprotected private network
52   protected_private_net_id:
53     type: string
54     label: Protected private network name or ID
55     description: Private network that connects vFirewall with vSink
56   protected_private_subnet_id:
57     type: string
58     label: Protected private subnetwork name or ID
59     description: Private subnetwork of the unprotected 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_1:
77     type: string
78     label: vFirewall private IP address towards the protected network
79     description: Private IP address that is assigned to the vFirewall to communicate with the vSink
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   vsn_private_ip_1:
85     type: string
86     label: vSink private IP address towards the ONAP management network
87     description: Private IP address that is assigned to the vSink to communicate with ONAP components
88   vsn_name_0:
89     type: string
90     label: vSink name
91     description: Name of the vSink
92   vnf_id:
93     type: string
94     label: VNF ID
95     description: The VNF ID is provided by ONAP
96   vf_module_id:
97     type: string
98     label: VF Module ID
99     description: The VF Module ID is provided by ONAP
100   key_name:
101     type: string
102     label: Key pair name
103     description: Public/Private key pair name
104   install_script_version:
105     type: string
106     label: Installation script version number
107     description: Version number of the scripts that install the vFW demo app
108   demo_artifacts_version:
109     type: string
110     label: Artifacts version used in demo vnfs
111     description: Artifacts (jar, tar.gz) version used in demo vnfs
112   nexus_artifact_repo:
113     type: string
114     description: Root URL for the Nexus repository for Maven artifacts.
115     default: "https://nexus.onap.org"
116   cloud_env:
117     type: string
118     label: Cloud environment
119     description: Cloud environment (e.g., openstack, rackspace)
120   sec_group:
121     type: string
122     description: ONAP Security Group
123   sdnc_model_name:
124     type: string
125     description: SDNC Model Name metatada
126   sdnc_model_version:
127     type: string
128     description: SDNC Model Version metatada
129   sdnc_artifact_name:
130     type: string
131     description: SDNC Artifact Name metatada
132
133
134 #############
135 #           #
136 # RESOURCES #
137 #           #
138 #############
139
140 resources:
141
142   # Virtual Sink instantiation
143   vsn_private_0_port:
144     type: OS::Neutron::Port
145     properties:
146       network: { get_param: protected_private_net_id }
147       fixed_ips: [{"subnet": { get_param: protected_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_0 }}]
148       security_groups:
149       - { get_param: sec_group }
150
151   vsn_private_1_port:
152     type: OS::Neutron::Port
153     properties:
154       network: { get_param: onap_private_net_id }
155       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vsn_private_ip_1 }}]
156       security_groups:
157       - { get_param: sec_group }
158
159   vsn_0:
160     type: OS::Nova::Server
161     properties:
162       image: { get_param: image_name }
163       flavor: { get_param: flavor_name }
164       name: { get_param: vsn_name_0 }
165       key_name: { get_param: key_name }
166       networks:
167         - network: { get_param: public_net_id }
168         - port: { get_resource: vsn_private_0_port }
169         - port: { get_resource: vsn_private_1_port }
170       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }, sdnc_model_name: { get_param: sdnc_model_name }, sdnc_model_version: { get_param: sdnc_model_version }, sdnc_artifact_name: { get_param: sdnc_artifact_name }}
171       user_data_format: RAW
172       user_data:
173         str_replace:
174           params:
175             __protected_net_gw__: { get_param: vfw_private_ip_1 }
176             __unprotected_net__: { get_param: unprotected_private_net_cidr }
177             __install_script_version__ : { get_param: install_script_version }
178             __vsn_private_ip_0__ : { get_param: vsn_private_ip_0 }
179             __vsn_private_ip_1__ : { get_param: vsn_private_ip_1 }
180             __protected_private_net_cidr__ : { get_param: protected_private_net_cidr }
181             __onap_private_net_cidr__ : { get_param: onap_private_net_cidr }
182             __cloud_env__ : { get_param: cloud_env }
183             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
184           template: |
185             #!/bin/bash
186
187             # Create configuration files
188             mkdir /opt/config
189             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt
190             echo "__unprotected_net__" > /opt/config/unprotected_net.txt
191             echo "__install_script_version__" > /opt/config/install_script_version.txt
192             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt
193             echo "__vsn_private_ip_1__" > /opt/config/vsn_private_ip_1.txt
194             echo "__protected_private_net_cidr__" > /opt/config/protected_private_net_cidr.txt
195             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
196             echo "__cloud_env__" > /opt/config/cloud_env.txt
197             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
198
199             # Download and run install script
200             apt-get update
201             apt-get -y install unzip
202             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
203             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
204             unzip -j /opt/vfw-scripts-__install_script_version__.zip -d /opt v_sink_install.sh
205             cd /opt
206             chmod +x v_sink_install.sh
207             ./v_sink_install.sh