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: 2013-05-23
36 Clearwater Sprout node
42 description: The VNF ID provided by ONAP
46 description: The VNF module ID provided by ONAP
49 description: ID of public network
51 - custom_constraint: neutron.network
52 description: Must be a valid network ID
55 description: Flavor to use
57 - custom_constraint: nova.flavor
58 description: Must be a valid flavor name
61 description: Name of image to use
64 description: Name of keypair to assign
66 - custom_constraint: nova.keypair
67 description: Must be a valid keypair name
68 # base_mgmt_security_group:
70 # description: ID of base security group for all Clearwater nodes (management)
71 # sprout_sig_security_group:
73 # description: ID of security group for Sprout nodes (signaling)
74 # sprout_sig2_security_group:
76 # description: ID of additional security group for Sprout nodes (signaling)
79 description: URL for Clearwater repository
80 default: http://repo.cw-ngv.com/stable
87 description: IP address for DNS server on network
90 description: DNSSEC private key (Base64-encoded)
92 - allowed_pattern: "[0-9A-Za-z+/=]+"
93 description: Must be Base64-encoded
96 description: IP address of an existing member of the etcd cluster
100 description: Index of this Sprout node in the Sprout cluster
105 type: OS::Nova::Server
107 name: { str_replace: { params: { __index__: { get_param: index }, __zone__: { get_param: zone } }, template: sprout-__index__.__zone__ } }
108 image: { get_param: sprout_image_name }
109 flavor: { get_param: sprout_flavor_name }
110 key_name: { get_param: key_name }
112 - network: { get_param: public_net_id }
113 metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
114 user_data_format: RAW
118 __repo_url__: { get_param: repo_url }
119 __zone__: { get_param: zone }
120 __dns_ip__: { get_param: dns_ip }
121 __dnssec_key__: { get_param: dnssec_key }
122 __etcd_ip__ : { get_param: etcd_ip }
123 __index__ : { get_param: index }
127 # Log all output to file.
128 exec > >(tee -a /var/log/clearwater-heat-sprout.log) 2>&1
131 # Configure the APT software source.
132 echo 'deb __repo_url__ binary/' > /etc/apt/sources.list.d/clearwater.list
133 curl -L http://repo.cw-ngv.com/repo_key | apt-key add -
136 # Get the public IP address from eth0
137 sudo apt-get install ipcalc
138 ADDR=`ip addr show eth0 | awk '/inet /{print $2}'`
139 PUBLIC_ADDR=`ipcalc -n -b $ADDR | awk '/Address:/{print $2}'`
141 # Configure /etc/clearwater/local_config.
142 mkdir -p /etc/clearwater
144 [ -n "$etcd_ip" ] || etcd_ip=$PUBLIC_ADDR
145 cat > /etc/clearwater/local_config << EOF
146 management_local_ip=$PUBLIC_ADDR
147 local_ip=$PUBLIC_ADDR
148 public_ip=$PUBLIC_ADDR
149 public_hostname=__index__.sprout.__zone__
150 etcd_cluster=$etcd_ip
153 # Create /etc/chronos/chronos.conf.
154 mkdir -p /etc/chronos
155 cat > /etc/chronos/chronos.conf << EOF
157 bind-address = $PUBLIC_ADDR
162 folder = /var/log/chronos
172 # Now install the software.
173 DEBIAN_FRONTEND=noninteractive apt-get install sprout-node --yes --force-yes
174 DEBIAN_FRONTEND=noninteractive apt-get install clearwater-management --yes --force-yes
176 # Function to give DNS record type and IP address for specified IP address
178 if echo $1 | grep -q -e '[^0-9.]' ; then
187 while ! { nsupdate -y "__zone__:__dnssec_key__" -v << EOF
189 update add sprout-__index__.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
190 update add __index__.sprout.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
191 update add sprout.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
192 update add scscf.sprout.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
193 update add icscf.sprout.__zone__. 30 $(ip2rr $PUBLIC_ADDR)
194 update add sprout.__zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.sprout.__zone__.
195 update add _sip._tcp.sprout.__zone__. 30 SRV 0 0 5054 __index__.sprout.__zone__.
196 update add icscf.sprout.__zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.icscf.sprout.__zone__.
197 update add _sip._tcp.icscf.sprout.__zone__. 30 SRV 0 0 5052 __index__.sprout.__zone__.
198 update add scscf.sprout.__zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.scscf.sprout.__zone__.
199 update add _sip._tcp.scscf.sprout.__zone__. 30 SRV 0 0 5054 __index__.sprout.__zone__.
202 } && [ $retries -lt 10 ]
204 retries=$((retries + 1))
205 echo 'nsupdate failed - retrying (retry '$retries')...'
209 # Use the DNS server.
210 echo 'nameserver __dns_ip__' > /etc/dnsmasq.resolv.conf
211 echo 'RESOLV_CONF=/etc/dnsmasq.resolv.conf' >> /etc/default/dnsmasq
212 service dnsmasq force-reload
216 description: IP address in public network
217 value: { get_attr: [ server, accessIPv4 ] }