Fix install hook on Groovy

Also add Groovy to the test gate and sync libraries

Change-Id: If32560a88cfa6735bf5e502a70e6b84b0171f045
Closes-Bug: #1903546
This commit is contained in:
Aurelien Lourot 2020-11-05 12:47:13 +01:00
parent a2797151f7
commit 2e799e5cf0
6 changed files with 48 additions and 11 deletions

View File

@ -33,6 +33,7 @@ INTERNAL = 'int'
ADMIN = 'admin' ADMIN = 'admin'
ACCESS = 'access' ACCESS = 'access'
# TODO: reconcile 'int' vs 'internal' binding names
ADDRESS_MAP = { ADDRESS_MAP = {
PUBLIC: { PUBLIC: {
'binding': 'public', 'binding': 'public',
@ -58,6 +59,14 @@ ADDRESS_MAP = {
'fallback': 'private-address', 'fallback': 'private-address',
'override': 'os-access-hostname', 'override': 'os-access-hostname',
}, },
# Note (thedac) bridge to begin the reconciliation between 'int' vs
# 'internal' binding names
'internal': {
'binding': 'internal',
'config': 'os-internal-network',
'fallback': 'private-address',
'override': 'os-internal-hostname',
},
} }
@ -195,3 +204,10 @@ def get_vip_in_network(network):
if is_address_in_network(network, vip): if is_address_in_network(network, vip):
matching_vip = vip matching_vip = vip
return matching_vip return matching_vip
def get_default_api_bindings():
_default_bindings = []
for binding in [INTERNAL, ADMIN, PUBLIC]:
_default_bindings.append(ADDRESS_MAP[binding]['binding'])
return _default_bindings

View File

@ -230,7 +230,7 @@ SWIFT_CODENAMES = OrderedDict([
('ussuri', ('ussuri',
['2.24.0', '2.25.0']), ['2.24.0', '2.25.0']),
('victoria', ('victoria',
['2.25.0']), ['2.25.0', '2.26.0']),
]) ])
# >= Liberty version->codename mapping # >= Liberty version->codename mapping

View File

@ -41,6 +41,7 @@ from subprocess import (
) )
from charmhelpers import deprecate from charmhelpers import deprecate
from charmhelpers.core.hookenv import ( from charmhelpers.core.hookenv import (
application_name,
config, config,
service_name, service_name,
local_unit, local_unit,
@ -162,6 +163,17 @@ def get_osd_settings(relation_name):
return _order_dict_by_key(osd_settings) return _order_dict_by_key(osd_settings)
def send_application_name(relid=None):
"""Send the application name down the relation.
:param relid: Relation id to set application name in.
:type relid: str
"""
relation_set(
relation_id=relid,
relation_settings={'application-name': application_name()})
def send_osd_settings(): def send_osd_settings():
"""Pass on requested OSD settings to osd units.""" """Pass on requested OSD settings to osd units."""
try: try:
@ -1074,7 +1086,10 @@ def create_erasure_profile(service, profile_name,
erasure_plugin_technique=None): erasure_plugin_technique=None):
"""Create a new erasure code profile if one does not already exist for it. """Create a new erasure code profile if one does not already exist for it.
Updates the profile if it exists. Please refer to [0] for more details. Profiles are considered immutable so will not be updated if the named
profile already exists.
Please refer to [0] for more details.
0: http://docs.ceph.com/docs/master/rados/operations/erasure-code-profile/ 0: http://docs.ceph.com/docs/master/rados/operations/erasure-code-profile/
@ -1110,6 +1125,11 @@ def create_erasure_profile(service, profile_name,
:type erasure_plugin_technique: str :type erasure_plugin_technique: str
:return: None. Can raise CalledProcessError, ValueError or AssertionError :return: None. Can raise CalledProcessError, ValueError or AssertionError
""" """
if erasure_profile_exists(service, profile_name):
log('EC profile {} exists, skipping update'.format(profile_name),
level=WARNING)
return
plugin_techniques = { plugin_techniques = {
'jerasure': [ 'jerasure': [
'reed_sol_van', 'reed_sol_van',
@ -1209,9 +1229,6 @@ def create_erasure_profile(service, profile_name,
if scalar_mds: if scalar_mds:
cmd.append('scalar-mds={}'.format(scalar_mds)) cmd.append('scalar-mds={}'.format(scalar_mds))
if erasure_profile_exists(service, profile_name):
cmd.append('--force')
check_call(cmd) check_call(cmd)
@ -2198,6 +2215,7 @@ def send_request_if_needed(request, relation='ceph'):
for rid in relation_ids(relation): for rid in relation_ids(relation):
log('Sending request {}'.format(request.request_id), level=DEBUG) log('Sending request {}'.format(request.request_id), level=DEBUG)
relation_set(relation_id=rid, broker_req=request.request) relation_set(relation_id=rid, broker_req=request.request)
relation_set(relation_id=rid, relation_settings={'unit-name': local_unit()})
def has_broker_rsp(rid=None, unit=None): def has_broker_rsp(rid=None, unit=None):

View File

@ -126,7 +126,6 @@ from charmhelpers.contrib.charmsupport import nrpe
hooks = Hooks() hooks = Hooks()
PACKAGES = ['corosync', 'pacemaker', 'python-netaddr', 'ipmitool']
COROSYNC_CONF = '/etc/corosync/corosync.conf' COROSYNC_CONF = '/etc/corosync/corosync.conf'
COROSYNC_DEFAULT = '/etc/default/corosync' COROSYNC_DEFAULT = '/etc/default/corosync'
COROSYNC_AUTHKEY = '/etc/corosync/authkey' COROSYNC_AUTHKEY = '/etc/corosync/authkey'
@ -137,7 +136,7 @@ COROSYNC_CONF_FILES = [
COROSYNC_CONF COROSYNC_CONF
] ]
PACKAGES = ['crmsh', 'corosync', 'pacemaker', 'python-netaddr', 'ipmitool', PACKAGES = ['crmsh', 'corosync', 'pacemaker', 'python3-netaddr', 'ipmitool',
'libmonitoring-plugin-perl', 'python3-requests-oauthlib'] 'libmonitoring-plugin-perl', 'python3-requests-oauthlib']
SUPPORTED_TRANSPORTS = ['udp', 'udpu', 'multicast', 'unicast'] SUPPORTED_TRANSPORTS = ['udp', 'udpu', 'multicast', 'unicast']
@ -148,12 +147,17 @@ DEPRECATED_TRANSPORT_VALUES = {"multicast": "udp", "unicast": "udpu"}
def install(): def install():
pkgs = copy.deepcopy(PACKAGES) pkgs = copy.deepcopy(PACKAGES)
ubuntu_release = lsb_release()['DISTRIB_CODENAME'].lower() ubuntu_release = lsb_release()['DISTRIB_CODENAME'].lower()
# use libnagios on anything older than Xenial
if CompareHostReleases(ubuntu_release) < 'xenial': if CompareHostReleases(ubuntu_release) < 'xenial':
# use libnagios on anything older than Xenial
pkgs.remove('libmonitoring-plugin-perl') pkgs.remove('libmonitoring-plugin-perl')
pkgs.append('libnagios-plugin-perl') pkgs.append('libnagios-plugin-perl')
pkgs.remove('python3-netaddr')
pkgs.append('python-netaddr')
elif CompareHostReleases(ubuntu_release) >= 'bionic': elif CompareHostReleases(ubuntu_release) >= 'bionic':
pkgs.append('python3-libmaas') pkgs.append('python3-libmaas')
# NOTE(dosaboy): we currently disallow upgrades due to bug #1382842. This # NOTE(dosaboy): we currently disallow upgrades due to bug #1382842. This
# should be removed once the pacemaker package is fixed. # should be removed once the pacemaker package is fixed.
status_set('maintenance', 'Installing apt packages') status_set('maintenance', 'Installing apt packages')

View File

@ -15,7 +15,6 @@ gate_bundles:
- bionic-ussuri - bionic-ussuri
- focal-ussuri - focal-ussuri
- focal-victoria - focal-victoria
dev_bundles:
- groovy-victoria - groovy-victoria
configure: configure:

View File

@ -327,7 +327,7 @@ class TestHooks(test_utils.CharmTestCase):
'DISTRIB_CODENAME': 'xenial'} 'DISTRIB_CODENAME': 'xenial'}
filter_installed_packages.side_effect = lambda x: x filter_installed_packages.side_effect = lambda x: x
expected_pkgs = [ expected_pkgs = [
'crmsh', 'corosync', 'pacemaker', 'python-netaddr', 'ipmitool', 'crmsh', 'corosync', 'pacemaker', 'python3-netaddr', 'ipmitool',
'libmonitoring-plugin-perl', 'python3-requests-oauthlib'] 'libmonitoring-plugin-perl', 'python3-requests-oauthlib']
hooks.install() hooks.install()
status_set.assert_called_once_with( status_set.assert_called_once_with(
@ -348,7 +348,7 @@ class TestHooks(test_utils.CharmTestCase):
'DISTRIB_CODENAME': 'bionic'} 'DISTRIB_CODENAME': 'bionic'}
filter_installed_packages.side_effect = lambda x: x filter_installed_packages.side_effect = lambda x: x
expected_pkgs = [ expected_pkgs = [
'crmsh', 'corosync', 'pacemaker', 'python-netaddr', 'ipmitool', 'crmsh', 'corosync', 'pacemaker', 'python3-netaddr', 'ipmitool',
'libmonitoring-plugin-perl', 'python3-requests-oauthlib', 'libmonitoring-plugin-perl', 'python3-requests-oauthlib',
'python3-libmaas'] 'python3-libmaas']
hooks.install() hooks.install()