From 02655dc99ab6df44c5847866964af360de9186ca Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Sat, 14 Dec 2019 21:54:50 -0300 Subject: [PATCH] Initial import --- .gitignore | 1 + copyright | 21 +++++++++++++++++++++ interface.yaml | 6 ++++++ requires.py | 37 ++++++++++++++++++++++++++++++++++++ test-requirements.txt | 2 ++ tox.ini | 44 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 111 insertions(+) create mode 100644 .gitignore create mode 100644 copyright create mode 100644 interface.yaml create mode 100644 requires.py create mode 100644 test-requirements.txt create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..172bf57 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.tox diff --git a/copyright b/copyright new file mode 100644 index 0000000..d66bea9 --- /dev/null +++ b/copyright @@ -0,0 +1,21 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0 + +Files: * +Copyright: 2019, Canonical Ltd. +License: Apache-2.0 + +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 new file mode 100644 index 0000000..5f752ff --- /dev/null +++ b/interface.yaml @@ -0,0 +1,6 @@ +name: keystone-notifications +summary: | + Interface for integrating with Keystone notifications interface + Charms use this relation to know when an endpoint changed. + +maintainer: Felipe Reyes diff --git a/requires.py b/requires.py new file mode 100644 index 0000000..e6c486d --- /dev/null +++ b/requires.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# 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. + +from charmhelpers.core import hookenv +from charms.reactive import RelationBase +from charms.reactive import hook +from charms.reactive import scopes + + +class KeystoneNotifications(RelationBase): + scope = scopes.GLOBAL + + @hook('{requires:keystone-notifications}-relation-joined') + def joined(self): + self.set_state('{relation_name}.connected') + + @hook('{requires:keystone-notifications}-relation-changed') + def changed(self): + self.set_state('{relation_name}.available.updated') + hookenv.atexit(self._clear_updated) + + @hook('{requires:keystone-notifications}-relation-{broken,departed}') + def departed(self): + self.remove_state('{relation_name}.connected') + + def _clear_updated(self): + self.remove_state('{relation_name}.available.updated') diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..095ec9c --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +flake8>=2.2.4,<=2.4.1 +os-testr>=0.4.1 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..776a5f2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,44 @@ +[tox] +envlist = pep8,py27,py34,py35 +skipsdist = True +# NOTE(beisner): Avoid build/test env pollution by not enabling sitepackages. +sitepackages = False +# NOTE(beisner): Avoid false positives by not skipping missing interpreters. +skip_missing_interpreters = False + +[testenv] +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 +install_command = + pip install {opts} {packages} +commands = ostestr {posargs} + +[testenv:py27] +basepython = python2.7 +deps = -r{toxinidir}/test-requirements.txt +# TODO: Need to write unit tests then remove the following command. +commands = /bin/true + +[testenv:py34] +basepython = python3.4 +deps = -r{toxinidir}/test-requirements.txt +# TODO: Need to write unit tests then remove the following command. +commands = /bin/true + +[testenv:py35] +basepython = python3.5 +deps = -r{toxinidir}/test-requirements.txt +# TODO: Need to write unit tests then remove the following command. +commands = /bin/true + +[testenv:pep8] +basepython = python3 +deps = -r{toxinidir}/test-requirements.txt +commands = flake8 {posargs} + +[testenv:venv] +basepython = python3 +commands = {posargs} + +[flake8] +ignore = E402,E226