Use provided unit scope in db_changed

If the unit parameter is passed to the db_changed function, ensure
that its used instead of the remote_unit function so that db_changed
can be called outside of the db-relation-changed hook context.

Change-Id: I30b42522ed982213176e485a1140ed872fc571df
Closes-Bug: 1688401
(cherry picked from commit 11bfc1e529)
This commit is contained in:
James Page 2017-05-13 09:48:19 +02:00
parent 189e5377e0
commit adc5d12a66
1 changed files with 1 additions and 1 deletions

View File

@ -354,7 +354,7 @@ def db_changed(relation_id=None, unit=None, admin=None):
if admin not in [True, False]:
admin = relation_type() == 'db-admin'
db_name, _ = remote_unit().split("/")
db_name, _ = (unit or remote_unit()).split("/")
username = db_name
db_helper = get_db_helper()
addr = relation_get('private-address', unit=unit, rid=relation_id)