[charms.reactive] http relation.available gets called on upgrade-charm hook, gives error.

Merlijn Sebrechts merlijn.sebrechts at gmail.com
Mon Oct 26 09:58:16 UTC 2015


Hi all


I have the following piece of code that reacts to the
httprelation.available hook (called rest2jfed in this case):


@when('rest2jfed.available')
def setup_rest2jfed(rest2jfed):
    hostname = rest2jfed.host()
    port = rest2jfed.port()
    # Do some stuff with hostname and port
    hookenv.status_set('active', 'Ready')


This piece of code gets called on the upgrade-charm hook. This throws an
error because there is not a relationship context.

  File "lib/charms/reactive/relations.py", line 88, in __accessor
    return self.get_remote(field)
  File "lib/charms/reactive/relations.py", line 308, in get_remote
    return self.conversation(scope).get_remote(key, default)
  File "lib/charms/reactive/relations.py", line 255, in conversation
    raise ValueError('Unable to determine default scope: no current hook or
global scope')

Am I using this relation wrong or is this a bug?



Kind regards
Merlijn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20151026/f2fb79d9/attachment.html>


More information about the Juju mailing list