Files
charm-interface-neutron-plugin/provides.py
Frode Nordahl 6dca7338b2 Add auto accessor for `host` attribute
Depends-On: I75cbc5eb97cf3603ffa5a9a49670411288d90520
Change-Id: I3b11eec3f1c4b8a673ccb6f9e6320d79dbde8f7a
Closes-Bug: #1845303
2019-10-01 08:02:17 +02:00

28 lines
785 B
Python

import json
from charms.reactive import hook
from charms.reactive import RelationBase
from charms.reactive import scopes
class NeutronPluginProvides(RelationBase):
scope = scopes.GLOBAL
auto_accessors = ['host']
@hook('{provides:neutron-plugin}-relation-{joined,changed}')
def changed(self):
self.set_state('{relation_name}.connected')
@hook('{provides:neutron-plugin}-relation-{broken,departed}')
def broken(self):
self.remove_state('{relation_name}.connected')
def configure_plugin(self, plugin, config):
conversation = self.conversation()
relation_info = {
'neutron-plugin': plugin,
'subordinate_configuration': json.dumps(config),
}
conversation.set_remote(**relation_info)