Charmhelper sync for 20.02
Change-Id: Ib2e4cb4f12c1d0868af73c8b690b7cd5ebff76c2
This commit is contained in:
parent
62c990fede
commit
98c8156538
|
@ -52,7 +52,7 @@ class RestrictedPackages(BaseAudit):
|
|||
def __init__(self, pkgs, **kwargs):
|
||||
super(RestrictedPackages, self).__init__(**kwargs)
|
||||
if isinstance(pkgs, string_types) or not hasattr(pkgs, '__iter__'):
|
||||
self.pkgs = [pkgs]
|
||||
self.pkgs = pkgs.split()
|
||||
else:
|
||||
self.pkgs = pkgs
|
||||
|
||||
|
@ -100,4 +100,5 @@ class RestrictedPackages(BaseAudit):
|
|||
apt_purge(pkg.name)
|
||||
|
||||
def is_virtual_package(self, pkg):
|
||||
return pkg.has_provides and not pkg.has_versions
|
||||
return (pkg.get('has_provides', False) and
|
||||
not pkg.get('has_versions', False))
|
||||
|
|
|
@ -44,6 +44,7 @@ from charmhelpers.core.hookenv import (
|
|||
INFO,
|
||||
ERROR,
|
||||
related_units,
|
||||
relation_get,
|
||||
relation_ids,
|
||||
relation_set,
|
||||
status_set,
|
||||
|
@ -331,6 +332,10 @@ PACKAGE_CODENAMES = {
|
|||
|
||||
DEFAULT_LOOPBACK_SIZE = '5G'
|
||||
|
||||
DB_SERIES_UPGRADING_KEY = 'cluster-series-upgrading'
|
||||
|
||||
DB_MAINTENANCE_KEYS = [DB_SERIES_UPGRADING_KEY]
|
||||
|
||||
|
||||
class CompareOpenStackReleases(BasicStringComparator):
|
||||
"""Provide comparisons of OpenStack releases.
|
||||
|
@ -1912,3 +1917,33 @@ def set_db_initialised():
|
|||
"""
|
||||
juju_log('Setting db-initialised to True', 'DEBUG')
|
||||
leader_set({'db-initialised': True})
|
||||
|
||||
|
||||
def is_db_maintenance_mode(relid=None):
|
||||
"""Check relation data from notifications of db in maintenance mode.
|
||||
|
||||
:returns: Whether db has notified it is in maintenance mode.
|
||||
:rtype: bool
|
||||
"""
|
||||
juju_log('Checking for maintenance notifications', 'DEBUG')
|
||||
if relid:
|
||||
r_ids = [relid]
|
||||
else:
|
||||
r_ids = relation_ids('shared-db')
|
||||
rids_units = [(r, u) for r in r_ids for u in related_units(r)]
|
||||
notifications = []
|
||||
for r_id, unit in rids_units:
|
||||
settings = relation_get(unit=unit, rid=r_id)
|
||||
for key, value in settings.items():
|
||||
if value and key in DB_MAINTENANCE_KEYS:
|
||||
juju_log(
|
||||
'Unit: {}, Key: {}, Value: {}'.format(unit, key, value),
|
||||
'DEBUG')
|
||||
try:
|
||||
notifications.append(bool_from_string(value))
|
||||
except ValueError:
|
||||
juju_log(
|
||||
'Could not discern bool from {}'.format(value),
|
||||
'WARN')
|
||||
pass
|
||||
return True in notifications
|
||||
|
|
|
@ -38,6 +38,7 @@ so with this we get rid of the dependency.
|
|||
import locale
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
class _container(dict):
|
||||
|
@ -59,6 +60,13 @@ class Cache(object):
|
|||
def __init__(self, progress=None):
|
||||
pass
|
||||
|
||||
def __contains__(self, package):
|
||||
try:
|
||||
pkg = self.__getitem__(package)
|
||||
return pkg is not None
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
def __getitem__(self, package):
|
||||
"""Get information about a package from apt and dpkg databases.
|
||||
|
||||
|
@ -178,6 +186,28 @@ class Cache(object):
|
|||
return pkgs
|
||||
|
||||
|
||||
class Config(_container):
|
||||
def __init__(self):
|
||||
super(Config, self).__init__(self._populate())
|
||||
|
||||
def _populate(self):
|
||||
cfgs = {}
|
||||
cmd = ['apt-config', 'dump']
|
||||
output = subprocess.check_output(cmd,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True)
|
||||
for line in output.splitlines():
|
||||
if not line.startswith("CommandLine"):
|
||||
k, v = line.split(" ", 1)
|
||||
cfgs[k] = v.strip(";").strip("\"")
|
||||
|
||||
return cfgs
|
||||
|
||||
|
||||
# Backwards compatibility with old apt_pkg module
|
||||
sys.modules[__name__].config = Config()
|
||||
|
||||
|
||||
def init():
|
||||
"""Compability shim that does nothing."""
|
||||
pass
|
||||
|
|
|
@ -20,6 +20,9 @@ def get_platform():
|
|||
# Stock Python does not detect Ubuntu and instead returns debian.
|
||||
# Or at least it does in some build environments like Travis CI
|
||||
return "ubuntu"
|
||||
elif "elementary" in current_platform:
|
||||
# ElementaryOS fails to run tests locally without this.
|
||||
return "ubuntu"
|
||||
else:
|
||||
raise RuntimeError("This module is not supported on {}."
|
||||
.format(current_platform))
|
||||
|
|
|
@ -12,7 +12,6 @@ tags:
|
|||
series:
|
||||
- xenial
|
||||
- bionic
|
||||
- disco
|
||||
- eoan
|
||||
- trusty
|
||||
extra-bindings:
|
||||
|
|
|
@ -13,7 +13,6 @@ gate_bundles:
|
|||
- bionic-rocky # mimic
|
||||
- bionic-stein
|
||||
- bionic-train
|
||||
- disco-stein
|
||||
dev_bundles:
|
||||
# Icehouse
|
||||
- trusty-icehouse
|
||||
|
|
Loading…
Reference in New Issue