From be3f9519f1cb82623e5078beb627dc116ee161ac Mon Sep 17 00:00:00 2001 From: David Ames Date: Tue, 12 Feb 2019 15:57:55 -0800 Subject: [PATCH] Update charm-helpers-hooks.yaml and sync ch Using the new version of the sync tool which removes the charmhelpers directory before syncing, run charm helpers sync to find any unexpected missing dependencies. Change-Id: I7623310b49dceccbb584c31d2b1e44edbe872019 --- charm-helpers-hooks.yaml | 2 +- .../contrib/openstack/amulet/utils.py | 16 ++++----- .../charmhelpers/contrib/openstack/context.py | 10 +++--- .../contrib/openstack/templating.py | 2 +- hooks/charmhelpers/contrib/openstack/utils.py | 18 ++++++++-- hooks/charmhelpers/contrib/python.py | 21 ++++++++++++ hooks/charmhelpers/contrib/python/version.py | 34 ------------------- hooks/charmhelpers/core/host.py | 1 + .../charmhelpers/core/host_factory/ubuntu.py | 8 +++++ .../{contrib => fetch}/python/__init__.py | 2 +- .../{contrib => fetch}/python/debug.py | 28 +++++++-------- .../{contrib => fetch}/python/packages.py | 0 .../{contrib => fetch}/python/rpdb.py | 26 +++++++------- hooks/charmhelpers/fetch/python/version.py | 32 +++++++++++++++++ 14 files changed, 118 insertions(+), 82 deletions(-) create mode 100644 hooks/charmhelpers/contrib/python.py delete mode 100644 hooks/charmhelpers/contrib/python/version.py rename hooks/charmhelpers/{contrib => fetch}/python/__init__.py (92%) rename hooks/charmhelpers/{contrib => fetch}/python/debug.py (58%) rename hooks/charmhelpers/{contrib => fetch}/python/packages.py (100%) rename hooks/charmhelpers/{contrib => fetch}/python/rpdb.py (68%) create mode 100644 hooks/charmhelpers/fetch/python/version.py diff --git a/charm-helpers-hooks.yaml b/charm-helpers-hooks.yaml index fbe21c02..5cd91bf0 100644 --- a/charm-helpers-hooks.yaml +++ b/charm-helpers-hooks.yaml @@ -11,7 +11,7 @@ include: - apache - cluster - contrib.network - - contrib.python.packages + - contrib.python - payload - contrib.charmsupport - contrib.hardening|inc=* diff --git a/hooks/charmhelpers/contrib/openstack/amulet/utils.py b/hooks/charmhelpers/contrib/openstack/amulet/utils.py index ea1fd8f3..53fa6506 100644 --- a/hooks/charmhelpers/contrib/openstack/amulet/utils.py +++ b/hooks/charmhelpers/contrib/openstack/amulet/utils.py @@ -88,14 +88,14 @@ class OpenStackAmuletUtils(AmuletUtils): validation_function = self.validate_v2_endpoint_data xenial_queens = OPENSTACK_RELEASES_PAIRS.index('xenial_queens') if openstack_release and openstack_release >= xenial_queens: - validation_function = self.validate_v3_endpoint_data - expected = { - 'id': expected['id'], - 'region': expected['region'], - 'region_id': 'RegionOne', - 'url': self.valid_url, - 'interface': self.not_null, - 'service_id': expected['service_id']} + validation_function = self.validate_v3_endpoint_data + expected = { + 'id': expected['id'], + 'region': expected['region'], + 'region_id': 'RegionOne', + 'url': self.valid_url, + 'interface': self.not_null, + 'service_id': expected['service_id']} return validation_function(endpoints, admin_port, internal_port, public_port, expected) diff --git a/hooks/charmhelpers/contrib/openstack/context.py b/hooks/charmhelpers/contrib/openstack/context.py index 8a203754..78a339f6 100644 --- a/hooks/charmhelpers/contrib/openstack/context.py +++ b/hooks/charmhelpers/contrib/openstack/context.py @@ -1427,11 +1427,11 @@ class ZeroMQContext(OSContextGenerator): ctxt = {} if is_relation_made('zeromq-configuration', 'host'): for rid in relation_ids('zeromq-configuration'): - for unit in related_units(rid): - ctxt['zmq_nonce'] = relation_get('nonce', unit, rid) - ctxt['zmq_host'] = relation_get('host', unit, rid) - ctxt['zmq_redis_address'] = relation_get( - 'zmq_redis_address', unit, rid) + for unit in related_units(rid): + ctxt['zmq_nonce'] = relation_get('nonce', unit, rid) + ctxt['zmq_host'] = relation_get('host', unit, rid) + ctxt['zmq_redis_address'] = relation_get( + 'zmq_redis_address', unit, rid) return ctxt diff --git a/hooks/charmhelpers/contrib/openstack/templating.py b/hooks/charmhelpers/contrib/openstack/templating.py index a623315d..050f8af5 100644 --- a/hooks/charmhelpers/contrib/openstack/templating.py +++ b/hooks/charmhelpers/contrib/openstack/templating.py @@ -183,7 +183,7 @@ class OSConfigRenderer(object): /tmp/templates/grizzly/api-paste.ini /tmp/templates/havana/api-paste.ini - Since it was registered with the grizzly release, it first seraches + Since it was registered with the grizzly release, it first searches the grizzly directory for nova.conf, then the templates dir. When writing api-paste.ini, it will find the template in the grizzly diff --git a/hooks/charmhelpers/contrib/openstack/utils.py b/hooks/charmhelpers/contrib/openstack/utils.py index 4e432a25..86b011b7 100644 --- a/hooks/charmhelpers/contrib/openstack/utils.py +++ b/hooks/charmhelpers/contrib/openstack/utils.py @@ -83,7 +83,8 @@ from charmhelpers.fetch import ( add_source as fetch_add_source, SourceConfigError, GPGKeyError, - get_upstream_version + get_upstream_version, + filter_missing_packages ) from charmhelpers.fetch.snap import ( @@ -309,6 +310,15 @@ def error_out(msg): sys.exit(1) +def get_installed_semantic_versioned_packages(): + '''Get a list of installed packages which have OpenStack semantic versioning + + :returns List of installed packages + :rtype: [pkg1, pkg2, ...] + ''' + return filter_missing_packages(PACKAGE_CODENAMES.keys()) + + def get_os_codename_install_source(src): '''Derive OpenStack release codename from a given installation source.''' ubuntu_rel = lsb_release()['DISTRIB_CODENAME'] @@ -972,7 +982,9 @@ def _ows_check_charm_func(state, message, charm_func_with_configs): """ if charm_func_with_configs: charm_state, charm_message = charm_func_with_configs() - if charm_state != 'active' and charm_state != 'unknown': + if (charm_state != 'active' and + charm_state != 'unknown' and + charm_state is not None): state = workload_state_compare(state, charm_state) if message: charm_message = charm_message.replace("Incomplete relations: ", @@ -1241,7 +1253,7 @@ def remote_restart(rel_name, remote_service=None): def check_actually_paused(services=None, ports=None): - """Check that services listed in the services object and and ports + """Check that services listed in the services object and ports are actually closed (not listened to), to verify that the unit is properly paused. diff --git a/hooks/charmhelpers/contrib/python.py b/hooks/charmhelpers/contrib/python.py new file mode 100644 index 00000000..84cba8c4 --- /dev/null +++ b/hooks/charmhelpers/contrib/python.py @@ -0,0 +1,21 @@ +# Copyright 2014-2019 Canonical Limited. +# +# 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. + +from __future__ import absolute_import + +# deprecated aliases for backwards compatibility +from charmhelpers.fetch.python import debug # noqa +from charmhelpers.fetch.python import packages # noqa +from charmhelpers.fetch.python import rpdb # noqa +from charmhelpers.fetch.python import version # noqa diff --git a/hooks/charmhelpers/contrib/python/version.py b/hooks/charmhelpers/contrib/python/version.py deleted file mode 100644 index 6dc11296..00000000 --- a/hooks/charmhelpers/contrib/python/version.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright 2014-2015 Canonical Limited. -# -# This file is part of charm-helpers. -# -# charm-helpers is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 as -# published by the Free Software Foundation. -# -# charm-helpers is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with charm-helpers. If not, see . - -__author__ = "Jorge Niedbalski " - -import sys - - -def current_version(): - """Current system python version""" - return sys.version_info - - -def current_version_string(): - """Current system python version as string major.minor.micro""" - return "{0}.{1}.{2}".format(sys.version_info.major, - sys.version_info.minor, - sys.version_info.micro) diff --git a/hooks/charmhelpers/core/host.py b/hooks/charmhelpers/core/host.py index 79953a44..47c1fc35 100644 --- a/hooks/charmhelpers/core/host.py +++ b/hooks/charmhelpers/core/host.py @@ -46,6 +46,7 @@ if __platform__ == "ubuntu": lsb_release, cmp_pkgrevno, CompareHostReleases, + get_distrib_codename, ) # flake8: noqa -- ignore F401 for this import elif __platform__ == "centos": from charmhelpers.core.host_factory.centos import ( # NOQA:F401 diff --git a/hooks/charmhelpers/core/host_factory/ubuntu.py b/hooks/charmhelpers/core/host_factory/ubuntu.py index a6d375af..d7e920eb 100644 --- a/hooks/charmhelpers/core/host_factory/ubuntu.py +++ b/hooks/charmhelpers/core/host_factory/ubuntu.py @@ -72,6 +72,14 @@ def lsb_release(): return d +def get_distrib_codename(): + """Return the codename of the distribution + :returns: The codename + :rtype: str + """ + return lsb_release()['DISTRIB_CODENAME'].lower() + + def cmp_pkgrevno(package, revno, pkgcache=None): """Compare supplied revno with the revno of the installed package. diff --git a/hooks/charmhelpers/contrib/python/__init__.py b/hooks/charmhelpers/fetch/python/__init__.py similarity index 92% rename from hooks/charmhelpers/contrib/python/__init__.py rename to hooks/charmhelpers/fetch/python/__init__.py index d7567b86..bff99dc9 100644 --- a/hooks/charmhelpers/contrib/python/__init__.py +++ b/hooks/charmhelpers/fetch/python/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2015 Canonical Limited. +# Copyright 2014-2019 Canonical Limited. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/hooks/charmhelpers/contrib/python/debug.py b/hooks/charmhelpers/fetch/python/debug.py similarity index 58% rename from hooks/charmhelpers/contrib/python/debug.py rename to hooks/charmhelpers/fetch/python/debug.py index 960770f2..757135ee 100644 --- a/hooks/charmhelpers/contrib/python/debug.py +++ b/hooks/charmhelpers/fetch/python/debug.py @@ -3,28 +3,24 @@ # Copyright 2014-2015 Canonical Limited. # -# This file is part of charm-helpers. +# 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 # -# charm-helpers is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 as -# published by the Free Software Foundation. +# http://www.apache.org/licenses/LICENSE-2.0 # -# charm-helpers is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with charm-helpers. If not, see . +# 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. from __future__ import print_function -__author__ = "Jorge Niedbalski " - import atexit import sys -from charmhelpers.contrib.python.rpdb import Rpdb +from charmhelpers.fetch.python.rpdb import Rpdb from charmhelpers.core.hookenv import ( open_port, close_port, @@ -32,6 +28,8 @@ from charmhelpers.core.hookenv import ( log ) +__author__ = "Jorge Niedbalski " + DEFAULT_ADDR = "0.0.0.0" DEFAULT_PORT = 4444 @@ -51,6 +49,6 @@ def set_trace(addr=DEFAULT_ADDR, port=DEFAULT_PORT): open_port(port) debugger = Rpdb(addr=addr, port=port) debugger.set_trace(sys._getframe().f_back) - except: + except Exception: _error("Cannot start a remote debug session on %s:%s" % (addr, port)) diff --git a/hooks/charmhelpers/contrib/python/packages.py b/hooks/charmhelpers/fetch/python/packages.py similarity index 100% rename from hooks/charmhelpers/contrib/python/packages.py rename to hooks/charmhelpers/fetch/python/packages.py diff --git a/hooks/charmhelpers/contrib/python/rpdb.py b/hooks/charmhelpers/fetch/python/rpdb.py similarity index 68% rename from hooks/charmhelpers/contrib/python/rpdb.py rename to hooks/charmhelpers/fetch/python/rpdb.py index 80bf66aa..9b31610c 100644 --- a/hooks/charmhelpers/contrib/python/rpdb.py +++ b/hooks/charmhelpers/fetch/python/rpdb.py @@ -1,28 +1,26 @@ # Copyright 2014-2015 Canonical Limited. # -# This file is part of charm-helpers. +# 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 # -# charm-helpers is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 as -# published by the Free Software Foundation. +# http://www.apache.org/licenses/LICENSE-2.0 # -# charm-helpers is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with charm-helpers. If not, see . +# 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. """Remote Python Debugger (pdb wrapper).""" -__author__ = "Bertrand Janin " -__version__ = "0.1.3" - import pdb import socket import sys +__author__ = "Bertrand Janin " +__version__ = "0.1.3" + class Rpdb(pdb.Pdb): diff --git a/hooks/charmhelpers/fetch/python/version.py b/hooks/charmhelpers/fetch/python/version.py new file mode 100644 index 00000000..3eb42103 --- /dev/null +++ b/hooks/charmhelpers/fetch/python/version.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# coding: utf-8 + +# Copyright 2014-2015 Canonical Limited. +# +# 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. + +import sys + +__author__ = "Jorge Niedbalski " + + +def current_version(): + """Current system python version""" + return sys.version_info + + +def current_version_string(): + """Current system python version as string major.minor.micro""" + return "{0}.{1}.{2}".format(sys.version_info.major, + sys.version_info.minor, + sys.version_info.micro)