Merge "Update charm-helpers-hooks.yaml and sync ch"

This commit is contained in:
Zuul 2019-02-19 16:00:24 +00:00 committed by Gerrit Code Review
commit 2dca259156
14 changed files with 83 additions and 26 deletions

View File

@ -15,6 +15,6 @@ include:
- payload - payload
- contrib.peerstorage - contrib.peerstorage
- contrib.network.ip - contrib.network.ip
- contrib.python.packages - contrib.python
- contrib.charmsupport - contrib.charmsupport
- contrib.hardening|inc=* - contrib.hardening|inc=*

View File

@ -88,14 +88,14 @@ class OpenStackAmuletUtils(AmuletUtils):
validation_function = self.validate_v2_endpoint_data validation_function = self.validate_v2_endpoint_data
xenial_queens = OPENSTACK_RELEASES_PAIRS.index('xenial_queens') xenial_queens = OPENSTACK_RELEASES_PAIRS.index('xenial_queens')
if openstack_release and openstack_release >= xenial_queens: if openstack_release and openstack_release >= xenial_queens:
validation_function = self.validate_v3_endpoint_data validation_function = self.validate_v3_endpoint_data
expected = { expected = {
'id': expected['id'], 'id': expected['id'],
'region': expected['region'], 'region': expected['region'],
'region_id': 'RegionOne', 'region_id': 'RegionOne',
'url': self.valid_url, 'url': self.valid_url,
'interface': self.not_null, 'interface': self.not_null,
'service_id': expected['service_id']} 'service_id': expected['service_id']}
return validation_function(endpoints, admin_port, internal_port, return validation_function(endpoints, admin_port, internal_port,
public_port, expected) public_port, expected)

View File

@ -1427,11 +1427,11 @@ class ZeroMQContext(OSContextGenerator):
ctxt = {} ctxt = {}
if is_relation_made('zeromq-configuration', 'host'): if is_relation_made('zeromq-configuration', 'host'):
for rid in relation_ids('zeromq-configuration'): for rid in relation_ids('zeromq-configuration'):
for unit in related_units(rid): for unit in related_units(rid):
ctxt['zmq_nonce'] = relation_get('nonce', unit, rid) ctxt['zmq_nonce'] = relation_get('nonce', unit, rid)
ctxt['zmq_host'] = relation_get('host', unit, rid) ctxt['zmq_host'] = relation_get('host', unit, rid)
ctxt['zmq_redis_address'] = relation_get( ctxt['zmq_redis_address'] = relation_get(
'zmq_redis_address', unit, rid) 'zmq_redis_address', unit, rid)
return ctxt return ctxt

View File

@ -183,7 +183,7 @@ class OSConfigRenderer(object):
/tmp/templates/grizzly/api-paste.ini /tmp/templates/grizzly/api-paste.ini
/tmp/templates/havana/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. the grizzly directory for nova.conf, then the templates dir.
When writing api-paste.ini, it will find the template in the grizzly When writing api-paste.ini, it will find the template in the grizzly

View File

@ -83,7 +83,8 @@ from charmhelpers.fetch import (
add_source as fetch_add_source, add_source as fetch_add_source,
SourceConfigError, SourceConfigError,
GPGKeyError, GPGKeyError,
get_upstream_version get_upstream_version,
filter_missing_packages
) )
from charmhelpers.fetch.snap import ( from charmhelpers.fetch.snap import (
@ -309,6 +310,15 @@ def error_out(msg):
sys.exit(1) 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): def get_os_codename_install_source(src):
'''Derive OpenStack release codename from a given installation source.''' '''Derive OpenStack release codename from a given installation source.'''
ubuntu_rel = lsb_release()['DISTRIB_CODENAME'] 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: if charm_func_with_configs:
charm_state, charm_message = 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) state = workload_state_compare(state, charm_state)
if message: if message:
charm_message = charm_message.replace("Incomplete relations: ", 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): 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 are actually closed (not listened to), to verify that the unit is
properly paused. properly paused.

View File

@ -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

View File

@ -856,12 +856,22 @@ def _keyring_path(service):
return KEYRING.format(service) return KEYRING.format(service)
def create_keyring(service, key): def add_key(service, key):
"""Create a new Ceph keyring containing key.""" """
Add a key to a keyring.
Creates the keyring if it doesn't already exist.
Logs and returns if the key is already in the keyring.
"""
keyring = _keyring_path(service) keyring = _keyring_path(service)
if os.path.exists(keyring): if os.path.exists(keyring):
log('Ceph keyring exists at %s.' % keyring, level=WARNING) with open(keyring, 'r') as ring:
return if key in ring.read():
log('Ceph keyring exists at %s and has not changed.' % keyring,
level=DEBUG)
return
log('Updating existing keyring %s.' % keyring, level=DEBUG)
cmd = ['ceph-authtool', keyring, '--create-keyring', cmd = ['ceph-authtool', keyring, '--create-keyring',
'--name=client.{}'.format(service), '--add-key={}'.format(key)] '--name=client.{}'.format(service), '--add-key={}'.format(key)]
@ -869,6 +879,11 @@ def create_keyring(service, key):
log('Created new ceph keyring at %s.' % keyring, level=DEBUG) log('Created new ceph keyring at %s.' % keyring, level=DEBUG)
def create_keyring(service, key):
"""Deprecated. Please use the more accurately named 'add_key'"""
return add_key(service, key)
def delete_keyring(service): def delete_keyring(service):
"""Delete an existing Ceph keyring.""" """Delete an existing Ceph keyring."""
keyring = _keyring_path(service) keyring = _keyring_path(service)
@ -905,7 +920,7 @@ def get_ceph_nodes(relation='ceph'):
def configure(service, key, auth, use_syslog): def configure(service, key, auth, use_syslog):
"""Perform basic configuration of Ceph.""" """Perform basic configuration of Ceph."""
create_keyring(service, key) add_key(service, key)
create_key_file(service, key) create_key_file(service, key)
hosts = get_ceph_nodes() hosts = get_ceph_nodes()
with open('/etc/ceph/ceph.conf', 'w') as ceph_conf: with open('/etc/ceph/ceph.conf', 'w') as ceph_conf:
@ -1068,7 +1083,7 @@ def ensure_ceph_keyring(service, user=None, group=None,
if not key: if not key:
return False return False
create_keyring(service=service, key=key) add_key(service=service, key=key)
keyring = _keyring_path(service) keyring = _keyring_path(service)
if user and group: if user and group:
check_call(['chown', '%s.%s' % (user, group), keyring]) check_call(['chown', '%s.%s' % (user, group), keyring])

View File

@ -46,6 +46,7 @@ if __platform__ == "ubuntu":
lsb_release, lsb_release,
cmp_pkgrevno, cmp_pkgrevno,
CompareHostReleases, CompareHostReleases,
get_distrib_codename,
) # flake8: noqa -- ignore F401 for this import ) # flake8: noqa -- ignore F401 for this import
elif __platform__ == "centos": elif __platform__ == "centos":
from charmhelpers.core.host_factory.centos import ( # NOQA:F401 from charmhelpers.core.host_factory.centos import ( # NOQA:F401

View File

@ -72,6 +72,14 @@ def lsb_release():
return d 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): def cmp_pkgrevno(package, revno, pkgcache=None):
"""Compare supplied revno with the revno of the installed package. """Compare supplied revno with the revno of the installed package.

View File

@ -1,4 +1,4 @@
# Copyright 2014-2015 Canonical Limited. # Copyright 2014-2019 Canonical Limited.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.

View File

@ -20,7 +20,7 @@ from __future__ import print_function
import atexit import atexit
import sys import sys
from charmhelpers.contrib.python.rpdb import Rpdb from charmhelpers.fetch.python.rpdb import Rpdb
from charmhelpers.core.hookenv import ( from charmhelpers.core.hookenv import (
open_port, open_port,
close_port, close_port,