From 7fdf92e499d5945a43d42eae5c16c6ab995c5dd0 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 12 Sep 2016 09:36:40 +0000 Subject: [PATCH] Add remote restart support --- interface.yaml | 6 +++--- provides.py | 32 +++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/interface.yaml b/interface.yaml index 0be27bb..de04b72 100644 --- a/interface.yaml +++ b/interface.yaml @@ -1,3 +1,3 @@ -name: neutron-plugin -summary: Interface for intergrating Neutron SDN's with the nova-compute charm -maintainer: James Page +name: neutron-plugin-api-subordinate +summary: Interface for intergrating Neutron SDN's with the neutron-api charm +maintainer: OpenStack Charmers diff --git a/provides.py b/provides.py index d15f780..f2f85bb 100644 --- a/provides.py +++ b/provides.py @@ -5,21 +5,43 @@ from charms.reactive import RelationBase from charms.reactive import scopes -class NeutronPluginProvides(RelationBase): +class NeutronPluginAPISubordinate(RelationBase): scope = scopes.GLOBAL - @hook('{provides:neutron-plugin}-relation-{joined,changed}') + @hook('{provides:neutron-plugin-api-subordinate}-relation-{joined,changed}') def changed(self): self.set_state('{relation_name}.connected') - @hook('{provides:neutron-plugin}-relation-{broken,departed}') + @hook('{provides:neutron-plugin-api-subordinate}-relation-{broken,departed}') def broken(self): self.remove_state('{relation_name}.connected') - def configure_plugin(self, plugin, config): + def configure_plugin(self, plugin=None, core_plugin=None, + neutron_plugin_config=None, service_plugins=None, + subordinate_configuration=None): conversation = self.conversation() relation_info = { 'neutron-plugin': plugin, - 'subordinate_configuration': json.dumps(config), + 'core-plugin': core_plugin, + 'neutron-plugin-config': neutron_plugin_config, + 'service-plugins': service_plugins, + 'subordinate_configuration': json.dumps(subordinate_configuration), } conversation.set_remote(**relation_info) + + def request_restart(self, service_type=None): + """Request a restart of a set of remote services + + :param service_type: string Service types to be restarted eg 'neutron'. + If ommitted a request to restart all + services is sent + """ + if service_type: + key = 'restart-trigger-{}'.format(service_type) + else: + key = 'restart-trigger' + relation_info = { + key: str(uuid.uuid4()), + } + print(relation_info) + self.set_remote(**relation_info)