Sync charm-helpers
Change-Id: I9029777c7cad92ffb5edba3f8acacac015efd663
This commit is contained in:
parent
e32c5caf97
commit
f4bf629c63
@ -33,6 +33,7 @@ from charmhelpers.core.hookenv import (
|
|||||||
hook_name,
|
hook_name,
|
||||||
local_unit,
|
local_unit,
|
||||||
log,
|
log,
|
||||||
|
relation_get,
|
||||||
relation_ids,
|
relation_ids,
|
||||||
relation_set,
|
relation_set,
|
||||||
relations_of_type,
|
relations_of_type,
|
||||||
@ -260,11 +261,23 @@ class NRPE(object):
|
|||||||
relation = relation_ids('nrpe-external-master')
|
relation = relation_ids('nrpe-external-master')
|
||||||
if relation:
|
if relation:
|
||||||
log("Setting charm primary status {}".format(primary))
|
log("Setting charm primary status {}".format(primary))
|
||||||
for rid in relation_ids('nrpe-external-master'):
|
for rid in relation:
|
||||||
relation_set(relation_id=rid, relation_settings={'primary': self.primary})
|
relation_set(relation_id=rid, relation_settings={'primary': self.primary})
|
||||||
|
self.remove_check_queue = set()
|
||||||
|
|
||||||
def add_check(self, *args, **kwargs):
|
def add_check(self, *args, **kwargs):
|
||||||
|
shortname = None
|
||||||
|
if kwargs.get('shortname') is None:
|
||||||
|
if len(args) > 0:
|
||||||
|
shortname = args[0]
|
||||||
|
else:
|
||||||
|
shortname = kwargs['shortname']
|
||||||
|
|
||||||
self.checks.append(Check(*args, **kwargs))
|
self.checks.append(Check(*args, **kwargs))
|
||||||
|
try:
|
||||||
|
self.remove_check_queue.remove(shortname)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
def remove_check(self, *args, **kwargs):
|
def remove_check(self, *args, **kwargs):
|
||||||
if kwargs.get('shortname') is None:
|
if kwargs.get('shortname') is None:
|
||||||
@ -281,6 +294,7 @@ class NRPE(object):
|
|||||||
|
|
||||||
check = Check(*args, **kwargs)
|
check = Check(*args, **kwargs)
|
||||||
check.remove(self.hostname)
|
check.remove(self.hostname)
|
||||||
|
self.remove_check_queue.add(kwargs['shortname'])
|
||||||
|
|
||||||
def write(self):
|
def write(self):
|
||||||
try:
|
try:
|
||||||
@ -313,8 +327,25 @@ class NRPE(object):
|
|||||||
monitor_ids = relation_ids("local-monitors") + \
|
monitor_ids = relation_ids("local-monitors") + \
|
||||||
relation_ids("nrpe-external-master")
|
relation_ids("nrpe-external-master")
|
||||||
for rid in monitor_ids:
|
for rid in monitor_ids:
|
||||||
|
reldata = relation_get(unit=local_unit(), rid=rid)
|
||||||
|
if 'monitors' in reldata:
|
||||||
|
# update the existing set of monitors with the new data
|
||||||
|
old_monitors = yaml.safe_load(reldata['monitors'])
|
||||||
|
old_nrpe_monitors = old_monitors['monitors']['remote']['nrpe']
|
||||||
|
# remove keys that are in the remove_check_queue
|
||||||
|
old_nrpe_monitors = {k: v for k, v in old_nrpe_monitors.items()
|
||||||
|
if k not in self.remove_check_queue}
|
||||||
|
# update/add nrpe_monitors
|
||||||
|
old_nrpe_monitors.update(nrpe_monitors)
|
||||||
|
old_monitors['monitors']['remote']['nrpe'] = old_nrpe_monitors
|
||||||
|
# write back to the relation
|
||||||
|
relation_set(relation_id=rid, monitors=yaml.dump(old_monitors))
|
||||||
|
else:
|
||||||
|
# write a brand new set of monitors, as no existing ones.
|
||||||
relation_set(relation_id=rid, monitors=yaml.dump(monitors))
|
relation_set(relation_id=rid, monitors=yaml.dump(monitors))
|
||||||
|
|
||||||
|
self.remove_check_queue.clear()
|
||||||
|
|
||||||
|
|
||||||
def get_nagios_hostcontext(relation_name='nrpe-external-master'):
|
def get_nagios_hostcontext(relation_name='nrpe-external-master'):
|
||||||
"""
|
"""
|
||||||
|
@ -323,6 +323,23 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
|||||||
else:
|
else:
|
||||||
return releases[self.series]
|
return releases[self.series]
|
||||||
|
|
||||||
|
def get_percona_service_entry(self, memory_constraint=None):
|
||||||
|
"""Return a amulet service entry for percona cluster.
|
||||||
|
|
||||||
|
:param memory_constraint: Override the default memory constraint
|
||||||
|
in the service entry.
|
||||||
|
:type memory_constraint: str
|
||||||
|
:returns: Amulet service entry.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
memory_constraint = memory_constraint or '3072M'
|
||||||
|
svc_entry = {
|
||||||
|
'name': 'percona-cluster',
|
||||||
|
'constraints': {'mem': memory_constraint}}
|
||||||
|
if self._get_openstack_release() <= self.trusty_mitaka:
|
||||||
|
svc_entry['location'] = 'cs:trusty/percona-cluster'
|
||||||
|
return svc_entry
|
||||||
|
|
||||||
def get_ceph_expected_pools(self, radosgw=False):
|
def get_ceph_expected_pools(self, radosgw=False):
|
||||||
"""Return a list of expected ceph pools in a ceph + cinder + glance
|
"""Return a list of expected ceph pools in a ceph + cinder + glance
|
||||||
test scenario, based on OpenStack release and whether ceph radosgw
|
test scenario, based on OpenStack release and whether ceph radosgw
|
||||||
|
@ -258,7 +258,7 @@ class SharedDBContext(OSContextGenerator):
|
|||||||
'database_password': rdata.get(password_setting),
|
'database_password': rdata.get(password_setting),
|
||||||
'database_type': 'mysql+pymysql'
|
'database_type': 'mysql+pymysql'
|
||||||
}
|
}
|
||||||
if CompareOpenStackReleases(rel) < 'stein':
|
if CompareOpenStackReleases(rel) < 'queens':
|
||||||
ctxt['database_type'] = 'mysql'
|
ctxt['database_type'] = 'mysql'
|
||||||
if self.context_complete(ctxt):
|
if self.context_complete(ctxt):
|
||||||
db_ssl(rdata, ctxt, self.ssl_dir)
|
db_ssl(rdata, ctxt, self.ssl_dir)
|
||||||
@ -443,8 +443,10 @@ class IdentityServiceContext(OSContextGenerator):
|
|||||||
'api_version': api_version})
|
'api_version': api_version})
|
||||||
|
|
||||||
if float(api_version) > 2:
|
if float(api_version) > 2:
|
||||||
ctxt.update({'admin_domain_name':
|
ctxt.update({
|
||||||
rdata.get('service_domain')})
|
'admin_domain_name': rdata.get('service_domain'),
|
||||||
|
'service_project_id': rdata.get('service_tenant_id'),
|
||||||
|
'service_domain_id': rdata.get('service_domain_id')})
|
||||||
|
|
||||||
# we keep all veriables in ctxt for compatibility and
|
# we keep all veriables in ctxt for compatibility and
|
||||||
# add nested dictionary for keystone_authtoken generic
|
# add nested dictionary for keystone_authtoken generic
|
||||||
|
@ -1482,6 +1482,21 @@ def send_request_if_needed(request, relation='ceph'):
|
|||||||
relation_set(relation_id=rid, broker_req=request.request)
|
relation_set(relation_id=rid, broker_req=request.request)
|
||||||
|
|
||||||
|
|
||||||
|
def has_broker_rsp(rid=None, unit=None):
|
||||||
|
"""Return True if the broker_rsp key is 'truthy' (i.e. set to something) in the relation data.
|
||||||
|
|
||||||
|
:param rid: The relation to check (default of None means current relation)
|
||||||
|
:type rid: Union[str, None]
|
||||||
|
:param unit: The remote unit to check (default of None means current unit)
|
||||||
|
:type unit: Union[str, None]
|
||||||
|
:returns: True if broker key exists and is set to something 'truthy'
|
||||||
|
:rtype: bool
|
||||||
|
"""
|
||||||
|
rdata = relation_get(rid=rid, unit=unit) or {}
|
||||||
|
broker_rsp = rdata.get(get_broker_rsp_key())
|
||||||
|
return True if broker_rsp else False
|
||||||
|
|
||||||
|
|
||||||
def is_broker_action_done(action, rid=None, unit=None):
|
def is_broker_action_done(action, rid=None, unit=None):
|
||||||
"""Check whether broker action has completed yet.
|
"""Check whether broker action has completed yet.
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
|
|||||||
"""
|
"""
|
||||||
this_service = {'name': 'neutron-gateway'}
|
this_service = {'name': 'neutron-gateway'}
|
||||||
other_services = [
|
other_services = [
|
||||||
{'name': 'percona-cluster', 'constraints': {'mem': '3072M'}},
|
self.get_percona_service_entry(),
|
||||||
{'name': 'rabbitmq-server'},
|
{'name': 'rabbitmq-server'},
|
||||||
{'name': 'keystone'},
|
{'name': 'keystone'},
|
||||||
{'name': 'glance'}, # satisfy workload status
|
{'name': 'glance'}, # satisfy workload status
|
||||||
|
2
tox.ini
2
tox.ini
@ -95,7 +95,7 @@ basepython = python2.7
|
|||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands =
|
commands =
|
||||||
bundletester -vl DEBUG -r json -o func-results.json gate-basic-bionic-rocky --no-destroy
|
bundletester -vl DEBUG -r json -o func-results.json gate-basic-bionic-stein --no-destroy
|
||||||
|
|
||||||
[testenv:func27-dfs]
|
[testenv:func27-dfs]
|
||||||
# Charm Functional Test
|
# Charm Functional Test
|
||||||
|
Loading…
Reference in New Issue
Block a user