40
44
from charmhelpers.core.host import (
56
from charmhelpers.contrib.hahelpers.cluster import (
50
61
from charmhelpers.core.templating import render
51
62
from charmhelpers.contrib.hahelpers.cluster import is_elected_leader
111
122
NEUTRON_CONF_DIR = "/etc/neutron"
113
124
NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
125
NEUTRON_LBAAS_CONF = '%s/neutron_lbaas.conf' % NEUTRON_CONF_DIR
126
NEUTRON_VPNAAS_CONF = '%s/neutron_vpnaas.conf' % NEUTRON_CONF_DIR
114
127
HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
115
128
APACHE_CONF = '/etc/apache2/sites-available/openstack_https_frontend'
116
129
APACHE_24_CONF = '/etc/apache2/sites-available/openstack_https_frontend.conf'
171
# The interface is said to be satisfied if anyone of the interfaces in the
172
# list has a complete context.
173
REQUIRED_INTERFACES = {
174
'database': ['shared-db', 'pgsql-db'],
175
'messaging': ['amqp', 'zeromq-configuration'],
176
'identity': ['identity-service'],
179
LIBERTY_RESOURCE_MAP = OrderedDict([
180
(NEUTRON_LBAAS_CONF, {
181
'services': ['neutron-server'],
184
(NEUTRON_VPNAAS_CONF, {
185
'services': ['neutron-server'],
159
191
def api_port(service):
160
192
return API_PORTS[service]
195
def additional_install_locations(plugin, source):
197
Add any required additional package locations for the charm, based
198
on the Neutron plugin being used. This will also force an immediate
201
if plugin == 'Calico':
202
if config('calico-origin'):
203
calico_source = config('calico-origin')
205
release = get_os_codename_install_source(source)
206
calico_source = 'ppa:project-calico/%s' % release
208
add_source(calico_source)
214
def force_etcd_restart():
216
If etcd has been reconfigured we need to force it to fully restart.
217
This is necessary because etcd has some config flags that it ignores
218
after the first time it starts, so we need to make it forget them.
221
for directory in glob.glob('/var/lib/etcd/*'):
222
shutil.rmtree(directory)
223
service_start('etcd')
163
226
def manage_plugin():
164
227
return config('manage-neutron-plugin-legacy-mode')
210
273
return list(set(ports))
276
def resource_map(release=None):
215
278
Dynamically generate a map of resources that will be managed for a single
281
release = release or os_release('neutron-common')
218
283
resource_map = deepcopy(BASE_RESOURCE_MAP)
284
if release >= 'liberty':
285
resource_map.update(LIBERTY_RESOURCE_MAP)
220
287
if os.path.exists('/etc/apache2/conf-available'):
221
288
resource_map.pop(APACHE_CONF)
253
320
def register_configs(release=None):
254
release = release or os_release('neutron-server')
321
release = release or os_release('neutron-common')
255
322
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
256
323
openstack_release=release)
257
324
for cfg, rscs in resource_map().iteritems():
290
357
:param configs: The charms main OSConfigRenderer object.
292
cur_os_rel = os_release('neutron-server')
359
cur_os_rel = os_release('neutron-common')
293
360
new_src = config('openstack-origin')
294
361
new_os_rel = get_os_codename_install_source(new_src)
396
463
raise Exception("IPv6 is not supported in the charms for Ubuntu "
397
464
"versions less than Trusty 14.04")
399
# NOTE(xianghui): Need to install haproxy(1.5.3) from trusty-backports
400
# to support ipv6 address, so check is required to make sure not
401
# breaking other versions, IPv6 only support for >= Trusty
402
if ubuntu_rel == 'trusty':
403
add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports'
466
# Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to
467
# use trusty-backports otherwise we can use the UCA.
468
if ubuntu_rel == 'trusty' and os_release('neutron-server') < 'liberty':
469
add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports '
406
472
apt_install('haproxy/trusty-backports', fatal=True)
540
606
neutron_api_context, perms=0o644)
542
608
service_restart('neutron-server')
611
def check_optional_relations(configs):
612
required_interfaces = {}
613
if relation_ids('ha'):
614
required_interfaces['ha'] = ['cluster']
616
get_hacluster_config()
619
'hacluster missing configuration: '
620
'vip, vip_iface, vip_cidr')
622
if required_interfaces:
623
set_os_workload_status(configs, required_interfaces)
626
return 'unknown', 'No optional relations'