Merge "Fix dns lookup failure"
[demo.git] / heat / vLB / packet_gen_vlb_openstack.yaml
1 ##########################################################################
2 #
3 #==================LICENSE_START==========================================
4
5 #
6 # Copyright © 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 description: Heat template to deploy a packet generator for the vLoadBalancer/vDNS demo app for ONAP
27
28 ##############
29 #            #
30 # PARAMETERS #
31 #            #
32 ##############
33
34 parameters:
35   public_net_id:
36     type: string
37     label: Public network name or ID
38     description: Public network that enables remote connection to VNF
39   vpg_image_name:
40     type: string
41     label: Image name or ID
42     description: Image to be used for compute instance
43   vpg_flavor_name:
44     type: string
45     label: Flavor
46     description: Type of instance (flavor) to be used
47   vpg_name_0:
48     type: string
49     label: vPacketGenerator name
50     description: Name of the vPacketGenerator
51   key_name:
52     type: string
53     label: Key pair name
54     description: Public/Private key pair name
55   pub_key:
56     type: string
57     label: Public key
58     description: Public key to be installed on the compute instance
59   repo_url_blob:
60     type: string
61     label: Repository URL
62     description: URL of the repository that hosts the demo packages
63   repo_url_artifacts:
64     type: string
65     label: Repository URL
66     description: URL of the repository that hosts the demo packages
67   vlb_ipaddr:
68     type: string
69     label: Public IP of the vLoadBalancer to which we want to send traffic
70     description: Public IP of the vLoadBalancer to which we want to send traffic
71   demo_artifacts_version:
72     type: string
73     label: Artifacts version used in demo vnfs
74     description: Artifacts (jar, tar.gz) version used in demo vnfs
75   install_script_version:
76     type: string
77     label: Installation script version number
78     description: Version number of the scripts that install the vFW demo app
79   onap_private_net_id:
80     type: string
81     label: ONAP management network name or ID
82     description: Private network that connects ONAP component and the VNF
83   onap_private_subnet_id:
84     type: string
85     label: ONAP management sub-network name or ID
86     description: Private sub-network that connects ONAP component and the VNF
87   vpg_private_ip_0_for_floating:
88     type: string
89     label: vPG private IP address towards the OpenStack public network via floating IP
90     description: vPG private IP address towards the OpenStack public network via floating IP
91
92 #############
93 #           #
94 # RESOURCES #
95 #           #
96 #############
97
98 resources:
99
100   random-str:
101     type: OS::Heat::RandomString
102     properties:
103       length: 4
104
105   my_keypair:
106     type: OS::Nova::KeyPair
107     properties:
108       name:
109         str_replace:
110           template: base_rand
111           params:
112             base: { get_param: key_name }
113             rand: { get_resource: random-str }
114       public_key: { get_param: pub_key }
115       save_private_key: false
116
117   vpg_private_0_port_for_floating:
118     type: OS::Neutron::Port
119     properties:
120       network: { get_param: onap_private_net_id }
121       fixed_ips: [{"subnet": { get_param: onap_private_subnet_id }, "ip_address": { get_param: vpg_private_ip_0_for_floating }}]
122
123   vpg_floating_ip:
124     type: OS::Neutron::FloatingIP
125     properties:
126       floating_network_id: { get_param: public_net_id }
127       port_id: { get_resource: vpg_private_0_port_for_floating }
128
129   vpg_0:
130     type: OS::Nova::Server
131     properties:
132       image: { get_param: vpg_image_name }
133       flavor: { get_param: vpg_flavor_name }
134       name: { get_param: vpg_name_0 }
135       key_name: { get_resource: my_keypair }
136       networks:
137         - port: { get_resource: vpg_private_0_port_for_floating }
138       user_data_format: RAW
139       user_data:
140         str_replace:
141           params:
142             __repo_url_blob__ : { get_param: repo_url_blob }
143             __repo_url_artifacts__ : { get_param: repo_url_artifacts }
144             __vlb_ipaddr__: { get_param: vlb_ipaddr }
145             __demo_artifacts_version__ : { get_param: demo_artifacts_version }
146             __install_script_version__ : { get_param: install_script_version }
147           template: |
148             #!/bin/bash
149
150             # Create configuration files
151             mkdir /opt/config
152             echo "__vlb_ipaddr__" > /opt/config/vlb_ipaddr.txt
153             echo "__repo_url_blob__" > /opt/config/repo_url_blob.txt
154             echo "__repo_url_artifacts__" > /opt/config/repo_url_artifacts.txt
155             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
156             echo "__install_script_version__" > /opt/config/install_script_version.txt
157
158             # Download and run install script
159             curl -k __repo_url_blob__/org.openecomp.demo/vnfs/vlb/__install_script_version__/v_packetgen_install.sh -o /opt/v_packetgen_install.sh
160             cd /opt
161             chmod +x v_packetgen_install.sh
162             ./v_packetgen_install.sh