Initial interface files

This is a basic, 'just about works' commit of the HSM plugin interface to
provide a base to work from in getting the HSM <-> barbican charm to work.
This commit is contained in:
Alex Kavanagh 2016-06-23 13:40:04 +00:00
commit e00c817737
6 changed files with 117 additions and 0 deletions

21
copyright Normal file
View File

@ -0,0 +1,21 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0
Files: *
Copyright: 2015, 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'.

4
interface.yaml Normal file
View File

@ -0,0 +1,4 @@
name: barbican-hsm-plugin
summary: Interface for a plugin to the Barbican charm.
maintainer: OpenStack Charmers <openstack-charmers@lists.ubuntu.com>
repo: https://github.com/openstack-charmers/charm-interface-barbican-plugin

28
provides.py Normal file
View File

@ -0,0 +1,28 @@
import charms.reactive as reactive
import charmhelpers.core.hookenv as hookenv
class BarbicanProvides(reactive.RelationBase):
scope = reactive.scopes.GLOBAL
# These remote data fields will be automatically mapped to accessors
# with a basic documentation string provided.
auto_accessors = ['test']
@reactive.hook('{provides:barbican-hsm-plugin}-relation-joined')
def joined(self):
self.set_state('{relation_name}.connected')
hookenv.log("BarbicanProvides.joined() ran")
@reactive.hook('{provides:barbican-hsm-plugin}-relation-changed')
def changed(self):
hookenv.log("BarbicanProvides.changed() ran")
@reactive.hook('{provides:barbican-hsm-plugin}-relation-{broken,departed}')
def departed(self):
hookenv.log("BarbicanProvides.departed() ran")
self.remove_state('{relation_name}.connected')
self.remove_state('{relation_name}.available')
def set_name(self, name):
self.set_remote(name=name)

31
requires.py Normal file
View File

@ -0,0 +1,31 @@
import charms.reactive as reactive
import charmhelpers.core.hookenv as hookenv
class BarbicanRequires(reactive.RelationBase):
scope = reactive.scopes.GLOBAL
# These remote data fields will be automatically mapped to accessors
# with a basic documentation string provided.
auto_accessors = ['name']
@reactive.hook('{requires:barbican-hsm-plugin}-relation-joined')
def joined(self):
self.set_state('{relation_name}.connected')
hookenv.log("BarbicanRequires.joined() ran")
self.update_status()
@reactive.hook('{requires:barbican-hsm-plugin}-relation-changed')
def changed(self):
hookenv.log("BarbicanRequires.changed() ran")
self.update_status()
@reactive.hook('{requires:barbican-hsm-plugin}-relation-{broken,departed}')
def departed(self):
hookenv.log("BarbicanRequires.departed() ran")
self.remove_state('{relation_name}.connected')
self.remove_state('{relation_name}.available')
def update_status(self):
if self.name is not None:
self.set_state('{relation_name}.available')

3
test-requirements.txt Normal file
View File

@ -0,0 +1,3 @@
flake8>=2.2.4,<=2.4.1
os-testr>=0.4.1
charm-tools

30
tox.ini Normal file
View File

@ -0,0 +1,30 @@
[tox]
envlist = lint,py34,py35
skipsdist = True
skip_missing_interpreters = True
[testenv]
setenv = VIRTUAL_ENV={envdir}
PYTHONHASHSEED=0
install_command =
pip install --allow-unverified python-apt {opts} {packages}
commands = ostestr {posargs}
[testenv:py34]
basepython = python3.4
deps = -r{toxinidir}/test-requirements.txt
[testenv:py35]
basepython = python3.5
deps = -r{toxinidir}/test-requirements.txt
[testenv:pep8]
basepython = python2.7
deps = -r{toxinidir}/test-requirements.txt
commands = flake8 {posargs}
[testenv:venv]
commands = {posargs}
[flake8]
ignore = E402,E226