diff --git a/README.md b/README.md new file mode 100644 index 0000000..a25c726 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# Overview + +This interface is used for a charm to request a restart of a service managed by +another charm. + +# Usage + +The interface provides the `service-control.connected` state. + +# metadata + +To consume this interface in your charm or layer, add the following to +`layer.yaml`: + +```yaml +includes: ['interface:service-control'] +``` + +and add a provides interface of type `service-control` to your charm or layers +`metadata.yaml` eg: + +```yaml +requires: + neutron-control: + interface: service-control +``` + +# Bugs + +Please report bugs on +[Launchpad](https://bugs.launchpad.net/openstack-charms/+filebug). + +For development questions please refer to the OpenStack [Charm +Guide](https://github.com/openstack/charm-guide). diff --git a/copyright b/copyright index afa853f..5a49dcb 100644 --- a/copyright +++ b/copyright @@ -2,8 +2,20 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0 Files: * Copyright: 2015, Canonical Ltd. -License: GPL-3 +License: Apache-2.0 -License: GPL-3 - On Debian GNU/Linux system you can find the complete text of the - GPL-3 license in '/usr/share/common-licenses/GPL-3' +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian-based systems the full text of the Apache version 2.0 license + can be found in `/usr/share/common-licenses/Apache-2.0'. diff --git a/interface.yaml b/interface.yaml index d62f8f0..7a66e8b 100644 --- a/interface.yaml +++ b/interface.yaml @@ -1,3 +1,3 @@ -name: neutron-control -summary: Interface for requesting restarts of neutron services +name: service-control +summary: Interface for requesting restarts of services maintainer: OpenStack Charmers diff --git a/provides.py b/provides.py deleted file mode 100644 index 020bd39..0000000 --- a/provides.py +++ /dev/null @@ -1,24 +0,0 @@ -import uuid - -from charms.reactive import hook -from charms.reactive import RelationBase -from charms.reactive import scopes - - -class NeutronControlProvides(RelationBase): - scope = scopes.GLOBAL - - @hook('{provides:neutron-control}-relation-{joined,changed}') - def changed(self): - self.set_state('{relation_name}.connected') - - @hook('{provides:neutron-control}-relation-{broken,departed}') - def broken(self): - self.remove_state('{relation_name}.connected') - - def request_restart(self): - conversation = self.conversation() - relation_info = { - 'restart-trigger': str(uuid.uuid4()), - } - conversation.set_remote(**relation_info) diff --git a/requires.py b/requires.py new file mode 100644 index 0000000..bfe7df7 --- /dev/null +++ b/requires.py @@ -0,0 +1,34 @@ +import uuid + +from charms.reactive import hook +from charms.reactive import RelationBase +from charms.reactive import scopes + + +class ServiceControlRequires(RelationBase): + scope = scopes.GLOBAL + + @hook('{requires:service-control}-relation-{joined,changed}') + def changed(self): + self.set_state('{relation_name}.connected') + + @hook('{requires:service-control}-relation-{broken,departed}') + def broken(self): + self.remove_state('{relation_name}.connected') + + 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 + """ + conversation = self.conversation() + if service_type: + key = 'restart-trigger-{}'.format(service_type) + else: + key = 'restart-trigger' + relation_info = { + key: str(uuid.uuid4()), + } + conversation.set_remote(**relation_info)