From bfd4279546dd326f98528dc0b1ac2904538e4013 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 31 Aug 2016 07:25:48 +0000 Subject: [PATCH] Initial commit --- __init__.py | 0 copyright | 9 +++++++++ interface.yaml | 3 +++ provides.py | 24 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 __init__.py create mode 100644 copyright create mode 100644 interface.yaml create mode 100644 provides.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/copyright b/copyright new file mode 100644 index 0000000..afa853f --- /dev/null +++ b/copyright @@ -0,0 +1,9 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0 + +Files: * +Copyright: 2015, Canonical Ltd. +License: GPL-3 + +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' diff --git a/interface.yaml b/interface.yaml new file mode 100644 index 0000000..d62f8f0 --- /dev/null +++ b/interface.yaml @@ -0,0 +1,3 @@ +name: neutron-control +summary: Interface for requesting restarts of neutron services +maintainer: OpenStack Charmers diff --git a/provides.py b/provides.py new file mode 100644 index 0000000..020bd39 --- /dev/null +++ b/provides.py @@ -0,0 +1,24 @@ +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)