Add remote restart support

This commit is contained in:
Liam Young 2016-09-12 09:36:40 +00:00
parent c6469fc1dc
commit 7fdf92e499
2 changed files with 30 additions and 8 deletions

View File

@ -1,3 +1,3 @@
name: neutron-plugin
summary: Interface for intergrating Neutron SDN's with the nova-compute charm
maintainer: James Page <james.page@ubuntu.com>
name: neutron-plugin-api-subordinate
summary: Interface for intergrating Neutron SDN's with the neutron-api charm
maintainer: OpenStack Charmers <openstack-dev@lists.openstack.org>

View File

@ -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)