Add support for network spaces
Automatically set the private-address relation key to the network space binding for the relation the interface is supporting for Juju >= 2.0; for older Juju versions continue to use "unit-get private-address". This change also adds the ability for the consuming charm to override the hostname provided on the relation using the option hostname parameter. Change-Id: Iee0d1ac7168fe0c32deaf03add5cb261da6c2a79
This commit is contained in:
parent
adc61d2ff9
commit
ace0c46caf
11
requires.py
11
requires.py
|
@ -84,13 +84,22 @@ class RabbitMQRequires(RelationBase):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def request_access(self, username, vhost):
|
def request_access(self, username, vhost, hostname=None):
|
||||||
"""
|
"""
|
||||||
Request access to vhost for the supplied username.
|
Request access to vhost for the supplied username.
|
||||||
"""
|
"""
|
||||||
|
if not hostname:
|
||||||
|
try:
|
||||||
|
hostname = hookenv.network_get_primary_address(
|
||||||
|
self.conversation().relation_name
|
||||||
|
)
|
||||||
|
except NotImplementedError:
|
||||||
|
hostname = hookenv.unit_private_ip()
|
||||||
|
|
||||||
relation_info = {
|
relation_info = {
|
||||||
'username': username,
|
'username': username,
|
||||||
'vhost': vhost,
|
'vhost': vhost,
|
||||||
|
'private-address': hostname,
|
||||||
}
|
}
|
||||||
self.set_local(**relation_info)
|
self.set_local(**relation_info)
|
||||||
self.set_remote(**relation_info)
|
self.set_remote(**relation_info)
|
||||||
|
|
Loading…
Reference in New Issue