1 # Project Clearwater - IMS in the Cloud
2 # Copyright (C) 2015 Metaswitch Networks Ltd
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the
6 # Free Software Foundation, either version 3 of the License, or (at your
7 # option) any later version, along with the "Special Exception" for use of
8 # the program along with SSL, set forth below. This program is distributed
9 # in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 # A PARTICULAR PURPOSE. See the GNU General Public License for more
12 # details. You should have received a copy of the GNU General Public
13 # License along with this program. If not, see
14 # <http://www.gnu.org/licenses/>.
16 # The author can be reached by email at clearwater@metaswitch.com or by
17 # post at Metaswitch Networks Ltd, 100 Church St, Enfield EN2 6BQ, UK
20 # Metaswitch Networks Ltd grants you permission to copy, modify,
21 # propagate, and distribute a work formed by combining OpenSSL with The
22 # Software, or a work derivative of such a combination, even if such
23 # copying, modification, propagation, or distribution would otherwise
24 # violate the terms of the GPL. You must comply with the GPL in all
25 # respects for all of the code used other than OpenSSL.
26 # "OpenSSL" means OpenSSL toolkit software distributed by the OpenSSL
27 # Project and licensed under the OpenSSL Licenses, or a work based on such
28 # software and licensed under the OpenSSL Licenses.
29 # "OpenSSL Licenses" means the OpenSSL License and Original SSLeay License
30 # under which the OpenSSL Project distributes the OpenSSL toolkit software,
31 # as those licenses appear in the file LICENSE-OPENSSL.
33 heat_template_version: 2014-10-16
36 Clearwater Sprout node
42 description: The VNF name provided by ONAP
46 description: The VNF ID provided by ONAP
50 description: The VNF module ID provided by ONAP
53 description: ID of public network
55 - custom_constraint: neutron.network
56 description: Must be a valid network ID
59 description: Flavor to use
61 - custom_constraint: nova.flavor
62 description: Must be a valid flavor name
65 description: Name of image to use
68 description: Name of keypair to assign
70 - custom_constraint: nova.keypair
71 description: Must be a valid keypair name
74 description: URL for Clearwater repository
80 description: IP address for DNS server on network
83 description: DNSSEC private key (Base64-encoded)
85 - allowed_pattern: "[0-9A-Za-z+/=]+"
86 description: Must be Base64-encoded
89 description: IP address of an existing member of the etcd cluster
94 type: OS::Heat::RandomString
98 sprout_security_group:
99 type: OS::Neutron::SecurityGroup
101 description: security group
104 template: pre_base_rand
107 base: { get_param: vnf_name }
108 rand: { get_resource: sprout_random_str }
110 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 22, port_range_max: 22},
111 {remote_ip_prefix: 0.0.0.0/0, protocol: udp, port_range_min: 161, port_range_max: 162},
112 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 2380, port_range_max: 2380},
113 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 4000, port_range_max: 4000},
114 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 5054, port_range_max: 5054},
115 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 5052, port_range_max: 5052},
116 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 9888, port_range_max: 9888},
117 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 443, port_range_max: 443},
118 {remote_ip_prefix: 0.0.0.0/0, protocol: icmp}]
121 type: OS::Neutron::Port
125 template: pre_base_rand
127 pre: sprout_admin_port_0_
128 base: { get_param: vnf_name }
129 rand: { get_resource: sprout_random_str }
130 network: { get_param: public_net_id }
131 security_groups: [{ get_resource: sprout_security_group }]
134 type: OS::Nova::Server
138 template: pre_base_rand
140 pre: sprout_server_0_
141 base: { get_param: vnf_name }
142 rand: { get_resource: sprout_random_str }
143 image: { get_param: sprout_image_name }
144 flavor: { get_param: sprout_flavor_name }
145 key_name: { get_param: key_name }
147 - port: { get_resource: sprout_admin_port_0 }
148 metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }, vnf_name: { get_param: vnf_name }}
149 user_data_format: RAW
153 __repo_url__: { get_param: repo_url }
154 __zone__: { get_param: zone }
155 __dns_ip__: { get_param: dns_ip }
156 __dnssec_key__: { get_param: dnssec_key }
157 __etcd_ip__ : { get_param: etcd_ip }
162 # Log all output to file.
163 exec > >(tee -a /var/log/clearwater-heat-sprout.log) 2>&1
166 # Configure the APT software source.
167 echo 'deb __repo_url__ binary/' > /etc/apt/sources.list.d/clearwater.list
168 curl -L http://repo.cw-ngv.com/repo_key | apt-key add -
171 # Get the public IP address from eth0
172 sudo apt-get install ipcalc
173 ADDR=`ip addr show eth0 | awk '/inet /{print $2}'`
174 PUBLIC_ADDR=`ipcalc -n -b $ADDR | awk '/Address:/{print $2}'`
176 # Configure /etc/clearwater/local_config.
177 mkdir -p /etc/clearwater
179 [ -n "$etcd_ip" ] || etcd_ip=$PUBLIC_ADDR
180 cat > /etc/clearwater/local_config << EOF
181 management_local_ip=$PUBLIC_ADDR
182 local_ip=$PUBLIC_ADDR
183 public_ip=$PUBLIC_ADDR
184 public_hostname=__index__.sprout.__zone__
185 etcd_cluster=$etcd_ip
188 # Create /etc/chronos/chronos.conf.
189 mkdir -p /etc/chronos
190 cat > /etc/chronos/chronos.conf << EOF
192 bind-address = $PUBLIC_ADDR
197 folder = /var/log/chronos
207 # Now install the software.
208 DEBIAN_FRONTEND=noninteractive apt-get install sprout --yes --force-yes
209 DEBIAN_FRONTEND=noninteractive apt-get install clearwater-management --yes --force-yes
211 # Function to give DNS record type and IP address for specified IP address
213 if echo $1 | grep -q -e '[^0-9.]' ; then
222 while ! { nsupdate -y "__zone__:__dnssec_key__" -v << EOF
224 update add sprout-__index__.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
225 update add __index__.sprout.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
226 update add sprout.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
227 update add scscf.sprout.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
228 update add icscf.sprout.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
229 update add sprout.__zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.sprout.__zone__.
230 update add _sip._tcp.sprout.__zone__. 30 SRV 0 0 5054 __index__.sprout.__zone__.
231 update add icscf.sprout.__zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.icscf.sprout.__zone__.
232 update add _sip._tcp.icscf.sprout.__zone__. 30 SRV 0 0 5052 __index__.sprout.__zone__.
233 update add scscf.sprout.__zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.scscf.sprout.__zone__.
234 update add _sip._tcp.scscf.sprout.__zone__. 30 SRV 0 0 5054 __index__.sprout.__zone__.
237 } && [ $retries -lt 10 ]
239 retries=$((retries + 1))
240 echo 'nsupdate failed - retrying (retry '$retries')...'
244 # Use the DNS server.
245 echo 'nameserver __dns_ip__' > /etc/dnsmasq.resolv.conf
246 echo 'RESOLV_CONF=/etc/dnsmasq.resolv.conf' >> /etc/default/dnsmasq
247 service dnsmasq force-reload
251 description: IP address in public network
252 value: { get_attr: [ sprout_server_0, networks, { get_param: public_net_id }, 0 ] }