Browse Source

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
changes/26/425226/2
James Page 3 years ago
parent
commit
ace0c46caf
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      requires.py

+ 10
- 1
requires.py View File

@@ -84,13 +84,22 @@ class RabbitMQRequires(RelationBase):
return True
return False

def request_access(self, username, vhost):
def request_access(self, username, vhost, hostname=None):
"""
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 = {
'username': username,
'vhost': vhost,
'private-address': hostname,
}
self.set_local(**relation_info)
self.set_remote(**relation_info)


Loading…
Cancel
Save