Create vLB HEAT templates for CDS
[demo.git] / heat / vLB_CDS / vpkg.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4 #
5 #
6 # Copyright (c) 2019 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 a vPacketGen for ONAP
28
29 ##############
30 #            #
31 # PARAMETERS #
32 #            #
33 ##############
34
35 parameters:
36   vpg_image_name:
37     type: string
38     label: Image name or ID
39     description: Image to be used for compute instance
40   vpg_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   int_pktgen_private_net_id:
49     type: string
50     label: vPacketGen private network name or ID
51     description: Private network that connects vLoadBalancer with vPacketGen
52   int_pktgen_private_subnet_id:
53     type: string
54     label: vPacketGen private subnet name or ID
55     description: Private subnet of the network that connects vLoadBalancer with vPacketGen
56   onap_private_net_id:
57     type: string
58     label: ONAP management network name or ID
59     description: Private network that connects ONAP component and the VNF
60   onap_private_subnet_id:
61     type: string
62     label: ONAP management sub-network name or ID
63     description: Private sub-network that connects ONAP component and the VNF
64   pktgen_private_net_cidr:
65     type: string
66     label: vPacketGen private network CIDR
67     description: The CIDR of the vPacketGen private network
68   onap_private_net_cidr:
69     type: string
70     label: ONAP private network CIDR
71     description: The CIDR of the protected private network
72   vpg_int_pktgen_private_ip_0:
73     type: string
74     label: vPacketGen private IP address towards the vPacketGen private network
75     description: Private IP address that is assigned to the vPacketGen to communicate with the vLoadBalancer
76   vpg_onap_private_ip_0:
77     type: string
78     label: vPacketGen private IP address towards the ONAP management network
79     description: Private IP address that is assigned to the vPacketGen to communicate with ONAP components
80   vlb_int_pktgen_private_ip_0:
81     type: string
82     label: vLoadBalancer private IP address towards the vPacketGen network
83     description: Private IP address that is assigned to the vLoadBalancer to communicate with vPacketGen
84   vlb_0_mac_address:
85     type: string
86     label: vLB MAC address
87     description: MAC address of the vLB used by the vPacketGen VM
88   vpg_0_mac_address:
89     type: string
90     label: vPacketGen MAC address
91     description: MAC address of the vPacketGen used by the vLB VM
92   pg_int:
93     type: string
94     label: IP Address of the output vPacketGen interface
95     description: IP address assigned to the output interface of the vPacketGen's VPP layer
96   vpg_name_0:
97     type: string
98     label: vPKTGEN name
99     description: Name of the vPKTGEN
100   vnf_id:
101     type: string
102     label: VNF ID
103     description: The VNF ID is provided by ONAP
104   vnf_name:
105     type: string
106     label: VNF NAME
107     description: The VNF NAME is provided by ONAP
108   vf_module_id:
109     type: string
110     label: vFirewall module ID
111     description: The vLoadBalancer Module ID is provided by ONAP
112   keypair:
113     type: string
114     label: Key pair name
115     description: Public/Private key pair name
116   demo_artifacts_version:
117     type: string
118     label: Artifacts version used in demo vnfs
119     description: Version number for downloading the vPacketGen streams for VPP and VES
120   nb_api_version:
121     type: string
122     label: Northbound API version
123     description: Version number of the health check and config APIs
124   install_script_version:
125     type: string
126     label: Installation script version number
127     description: Version number of the scripts that install the vLB demo app
128   cloud_env:
129     type: string
130     label: Cloud environment
131     description: Cloud environment (e.g., openstack, rackspace)
132   nexus_artifact_repo:
133     type: string
134     description: Root URL for the Nexus repository for Maven artifacts.
135   sec_group:
136     type: string
137     description: ONAP Security Group
138   sdnc_model_name:
139     type: string
140     description: SDNC Model Name metatada
141   sdnc_model_version:
142     type: string
143     description: SDNC Model Version metatada
144   sdnc_artifact_name:
145     type: string
146     description: SDNC Artifact Name metatada
147
148 #############
149 #           #
150 # RESOURCES #
151 #           #
152 #############
153
154 resources:
155
156   # NETWORK_ROLE: pktgen_private
157   # VM_TYPE: vpg
158   vpg_0_int_pktgen_private_port_0:
159     type: OS::Neutron::Port
160     properties:
161       network: { get_param: int_pktgen_private_net_id }
162       fixed_ips: [{"subnet": { get_param: int_pktgen_private_subnet_id }, "ip_address": { get_param: vpg_int_pktgen_private_ip_0 }}]
163       mac_address: { get_param: vpg_0_mac_address }
164       security_groups:
165       - { get_param: sec_group }
166
167   # NETWORK_ROLE: onap_private
168   # VM_TYPE: vpg
169   vpg_0_onap_private_port_0:
170     type: OS::Neutron::Port
171     properties:
172       network: { get_param: onap_private_net_id }
173       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_onap_private_ip_0 }}]
174       security_groups:
175       - { get_param: sec_group }
176
177   # VM_TYPE: vpg
178   vpg_server_0:
179     type: OS::Nova::Server
180     properties:
181       image: { get_param: vpg_image_name }
182       flavor: { get_param: vpg_flavor_name }
183       name: { get_param: vpg_name_0 }
184       key_name: { get_param: keypair }
185       metadata:
186         vnf_id: { get_param: vnf_id }
187         vf_module_id: { get_param: vf_module_id }
188         vnf_name: { get_param: vnf_name }
189         sdnc_model_name: { get_param: sdnc_model_name }
190         sdnc_model_version: { get_param: sdnc_model_version }
191         sdnc_artifact_name: { get_param: sdnc_artifact_name }
192       networks:
193         - network: { get_param: public_net_id }
194         - port: { get_resource: vpg_0_int_pktgen_private_port_0 }
195         - port: { get_resource: vpg_0_onap_private_port_0 }
196       user_data_format: RAW
197       user_data:
198         str_replace:
199           params:
200             __local_private_ipaddr__: { get_param: vpg_int_pktgen_private_ip_0 }
201             __oam_private_ipaddr__: { get_param: vpg_onap_private_ip_0 }
202             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
203             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
204             __vlb_ipaddr__: { get_param: vlb_int_pktgen_private_ip_0 }
205             __demo_artifacts_version__: { get_param: demo_artifacts_version }
206             __nb_api_version__: { get_param: nb_api_version }
207             __install_script_version__: { get_param: install_script_version }
208             __pg_int__: { get_param: pg_int }
209             __vlb_mac__: { get_param: vlb_0_mac_address }
210             __cloud_env__: { get_param: cloud_env }
211             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
212           template: |
213             #!/bin/bash
214
215             # Create configuration files
216             mkdir /opt/config
217             echo "__oam_private_ipaddr__" > /opt/config/oam_private_ipaddr.txt
218             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
219             echo "__local_private_ipaddr__" > /opt/config/local_private_ipaddr.txt
220             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
221             echo "__vlb_ipaddr__" > /opt/config/vlb_ipaddr.txt
222             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
223             echo "__nb_api_version__" > /opt/config/nb_api_version.txt
224             echo "__install_script_version__" > /opt/config/install_script_version.txt
225             echo "__pg_int__" > /opt/config/pg_int.txt
226             echo "__vlb_mac__" > /opt/config/vlb_mac.txt
227             echo "__cloud_env__" > /opt/config/cloud_env.txt
228             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
229
230             # Download and run install script
231             apt-get update
232             apt-get -y install unzip
233             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
234             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vlbms&a=vlbms-scripts&e=zip&v=__install_script_version__" -o /opt/vlbms-scripts-__install_script_version__.zip
235             unzip -j /opt/vlbms-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
236             cd /opt
237             chmod +x v_packetgen_install.sh
238             ./v_packetgen_install.sh