From b1e5ad5a97397d890070ad1205fb1a4915c5bb6e Mon Sep 17 00:00:00 2001 From: David Ames Date: Tue, 17 Nov 2020 19:04:26 +0000 Subject: [PATCH] Enable prefix aware get_allowed_units Related CH change: https://github.com/juju/charm-helpers/pull/531 Closes-Bug: #1904610 Change-Id: I49ad33797fb91ecbc5312709481e9236cfa4d840 --- src/lib/charm/openstack/mysql_innodb_cluster.py | 11 ++++++++--- src/wheelhouse.txt | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/charm/openstack/mysql_innodb_cluster.py b/src/lib/charm/openstack/mysql_innodb_cluster.py index 4cbacde..4ec6bbf 100644 --- a/src/lib/charm/openstack/mysql_innodb_cluster.py +++ b/src/lib/charm/openstack/mysql_innodb_cluster.py @@ -1093,7 +1093,7 @@ class MySQLInnoDBClusterCharm(charms_openstack.charm.OpenStackCharm): # TODO: Generalize and move to mysql charmhelpers def get_allowed_units(self, database, username, relation_id, - db_helper=None): + db_helper=None, prefix=None): """Get Allowed Units. Call MySQL8Helper.get_allowed_units and return space delimited list of @@ -1107,13 +1107,17 @@ class MySQLInnoDBClusterCharm(charms_openstack.charm.OpenStackCharm): :type username: str :param relation_id: Relation ID :type relation_id: str + :param db_helper: DB Helper instnace + :type db_helper: MySQLDB8Helper instance + :param prefix: Prefix for db request + :type prefix: str :returns: Space delimited list of unit names :rtype: str """ if not db_helper: db_helper = self.get_db_helper() allowed_units = db_helper.get_allowed_units( - database, username, relation_id=relation_id) + database, username, relation_id=relation_id, prefix=prefix) allowed_units = sorted( allowed_units, key=lambda a: int(a.split('/')[-1])) allowed_units = ' '.join(allowed_units) @@ -1158,7 +1162,8 @@ class MySQLInnoDBClusterCharm(charms_openstack.charm.OpenStackCharm): allowed_units = self.get_allowed_units( database, username, unit.relation.relation_id, - db_helper=db_helper) + db_helper=db_helper, + prefix=prefix) if prefix in self._unprefixed: prefix = None diff --git a/src/wheelhouse.txt b/src/wheelhouse.txt index ea94e6d..d268cbc 100644 --- a/src/wheelhouse.txt +++ b/src/wheelhouse.txt @@ -1,3 +1,4 @@ mysqlclient psutil tenacity +git+https://github.com/juju/charm-helpers.git#egg=charmhelpers