Initial import

This commit is contained in:
Felipe Reyes 2019-12-14 21:54:50 -03:00
commit 02655dc99a
6 changed files with 111 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.tox

21
copyright Normal file
View File

@ -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'.

6
interface.yaml Normal file
View File

@ -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 <felipe.reyes@canonical.com>

37
requires.py Normal file
View File

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

2
test-requirements.txt Normal file
View File

@ -0,0 +1,2 @@
flake8>=2.2.4,<=2.4.1
os-testr>=0.4.1

44
tox.ini Normal file
View File

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