2017-11-05 09:04:50 +11:00
|
|
|
#!/usr/bin/env python3
|
2016-07-03 17:47:52 +01:00
|
|
|
#
|
|
|
|
# Copyright 2016 Canonical Ltd
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2014-06-05 11:59:00 +01:00
|
|
|
|
2019-09-25 12:33:50 +02:00
|
|
|
import json
|
2019-09-09 07:32:10 +00:00
|
|
|
import os
|
2014-06-05 11:59:00 +01:00
|
|
|
import sys
|
2014-09-30 09:10:40 +01:00
|
|
|
import uuid
|
2015-03-29 21:09:15 +01:00
|
|
|
from subprocess import (
|
|
|
|
check_call,
|
|
|
|
)
|
2014-06-05 11:59:00 +01:00
|
|
|
|
|
|
|
from charmhelpers.core.hookenv import (
|
2019-09-25 17:12:26 +02:00
|
|
|
DEBUG,
|
|
|
|
ERROR,
|
2014-06-05 11:59:00 +01:00
|
|
|
Hooks,
|
|
|
|
UnregisteredHookError,
|
|
|
|
config,
|
2019-09-25 17:12:26 +02:00
|
|
|
is_leader,
|
|
|
|
leader_get,
|
|
|
|
leader_set,
|
2015-04-22 14:15:37 +00:00
|
|
|
local_unit,
|
2014-06-05 11:59:00 +01:00
|
|
|
log,
|
2019-09-25 17:12:26 +02:00
|
|
|
open_port,
|
|
|
|
related_units,
|
2014-06-05 11:59:00 +01:00
|
|
|
relation_get,
|
2019-09-25 17:12:26 +02:00
|
|
|
relation_id,
|
2014-06-05 11:59:00 +01:00
|
|
|
relation_ids,
|
|
|
|
relation_set,
|
2015-05-08 14:54:32 +00:00
|
|
|
status_set,
|
2014-06-05 11:59:00 +01:00
|
|
|
unit_get,
|
|
|
|
)
|
|
|
|
|
|
|
|
from charmhelpers.core.host import (
|
2016-01-22 16:14:59 +01:00
|
|
|
mkdir,
|
2015-03-30 18:26:30 +01:00
|
|
|
service_reload,
|
2018-11-15 12:14:11 +00:00
|
|
|
service_restart,
|
2014-06-05 11:59:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
from charmhelpers.fetch import (
|
2015-04-09 10:23:02 -07:00
|
|
|
apt_install,
|
|
|
|
add_source,
|
|
|
|
apt_update,
|
2014-10-13 15:13:09 +00:00
|
|
|
filter_installed_packages,
|
2014-06-05 11:59:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
from charmhelpers.contrib.openstack.utils import (
|
|
|
|
configure_installation_source,
|
|
|
|
openstack_upgrade_available,
|
2015-04-22 13:38:00 +00:00
|
|
|
os_release,
|
2015-09-11 16:32:34 -07:00
|
|
|
sync_db_with_multi_ipv6_addresses,
|
2016-03-17 17:19:46 +00:00
|
|
|
is_unit_paused_set,
|
|
|
|
pausable_restart_on_change as restart_on_change,
|
2017-03-20 12:07:42 +00:00
|
|
|
CompareOpenStackReleases,
|
2018-09-18 10:18:19 +00:00
|
|
|
series_upgrade_prepare,
|
|
|
|
series_upgrade_complete,
|
2020-01-30 12:37:43 +00:00
|
|
|
is_db_maintenance_mode,
|
2014-06-05 11:59:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
from neutron_api_utils import (
|
2019-09-09 07:32:10 +00:00
|
|
|
ADMIN_POLICY,
|
2019-09-25 12:33:50 +02:00
|
|
|
CLUSTER_RES,
|
|
|
|
NEUTRON_CONF,
|
|
|
|
additional_install_locations,
|
2014-09-26 15:46:49 +00:00
|
|
|
api_port,
|
2017-03-01 04:05:44 +03:00
|
|
|
assess_status,
|
2019-09-25 12:33:50 +02:00
|
|
|
check_local_db_actions_complete,
|
2014-06-05 11:59:00 +01:00
|
|
|
determine_packages,
|
|
|
|
determine_ports,
|
2014-09-26 15:46:49 +00:00
|
|
|
do_openstack_upgrade,
|
2017-03-01 04:05:44 +03:00
|
|
|
dvr_router_present,
|
|
|
|
force_etcd_restart,
|
2016-02-03 11:17:14 -08:00
|
|
|
is_api_ready,
|
2019-09-25 12:33:50 +02:00
|
|
|
is_db_initialised,
|
2015-03-27 10:59:50 +00:00
|
|
|
l3ha_router_present,
|
2019-09-25 12:33:50 +02:00
|
|
|
manage_plugin,
|
2020-02-07 18:42:35 +01:00
|
|
|
maybe_set_os_install_release,
|
2015-04-22 13:38:00 +00:00
|
|
|
migrate_neutron_database,
|
2015-04-21 08:46:00 +00:00
|
|
|
neutron_ready,
|
2019-09-25 12:33:50 +02:00
|
|
|
pause_unit_helper,
|
2014-06-05 11:59:00 +01:00
|
|
|
register_configs,
|
2019-09-25 12:33:50 +02:00
|
|
|
remove_old_packages,
|
2014-06-05 11:59:00 +01:00
|
|
|
restart_map,
|
2019-09-25 12:33:50 +02:00
|
|
|
resume_unit_helper,
|
2014-11-17 13:42:03 +10:00
|
|
|
services,
|
2014-10-15 08:03:20 +00:00
|
|
|
setup_ipv6,
|
2014-06-05 11:59:00 +01:00
|
|
|
)
|
2014-10-03 09:35:19 +00:00
|
|
|
from neutron_api_context import (
|
2019-09-25 12:33:50 +02:00
|
|
|
EtcdContext,
|
|
|
|
IdentityServiceContext,
|
|
|
|
NeutronApiSDNContext,
|
|
|
|
NeutronCCContext,
|
2017-04-18 23:22:14 -07:00
|
|
|
get_dns_domain,
|
2015-02-02 13:29:41 +00:00
|
|
|
get_dvr,
|
2014-10-03 09:35:19 +00:00
|
|
|
get_l2population,
|
2019-09-25 12:33:50 +02:00
|
|
|
get_l3ha,
|
2014-10-03 09:35:19 +00:00
|
|
|
get_overlay_network_type,
|
2021-08-31 11:07:12 +05:30
|
|
|
is_fwaas_enabled,
|
2019-06-07 13:01:23 +00:00
|
|
|
is_nfg_logging_enabled,
|
2018-10-09 11:41:09 +03:00
|
|
|
is_nsg_logging_enabled,
|
2019-09-25 12:33:50 +02:00
|
|
|
is_qos_requested_and_valid,
|
2019-09-02 20:21:39 -04:00
|
|
|
is_port_forwarding_enabled,
|
2019-09-25 12:33:50 +02:00
|
|
|
is_vlan_trunking_requested_and_valid,
|
2014-10-03 09:35:19 +00:00
|
|
|
)
|
2014-06-05 11:59:00 +01:00
|
|
|
|
|
|
|
from charmhelpers.contrib.hahelpers.cluster import (
|
2017-10-03 09:38:21 +00:00
|
|
|
is_clustered,
|
2015-04-22 18:50:48 +00:00
|
|
|
is_elected_leader,
|
2014-06-05 11:59:00 +01:00
|
|
|
)
|
|
|
|
|
2016-06-14 15:47:54 -07:00
|
|
|
from charmhelpers.contrib.openstack.ha.utils import (
|
2018-12-03 13:39:25 +00:00
|
|
|
generate_ha_relation_data,
|
2016-06-14 15:47:54 -07:00
|
|
|
)
|
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
from charmhelpers.payload.execd import execd_preinstall
|
2014-07-04 12:51:35 +01:00
|
|
|
|
|
|
|
from charmhelpers.contrib.openstack.ip import (
|
|
|
|
canonical_url,
|
|
|
|
PUBLIC, INTERNAL, ADMIN
|
|
|
|
)
|
2014-06-05 11:59:00 +01:00
|
|
|
|
2015-04-17 17:02:54 -07:00
|
|
|
from charmhelpers.contrib.openstack.neutron import (
|
|
|
|
neutron_plugin_attribute,
|
|
|
|
)
|
|
|
|
|
2014-07-16 14:15:57 +01:00
|
|
|
from charmhelpers.contrib.network.ip import (
|
2017-04-25 13:43:44 -07:00
|
|
|
get_relation_ip,
|
2014-07-16 14:15:57 +01:00
|
|
|
)
|
|
|
|
|
2018-05-15 14:20:20 +00:00
|
|
|
from charmhelpers.contrib.openstack.cert_utils import (
|
|
|
|
get_certificate_request,
|
|
|
|
process_certificates,
|
|
|
|
)
|
|
|
|
|
2019-09-27 16:12:19 +01:00
|
|
|
from charmhelpers.contrib.openstack.policyd import (
|
|
|
|
maybe_do_policyd_overrides,
|
|
|
|
maybe_do_policyd_overrides_on_config_changed,
|
|
|
|
)
|
|
|
|
|
2014-09-30 09:05:41 +01:00
|
|
|
from charmhelpers.contrib.openstack.context import ADDRESS_TYPES
|
2014-07-16 14:15:57 +01:00
|
|
|
|
2015-01-12 12:04:00 +00:00
|
|
|
from charmhelpers.contrib.charmsupport import nrpe
|
2016-03-22 20:59:52 +00:00
|
|
|
from charmhelpers.contrib.hardening.harden import harden
|
2014-10-29 22:30:36 -05:00
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
hooks = Hooks()
|
|
|
|
CONFIGS = register_configs()
|
|
|
|
|
|
|
|
|
2015-04-22 13:38:00 +00:00
|
|
|
def conditional_neutron_migration():
|
2017-08-15 16:50:09 +01:00
|
|
|
"""Initialise neutron database if not already done so.
|
|
|
|
|
|
|
|
Runs neutron-manage to initialize a new database or migrate existing and
|
|
|
|
restarts services to ensure that the changes are picked up. The first
|
|
|
|
(leader) unit to perform this action should have broadcast this information
|
|
|
|
to its peers so first we check whether this has already occurred.
|
|
|
|
"""
|
2017-03-20 12:07:42 +00:00
|
|
|
if CompareOpenStackReleases(os_release('neutron-server')) <= 'icehouse':
|
2016-04-19 08:50:05 +00:00
|
|
|
log('Not running neutron database migration as migrations are handled '
|
|
|
|
'by the neutron-server process.')
|
|
|
|
return
|
2017-08-15 16:50:09 +01:00
|
|
|
|
|
|
|
if not is_elected_leader(CLUSTER_RES):
|
2015-04-22 18:50:48 +00:00
|
|
|
log('Not running neutron database migration, not leader')
|
2017-08-15 16:50:09 +01:00
|
|
|
return
|
|
|
|
|
|
|
|
allowed_units = relation_get('allowed_units')
|
|
|
|
if not (allowed_units and local_unit() in allowed_units.split()):
|
|
|
|
log('Not running neutron database migration, either no '
|
|
|
|
'allowed_units or this unit is not present')
|
|
|
|
return
|
|
|
|
|
|
|
|
migrate_neutron_database()
|
2015-04-22 13:38:00 +00:00
|
|
|
|
|
|
|
|
2014-06-27 13:19:01 +01:00
|
|
|
def configure_https():
|
|
|
|
'''
|
|
|
|
Enables SSL API Apache config if appropriate and kicks identity-service
|
|
|
|
with any required api updates.
|
|
|
|
'''
|
|
|
|
# need to write all to ensure changes to the entire request pipeline
|
|
|
|
# propagate (c-api, haprxy, apache)
|
|
|
|
CONFIGS.write_all()
|
|
|
|
if 'https' in CONFIGS.complete_contexts():
|
|
|
|
cmd = ['a2ensite', 'openstack_https_frontend']
|
|
|
|
check_call(cmd)
|
|
|
|
else:
|
|
|
|
cmd = ['a2dissite', 'openstack_https_frontend']
|
|
|
|
check_call(cmd)
|
|
|
|
|
2015-03-29 21:09:15 +01:00
|
|
|
# TODO: improve this by checking if local CN certs are available
|
|
|
|
# first then checking reload status (see LP #1433114).
|
2016-03-17 17:19:46 +00:00
|
|
|
if not is_unit_paused_set():
|
|
|
|
service_reload('apache2', restart_on_failure=True)
|
2015-03-29 21:09:15 +01:00
|
|
|
|
2014-06-27 13:19:01 +01:00
|
|
|
for rid in relation_ids('identity-service'):
|
|
|
|
identity_joined(rid=rid)
|
|
|
|
|
2015-02-11 20:35:21 -08:00
|
|
|
|
2017-11-05 09:04:50 +11:00
|
|
|
@hooks.hook('install')
|
2016-03-22 20:59:52 +00:00
|
|
|
@harden()
|
2014-06-05 11:59:00 +01:00
|
|
|
def install():
|
2015-07-10 08:22:34 -07:00
|
|
|
status_set('maintenance', 'Executing pre-install')
|
2014-06-05 11:59:00 +01:00
|
|
|
execd_preinstall()
|
2016-01-22 16:14:59 +01:00
|
|
|
openstack_origin = config('openstack-origin')
|
|
|
|
configure_installation_source(openstack_origin)
|
2020-02-07 18:42:35 +01:00
|
|
|
|
|
|
|
# Manage change of default configuration option values gated on
|
|
|
|
# install-time OpenStack release
|
|
|
|
maybe_set_os_install_release(openstack_origin)
|
|
|
|
|
2016-01-22 16:14:59 +01:00
|
|
|
neutron_plugin = config('neutron-plugin')
|
|
|
|
additional_install_locations(neutron_plugin, openstack_origin)
|
2014-09-22 13:18:12 -07:00
|
|
|
|
2015-10-07 06:25:23 -07:00
|
|
|
add_source(config('extra-source'), config('extra-key'))
|
2015-07-10 08:22:34 -07:00
|
|
|
status_set('maintenance', 'Installing apt packages')
|
2015-12-17 12:20:46 +00:00
|
|
|
apt_update(fatal=True)
|
2022-10-04 15:24:12 +00:00
|
|
|
# (ajkavanagh) LP: #1989538
|
|
|
|
# Tactical fix to force openstack-release to match the configured
|
|
|
|
# installation source; note that it comes after apt_update().
|
|
|
|
apt_install(['openstack-release'], fatal=False, quiet=True)
|
2016-01-22 16:14:59 +01:00
|
|
|
packages = determine_packages(openstack_origin)
|
2014-10-02 21:20:31 -07:00
|
|
|
apt_install(packages, fatal=True)
|
2014-11-03 13:13:02 -08:00
|
|
|
|
2019-09-27 16:12:19 +01:00
|
|
|
for port in determine_ports():
|
|
|
|
open_port(port)
|
2014-06-05 11:59:00 +01:00
|
|
|
|
2016-01-22 16:14:59 +01:00
|
|
|
if neutron_plugin == 'midonet':
|
|
|
|
mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron',
|
|
|
|
perms=0o755, force=False)
|
2019-09-27 16:12:19 +01:00
|
|
|
# call the policy overrides handler which will install any policy overrides
|
|
|
|
maybe_do_policyd_overrides(
|
|
|
|
os_release('neutron-server'),
|
|
|
|
'neutron',
|
|
|
|
restart_handler=lambda: service_restart('neutron-server'))
|
2016-01-22 16:14:59 +01:00
|
|
|
|
2016-02-17 12:33:37 -05:00
|
|
|
|
2016-02-13 17:12:10 -05:00
|
|
|
@hooks.hook('vsd-rest-api-relation-joined')
|
2016-02-17 12:33:37 -05:00
|
|
|
@restart_on_change(restart_map(), stopstart=True)
|
2016-02-16 18:43:47 -05:00
|
|
|
def relation_set_nuage_cms_name(rid=None):
|
2017-03-20 12:07:42 +00:00
|
|
|
if CompareOpenStackReleases(os_release('neutron-server')) >= 'kilo':
|
2016-02-19 21:27:40 -05:00
|
|
|
if config('vsd-cms-name') is None:
|
|
|
|
e = "Neutron Api hook failed as vsd-cms-name" \
|
|
|
|
" is not specified"
|
|
|
|
status_set('blocked', e)
|
|
|
|
else:
|
|
|
|
relation_data = {
|
|
|
|
'vsd-cms-name': '{}'.format(config('vsd-cms-name'))
|
|
|
|
}
|
|
|
|
relation_set(relation_id=rid, **relation_data)
|
2016-02-13 17:12:10 -05:00
|
|
|
|
2015-02-11 20:35:21 -08:00
|
|
|
|
2014-10-21 15:12:31 -07:00
|
|
|
@hooks.hook('vsd-rest-api-relation-changed')
|
2014-11-01 03:18:36 -07:00
|
|
|
@restart_on_change(restart_map(), stopstart=True)
|
2014-10-21 15:12:31 -07:00
|
|
|
def vsd_changed(relation_id=None, remote_unit=None):
|
|
|
|
if config('neutron-plugin') == 'vsp':
|
2014-11-01 21:07:07 -07:00
|
|
|
vsd_ip_address = relation_get('vsd-ip-address')
|
|
|
|
if not vsd_ip_address:
|
|
|
|
return
|
|
|
|
vsd_address = '{}:8443'.format(vsd_ip_address)
|
2017-03-20 12:07:42 +00:00
|
|
|
if CompareOpenStackReleases(os_release('neutron-server')) >= 'kilo':
|
2016-04-16 20:46:04 -04:00
|
|
|
vsd_cms_id = relation_get('nuage-cms-id')
|
|
|
|
log("nuage-vsd-api-relation-changed : cms_id:{}"
|
|
|
|
.format(vsd_cms_id))
|
2015-04-17 17:02:54 -07:00
|
|
|
nuage_config_file = neutron_plugin_attribute(config('neutron-plugin'),
|
|
|
|
'config', 'neutron')
|
2015-02-12 10:31:57 -08:00
|
|
|
log('vsd-rest-api-relation-changed: ip address:{}'.format(vsd_address))
|
2015-04-17 17:02:54 -07:00
|
|
|
log('vsd-rest-api-relation-changed:{}'.format(nuage_config_file))
|
2016-02-19 19:01:11 -05:00
|
|
|
|
2015-04-17 17:02:54 -07:00
|
|
|
CONFIGS.write(nuage_config_file)
|
2015-04-09 10:23:02 -07:00
|
|
|
|
|
|
|
|
2014-06-18 11:36:43 +01:00
|
|
|
@hooks.hook('upgrade-charm')
|
2019-09-27 16:12:19 +01:00
|
|
|
@restart_on_change(restart_map(), stopstart=True)
|
|
|
|
@harden()
|
|
|
|
def upgrade_charm():
|
|
|
|
common_upgrade_charm_and_config_changed()
|
|
|
|
# call the policy overrides handler which will install any policy overrides
|
|
|
|
maybe_do_policyd_overrides(
|
|
|
|
os_release('neutron-server'),
|
|
|
|
'neutron',
|
|
|
|
restart_handler=lambda: service_restart('neutron-server'))
|
|
|
|
|
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
@hooks.hook('config-changed')
|
|
|
|
@restart_on_change(restart_map(), stopstart=True)
|
2016-03-22 20:59:52 +00:00
|
|
|
@harden()
|
2014-06-05 11:59:00 +01:00
|
|
|
def config_changed():
|
2019-09-27 16:12:19 +01:00
|
|
|
common_upgrade_charm_and_config_changed()
|
|
|
|
# call the policy overrides handler which will install any policy overrides
|
|
|
|
maybe_do_policyd_overrides_on_config_changed(
|
|
|
|
os_release('neutron-server'),
|
|
|
|
'neutron',
|
|
|
|
restart_handler=lambda: service_restart('neutron-server'))
|
|
|
|
|
|
|
|
|
|
|
|
def common_upgrade_charm_and_config_changed():
|
|
|
|
"""Common code between upgrade-charm and config-changed hooks"""
|
2018-09-18 10:18:19 +00:00
|
|
|
# if we are paused, delay doing any config changed hooks.
|
|
|
|
# It is forced on the resume.
|
|
|
|
if is_unit_paused_set():
|
|
|
|
log("Unit is pause or upgrading. Skipping config_changed", "WARN")
|
|
|
|
return
|
|
|
|
|
2015-04-21 08:46:00 +00:00
|
|
|
# If neutron is ready to be queried then check for incompatability between
|
|
|
|
# existing neutron objects and charm settings
|
|
|
|
if neutron_ready():
|
|
|
|
if l3ha_router_present() and not get_l3ha():
|
|
|
|
e = ('Cannot disable Router HA while ha enabled routers exist.'
|
|
|
|
' Please remove any ha routers')
|
2015-05-08 14:54:32 +00:00
|
|
|
status_set('blocked', e)
|
2015-04-21 08:46:00 +00:00
|
|
|
raise Exception(e)
|
|
|
|
if dvr_router_present() and not get_dvr():
|
|
|
|
e = ('Cannot disable dvr while dvr enabled routers exist. Please'
|
|
|
|
' remove any distributed routers')
|
|
|
|
log(e, level=ERROR)
|
2015-05-08 14:54:32 +00:00
|
|
|
status_set('blocked', e)
|
2015-04-21 08:46:00 +00:00
|
|
|
raise Exception(e)
|
2014-09-18 21:28:17 +08:00
|
|
|
if config('prefer-ipv6'):
|
2015-05-08 14:54:32 +00:00
|
|
|
status_set('maintenance', 'configuring ipv6')
|
2014-09-18 21:28:17 +08:00
|
|
|
setup_ipv6()
|
2014-09-26 19:56:11 +01:00
|
|
|
sync_db_with_multi_ipv6_addresses(config('database'),
|
|
|
|
config('database-user'))
|
2014-09-18 21:28:17 +08:00
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
global CONFIGS
|
2018-01-10 15:34:28 +00:00
|
|
|
if not config('action-managed-upgrade'):
|
2015-09-03 10:16:17 +01:00
|
|
|
if openstack_upgrade_available('neutron-common'):
|
2015-05-08 14:54:32 +00:00
|
|
|
status_set('maintenance', 'Running openstack upgrade')
|
2015-03-08 10:49:08 +00:00
|
|
|
do_openstack_upgrade(CONFIGS)
|
2015-04-20 15:11:30 +01:00
|
|
|
|
2015-06-16 10:25:27 +01:00
|
|
|
additional_install_locations(
|
|
|
|
config('neutron-plugin'),
|
|
|
|
config('openstack-origin')
|
|
|
|
)
|
2015-05-08 14:54:32 +00:00
|
|
|
status_set('maintenance', 'Installing apt packages')
|
2019-11-29 18:10:05 -03:00
|
|
|
pkgs = determine_packages(openstack_release=os_release('neutron-server'))
|
|
|
|
apt_install(filter_installed_packages(pkgs), fatal=True)
|
2018-11-15 12:14:11 +00:00
|
|
|
packages_removed = remove_old_packages()
|
2014-06-27 13:19:01 +01:00
|
|
|
configure_https()
|
2014-10-29 22:30:36 -05:00
|
|
|
update_nrpe_config()
|
2018-06-06 12:30:56 -04:00
|
|
|
infoblox_changed()
|
2019-09-09 07:32:10 +00:00
|
|
|
# This part can be removed for U.
|
|
|
|
if os.path.exists(ADMIN_POLICY):
|
|
|
|
# Clean 00-admin.json added for bug/1830536. At has been
|
|
|
|
# noticed that it creates regression.
|
|
|
|
os.remove(ADMIN_POLICY)
|
2014-06-05 11:59:00 +01:00
|
|
|
CONFIGS.write_all()
|
2018-11-15 12:14:11 +00:00
|
|
|
if packages_removed and not is_unit_paused_set():
|
|
|
|
log("Package purge detected, restarting services", "INFO")
|
|
|
|
for s in services():
|
|
|
|
service_restart(s)
|
2014-06-17 08:44:46 +00:00
|
|
|
for r_id in relation_ids('neutron-api'):
|
|
|
|
neutron_api_relation_joined(rid=r_id)
|
2014-06-17 16:23:57 +01:00
|
|
|
for r_id in relation_ids('neutron-plugin-api'):
|
|
|
|
neutron_plugin_api_relation_joined(rid=r_id)
|
2014-06-18 11:36:43 +01:00
|
|
|
for r_id in relation_ids('amqp'):
|
|
|
|
amqp_joined(relation_id=r_id)
|
|
|
|
for r_id in relation_ids('identity-service'):
|
|
|
|
identity_joined(rid=r_id)
|
2018-01-04 18:12:14 +00:00
|
|
|
for r_id in relation_ids('ha'):
|
|
|
|
ha_joined(relation_id=r_id)
|
2019-09-25 12:33:50 +02:00
|
|
|
for r_id in relation_ids('neutron-plugin-api-subordinate'):
|
|
|
|
neutron_plugin_api_subordinate_relation_joined(relid=r_id)
|
2019-09-27 16:12:19 +01:00
|
|
|
for rid in relation_ids('cluster'):
|
|
|
|
cluster_joined(rid)
|
2014-11-01 21:07:07 -07:00
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
|
|
|
|
@hooks.hook('amqp-relation-joined')
|
|
|
|
def amqp_joined(relation_id=None):
|
|
|
|
relation_set(relation_id=relation_id,
|
|
|
|
username=config('rabbit-user'), vhost=config('rabbit-vhost'))
|
|
|
|
|
|
|
|
|
|
|
|
@hooks.hook('amqp-relation-changed')
|
|
|
|
@hooks.hook('amqp-relation-departed')
|
|
|
|
@restart_on_change(restart_map())
|
|
|
|
def amqp_changed():
|
|
|
|
if 'amqp' not in CONFIGS.complete_contexts():
|
|
|
|
log('amqp relation incomplete. Peer not ready?')
|
|
|
|
return
|
|
|
|
CONFIGS.write(NEUTRON_CONF)
|
|
|
|
|
2016-02-03 11:17:14 -08:00
|
|
|
for r_id in relation_ids('neutron-plugin-api-subordinate'):
|
|
|
|
neutron_plugin_api_subordinate_relation_joined(relid=r_id)
|
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
|
|
|
|
@hooks.hook('shared-db-relation-joined')
|
|
|
|
def db_joined():
|
2014-09-17 17:26:59 +08:00
|
|
|
if config('prefer-ipv6'):
|
2014-09-26 19:56:11 +01:00
|
|
|
sync_db_with_multi_ipv6_addresses(config('database'),
|
|
|
|
config('database-user'))
|
2014-09-17 17:26:59 +08:00
|
|
|
else:
|
2017-04-25 13:43:44 -07:00
|
|
|
# Avoid churn check for access-network early
|
|
|
|
access_network = None
|
|
|
|
for unit in related_units():
|
|
|
|
access_network = relation_get(unit=unit,
|
|
|
|
attribute='access-network')
|
|
|
|
if access_network:
|
|
|
|
break
|
|
|
|
host = get_relation_ip('shared-db', cidr_network=access_network)
|
2016-04-12 14:50:54 +01:00
|
|
|
|
2014-09-27 01:23:25 +08:00
|
|
|
relation_set(database=config('database'),
|
|
|
|
username=config('database-user'),
|
|
|
|
hostname=host)
|
2014-06-05 11:59:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
@hooks.hook('shared-db-relation-changed')
|
|
|
|
@restart_on_change(restart_map())
|
|
|
|
def db_changed():
|
2020-01-30 12:37:43 +00:00
|
|
|
if is_db_maintenance_mode():
|
|
|
|
log('Database maintenance mode, aborting hook.', level=DEBUG)
|
|
|
|
return
|
2014-06-05 11:59:00 +01:00
|
|
|
if 'shared-db' not in CONFIGS.complete_contexts():
|
|
|
|
log('shared-db relation incomplete. Peer not ready?')
|
|
|
|
return
|
|
|
|
CONFIGS.write_all()
|
2015-04-22 13:38:00 +00:00
|
|
|
conditional_neutron_migration()
|
2018-06-06 12:30:56 -04:00
|
|
|
infoblox_changed()
|
2016-02-03 11:17:14 -08:00
|
|
|
for r_id in relation_ids('neutron-plugin-api-subordinate'):
|
|
|
|
neutron_plugin_api_subordinate_relation_joined(relid=r_id)
|
|
|
|
|
2014-06-17 16:52:42 +01:00
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
@hooks.hook('amqp-relation-broken',
|
|
|
|
'identity-service-relation-broken',
|
2017-12-21 12:04:34 +00:00
|
|
|
'shared-db-relation-broken')
|
2014-06-05 11:59:00 +01:00
|
|
|
def relation_broken():
|
|
|
|
CONFIGS.write_all()
|
|
|
|
|
2014-06-17 16:52:42 +01:00
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
@hooks.hook('identity-service-relation-joined')
|
2014-09-30 09:10:40 +01:00
|
|
|
def identity_joined(rid=None, relation_trigger=False):
|
2017-10-03 09:38:21 +00:00
|
|
|
if config('vip') and not is_clustered():
|
|
|
|
log('Defering registration until clustered', level=DEBUG)
|
|
|
|
return
|
|
|
|
|
2014-07-04 12:51:35 +01:00
|
|
|
public_url = '{}:{}'.format(canonical_url(CONFIGS, PUBLIC),
|
2014-06-27 12:55:45 +01:00
|
|
|
api_port('neutron-server'))
|
2014-07-04 12:51:35 +01:00
|
|
|
admin_url = '{}:{}'.format(canonical_url(CONFIGS, ADMIN),
|
2014-06-27 12:55:45 +01:00
|
|
|
api_port('neutron-server'))
|
2014-07-04 12:51:35 +01:00
|
|
|
internal_url = '{}:{}'.format(canonical_url(CONFIGS, INTERNAL),
|
|
|
|
api_port('neutron-server')
|
2014-07-28 15:33:48 +01:00
|
|
|
)
|
2014-09-30 09:10:40 +01:00
|
|
|
rel_settings = {
|
2016-01-12 11:16:17 +00:00
|
|
|
'neutron_service': 'neutron',
|
|
|
|
'neutron_region': config('region'),
|
|
|
|
'neutron_public_url': public_url,
|
|
|
|
'neutron_admin_url': admin_url,
|
|
|
|
'neutron_internal_url': internal_url,
|
|
|
|
'quantum_service': None,
|
|
|
|
'quantum_region': None,
|
|
|
|
'quantum_public_url': None,
|
|
|
|
'quantum_admin_url': None,
|
|
|
|
'quantum_internal_url': None,
|
2014-06-27 12:55:45 +01:00
|
|
|
}
|
2014-09-30 09:10:40 +01:00
|
|
|
if relation_trigger:
|
|
|
|
rel_settings['relation_trigger'] = str(uuid.uuid4())
|
|
|
|
relation_set(relation_id=rid, relation_settings=rel_settings)
|
2014-06-05 11:59:00 +01:00
|
|
|
|
2014-06-17 16:52:42 +01:00
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
@hooks.hook('identity-service-relation-changed')
|
|
|
|
@restart_on_change(restart_map())
|
|
|
|
def identity_changed():
|
|
|
|
if 'identity-service' not in CONFIGS.complete_contexts():
|
|
|
|
log('identity-service relation incomplete. Peer not ready?')
|
|
|
|
return
|
|
|
|
CONFIGS.write(NEUTRON_CONF)
|
|
|
|
for r_id in relation_ids('neutron-api'):
|
|
|
|
neutron_api_relation_joined(rid=r_id)
|
2015-03-31 14:54:53 +00:00
|
|
|
for r_id in relation_ids('neutron-plugin-api'):
|
|
|
|
neutron_plugin_api_relation_joined(rid=r_id)
|
2016-02-03 11:17:14 -08:00
|
|
|
for r_id in relation_ids('neutron-plugin-api-subordinate'):
|
|
|
|
neutron_plugin_api_subordinate_relation_joined(relid=r_id)
|
2014-06-27 13:19:01 +01:00
|
|
|
configure_https()
|
2018-06-06 12:30:56 -04:00
|
|
|
infoblox_changed()
|
2014-06-17 16:52:42 +01:00
|
|
|
|
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
@hooks.hook('neutron-api-relation-joined')
|
|
|
|
def neutron_api_relation_joined(rid=None):
|
2014-07-04 12:51:35 +01:00
|
|
|
base_url = canonical_url(CONFIGS, INTERNAL)
|
2014-06-05 11:59:00 +01:00
|
|
|
neutron_url = '%s:%s' % (base_url, api_port('neutron-server'))
|
|
|
|
relation_data = {
|
2016-04-18 15:37:32 -06:00
|
|
|
'enable-sriov': config('enable-sriov'),
|
2019-09-30 10:15:01 +01:00
|
|
|
'enable-hardware-offload': config('enable-hardware-offload'),
|
2014-06-23 12:18:17 +01:00
|
|
|
'neutron-url': neutron_url,
|
|
|
|
'neutron-plugin': config('neutron-plugin'),
|
2014-06-05 11:59:00 +01:00
|
|
|
}
|
2014-06-17 09:52:15 +01:00
|
|
|
if config('neutron-security-groups'):
|
2014-06-23 12:18:17 +01:00
|
|
|
relation_data['neutron-security-groups'] = "yes"
|
2014-06-17 09:52:15 +01:00
|
|
|
else:
|
2014-06-23 12:18:17 +01:00
|
|
|
relation_data['neutron-security-groups'] = "no"
|
2016-02-03 11:17:14 -08:00
|
|
|
|
|
|
|
if is_api_ready(CONFIGS):
|
|
|
|
relation_data['neutron-api-ready'] = "yes"
|
|
|
|
else:
|
|
|
|
relation_data['neutron-api-ready'] = "no"
|
|
|
|
|
2018-11-28 10:40:18 -08:00
|
|
|
# LP Bug#1805645
|
|
|
|
dns_domain = get_dns_domain()
|
|
|
|
if dns_domain:
|
|
|
|
relation_data['dns-domain'] = dns_domain
|
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
relation_set(relation_id=rid, **relation_data)
|
2016-01-12 11:16:17 +00:00
|
|
|
# Nova-cc may have grabbed the neutron endpoint so kick identity-service
|
2014-06-23 12:18:17 +01:00
|
|
|
# relation to register that its here
|
2014-06-05 11:59:00 +01:00
|
|
|
for r_id in relation_ids('identity-service'):
|
2014-09-30 09:10:40 +01:00
|
|
|
identity_joined(rid=r_id, relation_trigger=True)
|
2014-06-05 11:59:00 +01:00
|
|
|
|
2014-06-17 16:52:42 +01:00
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
@hooks.hook('neutron-api-relation-changed')
|
|
|
|
@restart_on_change(restart_map())
|
|
|
|
def neutron_api_relation_changed():
|
2014-06-11 09:10:54 +00:00
|
|
|
CONFIGS.write(NEUTRON_CONF)
|
2014-06-09 17:11:19 +00:00
|
|
|
|
2014-06-17 16:52:42 +01:00
|
|
|
|
2018-10-26 15:14:51 +02:00
|
|
|
@hooks.hook('neutron-load-balancer-relation-joined')
|
|
|
|
def neutron_load_balancer_relation_joined(rid=None):
|
|
|
|
relation_data = {}
|
|
|
|
relation_data['neutron-api-ready'] = is_api_ready(CONFIGS)
|
|
|
|
relation_set(relation_id=rid, **relation_data)
|
|
|
|
|
|
|
|
|
|
|
|
@hooks.hook('neutron-load-balancer-relation-changed')
|
|
|
|
@restart_on_change(restart_map())
|
|
|
|
def neutron_load_balancer_relation_changed(rid=None):
|
|
|
|
neutron_load_balancer_relation_joined(rid)
|
|
|
|
CONFIGS.write(NEUTRON_CONF)
|
|
|
|
|
|
|
|
|
2014-06-17 16:07:02 +01:00
|
|
|
@hooks.hook('neutron-plugin-api-relation-joined')
|
|
|
|
def neutron_plugin_api_relation_joined(rid=None):
|
2014-10-14 06:48:48 +00:00
|
|
|
if config('neutron-plugin') == 'nsx':
|
|
|
|
relation_data = {
|
2014-10-14 07:47:50 +00:00
|
|
|
'nsx-username': config('nsx-username'),
|
|
|
|
'nsx-password': config('nsx-password'),
|
|
|
|
'nsx-cluster-name': config('nsx-cluster-name'),
|
|
|
|
'nsx-tz-uuid': config('nsx-tz-uuid'),
|
|
|
|
'nsx-l3-uuid': config('nsx-l3-uuid'),
|
|
|
|
'nsx-controllers': config('nsx-controllers'),
|
2014-10-14 06:48:48 +00:00
|
|
|
}
|
|
|
|
else:
|
|
|
|
relation_data = {
|
|
|
|
'neutron-security-groups': config('neutron-security-groups'),
|
|
|
|
'l2-population': get_l2population(),
|
2015-02-02 13:29:41 +00:00
|
|
|
'enable-dvr': get_dvr(),
|
2015-02-20 11:50:14 +00:00
|
|
|
'enable-l3ha': get_l3ha(),
|
2017-08-07 17:05:28 +01:00
|
|
|
'enable-qos': is_qos_requested_and_valid(),
|
2018-05-23 20:58:16 +03:00
|
|
|
'enable-vlan-trunking': is_vlan_trunking_requested_and_valid(),
|
2018-10-09 11:41:09 +03:00
|
|
|
'enable-nsg-logging': is_nsg_logging_enabled(),
|
2019-06-07 13:01:23 +00:00
|
|
|
'enable-nfg-logging': is_nfg_logging_enabled(),
|
2019-09-02 20:21:39 -04:00
|
|
|
'enable-port-forwarding': is_port_forwarding_enabled(),
|
2021-08-31 11:07:12 +05:30
|
|
|
'enable-fwaas': is_fwaas_enabled(),
|
2014-10-14 06:48:48 +00:00
|
|
|
'overlay-network-type': get_overlay_network_type(),
|
2015-03-10 16:38:49 +00:00
|
|
|
'addr': unit_get('private-address'),
|
2017-07-05 10:39:42 +08:00
|
|
|
'polling-interval': config('polling-interval'),
|
|
|
|
'rpc-response-timeout': config('rpc-response-timeout'),
|
|
|
|
'report-interval': config('report-interval'),
|
2019-06-21 09:06:59 +00:00
|
|
|
'global-physnet-mtu': config('global-physnet-mtu'),
|
|
|
|
'physical-network-mtus': config('physical-network-mtus'),
|
2014-10-14 06:48:48 +00:00
|
|
|
}
|
2015-02-10 09:52:15 +00:00
|
|
|
|
2015-02-11 13:39:13 +00:00
|
|
|
# Provide this value to relations since it needs to be set in multiple
|
|
|
|
# places e.g. neutron.conf, nova.conf
|
|
|
|
net_dev_mtu = config('network-device-mtu')
|
|
|
|
if net_dev_mtu:
|
|
|
|
relation_data['network-device-mtu'] = net_dev_mtu
|
2015-02-10 09:52:15 +00:00
|
|
|
|
2015-03-31 14:52:11 +00:00
|
|
|
identity_ctxt = IdentityServiceContext()()
|
2015-03-31 15:20:42 +00:00
|
|
|
if not identity_ctxt:
|
|
|
|
identity_ctxt = {}
|
|
|
|
|
2015-03-31 14:52:11 +00:00
|
|
|
relation_data.update({
|
|
|
|
'auth_host': identity_ctxt.get('auth_host'),
|
|
|
|
'auth_port': identity_ctxt.get('auth_port'),
|
2015-04-01 12:26:15 +01:00
|
|
|
'auth_protocol': identity_ctxt.get('auth_protocol'),
|
2015-03-31 14:52:11 +00:00
|
|
|
'service_protocol': identity_ctxt.get('service_protocol'),
|
|
|
|
'service_host': identity_ctxt.get('service_host'),
|
|
|
|
'service_port': identity_ctxt.get('service_port'),
|
|
|
|
'service_tenant': identity_ctxt.get('admin_tenant_name'),
|
|
|
|
'service_username': identity_ctxt.get('admin_user'),
|
|
|
|
'service_password': identity_ctxt.get('admin_password'),
|
2021-09-08 11:32:22 +05:30
|
|
|
'internal_host': identity_ctxt.get('internal_host'),
|
|
|
|
'internal_port': identity_ctxt.get('internal_port'),
|
|
|
|
'internal_protocol': identity_ctxt.get('internal_protocol'),
|
2015-03-31 14:52:11 +00:00
|
|
|
'region': config('region'),
|
|
|
|
})
|
|
|
|
|
2017-04-18 23:22:14 -07:00
|
|
|
dns_domain = get_dns_domain()
|
|
|
|
if dns_domain:
|
|
|
|
relation_data['dns-domain'] = dns_domain
|
|
|
|
|
2016-02-03 11:17:14 -08:00
|
|
|
if is_api_ready(CONFIGS):
|
|
|
|
relation_data['neutron-api-ready'] = "yes"
|
|
|
|
else:
|
|
|
|
relation_data['neutron-api-ready'] = "no"
|
|
|
|
|
2014-06-17 16:07:02 +01:00
|
|
|
relation_set(relation_id=rid, **relation_data)
|
|
|
|
|
2014-06-17 16:52:42 +01:00
|
|
|
|
2014-09-30 17:17:06 +08:00
|
|
|
@hooks.hook('cluster-relation-joined')
|
|
|
|
def cluster_joined(relation_id=None):
|
2017-05-04 15:36:23 -07:00
|
|
|
settings = {}
|
|
|
|
|
2014-09-30 09:05:41 +01:00
|
|
|
for addr_type in ADDRESS_TYPES:
|
2017-05-04 15:36:23 -07:00
|
|
|
address = get_relation_ip(
|
|
|
|
addr_type,
|
|
|
|
cidr_network=config('os-{}-network'.format(addr_type)))
|
2014-09-30 09:05:41 +01:00
|
|
|
if address:
|
2017-05-04 15:36:23 -07:00
|
|
|
settings['{}-address'.format(addr_type)] = address
|
|
|
|
|
|
|
|
settings['private-address'] = get_relation_ip('cluster')
|
|
|
|
|
|
|
|
relation_set(relation_id=relation_id, relation_settings=settings)
|
2014-09-30 17:17:06 +08:00
|
|
|
|
2017-08-15 16:50:09 +01:00
|
|
|
if not relation_id:
|
|
|
|
check_local_db_actions_complete()
|
|
|
|
|
2014-09-30 17:17:06 +08:00
|
|
|
|
2014-06-17 08:44:46 +00:00
|
|
|
@hooks.hook('cluster-relation-changed',
|
|
|
|
'cluster-relation-departed')
|
|
|
|
@restart_on_change(restart_map(), stopstart=True)
|
|
|
|
def cluster_changed():
|
|
|
|
CONFIGS.write_all()
|
2017-08-15 16:50:09 +01:00
|
|
|
check_local_db_actions_complete()
|
2014-06-17 08:44:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
@hooks.hook('ha-relation-joined')
|
2016-06-14 15:47:54 -07:00
|
|
|
def ha_joined(relation_id=None):
|
2018-12-03 13:39:25 +00:00
|
|
|
extra_settings = {
|
|
|
|
'delete_resources': ['cl_nova_haproxy']
|
2014-06-17 08:44:46 +00:00
|
|
|
}
|
2018-12-03 13:39:25 +00:00
|
|
|
settings = generate_ha_relation_data(
|
|
|
|
'neutron',
|
|
|
|
extra_settings=extra_settings)
|
|
|
|
relation_set(relation_id=relation_id, **settings)
|
2014-06-17 08:44:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
@hooks.hook('ha-relation-changed')
|
|
|
|
def ha_changed():
|
|
|
|
clustered = relation_get('clustered')
|
|
|
|
if not clustered or clustered in [None, 'None', '']:
|
2014-09-23 15:04:15 +01:00
|
|
|
log('ha_changed: hacluster subordinate'
|
|
|
|
' not fully clustered: %s' % clustered)
|
2014-06-17 08:44:46 +00:00
|
|
|
return
|
|
|
|
log('Cluster configured, notifying other services and updating '
|
|
|
|
'keystone endpoint configuration')
|
|
|
|
for rid in relation_ids('identity-service'):
|
|
|
|
identity_joined(rid=rid)
|
|
|
|
for rid in relation_ids('neutron-api'):
|
|
|
|
neutron_api_relation_joined(rid=rid)
|
|
|
|
|
2014-06-17 16:52:42 +01:00
|
|
|
|
2017-03-01 04:05:44 +03:00
|
|
|
@hooks.hook('neutron-plugin-api-subordinate-relation-joined',
|
|
|
|
'neutron-plugin-api-subordinate-relation-changed')
|
|
|
|
@restart_on_change(restart_map(), stopstart=True)
|
2016-02-03 11:17:14 -08:00
|
|
|
def neutron_plugin_api_subordinate_relation_joined(relid=None):
|
2019-09-25 17:12:26 +02:00
|
|
|
relation_data = {}
|
|
|
|
if is_db_initialised():
|
|
|
|
db_migration_key = 'migrate-database-nonce'
|
|
|
|
if not relid:
|
|
|
|
relid = relation_id()
|
|
|
|
leader_key = '{}-{}'.format(db_migration_key, relid)
|
|
|
|
for unit in related_units(relid):
|
|
|
|
nonce = relation_get(db_migration_key, rid=relid, unit=unit)
|
|
|
|
if nonce:
|
|
|
|
if is_leader() and leader_get(leader_key) != nonce:
|
|
|
|
migrate_neutron_database(upgrade=True)
|
|
|
|
# track nonce in leader storage to avoid superfluous
|
|
|
|
# migrations
|
|
|
|
leader_set({leader_key: nonce})
|
|
|
|
# set nonce back on relation to signal completion to other end
|
|
|
|
# we do this regardless of leadership status so that
|
|
|
|
# subordinates connected to non-leader units can proceed.
|
|
|
|
relation_data[db_migration_key] = nonce
|
|
|
|
|
|
|
|
relation_data['neutron-api-ready'] = 'no'
|
2016-02-03 11:17:14 -08:00
|
|
|
if is_api_ready(CONFIGS):
|
2019-09-25 17:12:26 +02:00
|
|
|
relation_data['neutron-api-ready'] = 'yes'
|
2019-09-25 12:33:50 +02:00
|
|
|
if not manage_plugin():
|
|
|
|
neutron_cc_ctxt = NeutronCCContext()()
|
|
|
|
plugin_instance = NeutronApiSDNContext()
|
|
|
|
neutron_config_data = {
|
|
|
|
k: v for k, v in neutron_cc_ctxt.items()
|
|
|
|
if plugin_instance.is_allowed(k)}
|
|
|
|
if neutron_config_data:
|
|
|
|
relation_data['neutron_config_data'] = json.dumps(
|
|
|
|
neutron_config_data)
|
2016-02-03 11:17:14 -08:00
|
|
|
relation_set(relation_id=relid, **relation_data)
|
|
|
|
|
2017-03-01 04:05:44 +03:00
|
|
|
# there is no race condition with the neutron service restart
|
|
|
|
# as juju propagates the changes done in relation_set only after
|
|
|
|
# the hook exists
|
2014-09-09 13:23:18 +00:00
|
|
|
CONFIGS.write_all()
|
|
|
|
|
|
|
|
|
2014-11-17 13:42:03 +10:00
|
|
|
@hooks.hook('nrpe-external-master-relation-joined',
|
|
|
|
'nrpe-external-master-relation-changed')
|
2014-10-29 22:30:36 -05:00
|
|
|
def update_nrpe_config():
|
2015-01-12 12:04:00 +00:00
|
|
|
# python-dbus is used by check_upstart_job
|
2014-10-29 22:30:36 -05:00
|
|
|
apt_install('python-dbus')
|
2015-01-12 12:04:00 +00:00
|
|
|
hostname = nrpe.get_nagios_hostname()
|
|
|
|
current_unit = nrpe.get_nagios_unit_name()
|
|
|
|
nrpe_setup = nrpe.NRPE(hostname=hostname)
|
2015-02-19 14:21:44 +10:00
|
|
|
nrpe.copy_nrpe_checks()
|
2015-01-12 12:04:00 +00:00
|
|
|
nrpe.add_init_service_checks(nrpe_setup, services(), current_unit)
|
2016-02-03 11:17:14 -08:00
|
|
|
|
2015-02-19 14:21:44 +10:00
|
|
|
nrpe.add_haproxy_checks(nrpe_setup, current_unit)
|
2015-01-12 12:04:00 +00:00
|
|
|
nrpe_setup.write()
|
2014-10-29 22:30:36 -05:00
|
|
|
|
|
|
|
|
2015-06-19 09:18:26 +01:00
|
|
|
@hooks.hook('etcd-proxy-relation-joined')
|
|
|
|
@hooks.hook('etcd-proxy-relation-changed')
|
|
|
|
def etcd_proxy_force_restart(relation_id=None):
|
2015-04-16 11:42:32 +01:00
|
|
|
# note(cory.benfield): Mostly etcd does not require active management,
|
|
|
|
# but occasionally it does require a full config nuking. This does not
|
|
|
|
# play well with the standard neutron-api config management, so we
|
|
|
|
# treat etcd like the special snowflake it insists on being.
|
|
|
|
CONFIGS.register('/etc/init/etcd.conf', [EtcdContext()])
|
|
|
|
CONFIGS.write('/etc/init/etcd.conf')
|
2016-04-05 12:12:24 +01:00
|
|
|
CONFIGS.register('/etc/default/etcd', [EtcdContext()])
|
|
|
|
CONFIGS.write('/etc/default/etcd')
|
2015-06-19 09:18:26 +01:00
|
|
|
|
|
|
|
if 'etcd-proxy' in CONFIGS.complete_contexts():
|
|
|
|
force_etcd_restart()
|
2015-04-16 11:42:32 +01:00
|
|
|
|
|
|
|
|
2016-01-22 16:14:59 +01:00
|
|
|
@hooks.hook('midonet-relation-joined')
|
|
|
|
@hooks.hook('midonet-relation-changed')
|
|
|
|
@hooks.hook('midonet-relation-departed')
|
|
|
|
@restart_on_change(restart_map())
|
|
|
|
def midonet_changed():
|
|
|
|
CONFIGS.write_all()
|
|
|
|
|
|
|
|
|
2017-11-20 10:52:41 +01:00
|
|
|
@hooks.hook('external-dns-relation-joined',
|
|
|
|
'external-dns-relation-changed',
|
|
|
|
'external-dns-relation-departed',
|
|
|
|
'external-dns-relation-broken')
|
|
|
|
@restart_on_change(restart_map())
|
|
|
|
def designate_changed():
|
|
|
|
CONFIGS.write_all()
|
|
|
|
|
|
|
|
|
2018-06-06 12:30:56 -04:00
|
|
|
@hooks.hook('infoblox-neutron-relation-changed')
|
|
|
|
@restart_on_change(restart_map)
|
|
|
|
def infoblox_changed():
|
|
|
|
# The neutron DB upgrade will add new tables to
|
|
|
|
# neutron db related to infoblox service.
|
|
|
|
# Please take a look to charm-infoblox docs.
|
|
|
|
if 'infoblox-neutron' not in CONFIGS.complete_contexts():
|
|
|
|
log('infoblox-neutron relation incomplete. Peer not ready?')
|
|
|
|
return
|
|
|
|
|
|
|
|
CONFIGS.write(NEUTRON_CONF)
|
|
|
|
|
|
|
|
if is_leader():
|
|
|
|
ready = False
|
|
|
|
if is_db_initialised() and neutron_ready():
|
|
|
|
migrate_neutron_database(upgrade=True)
|
|
|
|
ready = True
|
|
|
|
for rid in relation_ids('infoblox-neutron'):
|
|
|
|
relation_set(relation_id=rid, neutron_api_ready=ready)
|
|
|
|
|
|
|
|
|
|
|
|
@hooks.hook('infoblox-neutron-relation-departed',
|
|
|
|
'infoblox-neutron-relation-broken')
|
|
|
|
@restart_on_change(restart_map)
|
|
|
|
def infoblox_departed():
|
|
|
|
CONFIGS.write_all()
|
|
|
|
|
|
|
|
|
2016-03-22 20:59:52 +00:00
|
|
|
@hooks.hook('update-status')
|
|
|
|
@harden()
|
|
|
|
@harden()
|
|
|
|
def update_status():
|
|
|
|
log('Updating status.')
|
|
|
|
|
|
|
|
|
2018-05-15 14:20:20 +00:00
|
|
|
@hooks.hook('certificates-relation-joined')
|
|
|
|
def certs_joined(relation_id=None):
|
|
|
|
relation_set(
|
|
|
|
relation_id=relation_id,
|
|
|
|
relation_settings=get_certificate_request())
|
|
|
|
|
|
|
|
|
|
|
|
@hooks.hook('certificates-relation-changed')
|
|
|
|
@restart_on_change(restart_map(), stopstart=True)
|
|
|
|
def certs_changed(relation_id=None, unit=None):
|
|
|
|
process_certificates('neutron', relation_id, unit)
|
|
|
|
configure_https()
|
2020-02-17 11:08:20 +00:00
|
|
|
# If endpoint has switched to https, need to tell
|
|
|
|
# nova-cc
|
|
|
|
for r_id in relation_ids('neutron-api'):
|
|
|
|
neutron_api_relation_joined(rid=r_id)
|
2018-05-15 14:20:20 +00:00
|
|
|
|
|
|
|
|
2018-09-18 10:18:19 +00:00
|
|
|
@hooks.hook('pre-series-upgrade')
|
|
|
|
def pre_series_upgrade():
|
|
|
|
log("Running prepare series upgrade hook", "INFO")
|
|
|
|
series_upgrade_prepare(
|
|
|
|
pause_unit_helper, CONFIGS)
|
|
|
|
|
|
|
|
|
|
|
|
@hooks.hook('post-series-upgrade')
|
|
|
|
def post_series_upgrade():
|
|
|
|
log("Running complete series upgrade hook", "INFO")
|
|
|
|
series_upgrade_complete(
|
|
|
|
resume_unit_helper, CONFIGS)
|
|
|
|
|
|
|
|
|
2014-06-05 11:59:00 +01:00
|
|
|
def main():
|
|
|
|
try:
|
|
|
|
hooks.execute(sys.argv)
|
|
|
|
except UnregisteredHookError as e:
|
|
|
|
log('Unknown hook {} - skipping.'.format(e))
|
2016-09-30 09:58:42 +01:00
|
|
|
assess_status(CONFIGS)
|
2014-06-05 11:59:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|