Initial commit of basic softhsm plugin charm

This is a barebones charm (as part of this commit) which only connects to the
prinical barbican charm and announces its name (as softhsm).  Next steps are to
install and configure the software for the softhsm and determine what should go
across the charm relation.
This commit is contained in:
Alex Kavanagh 2016-06-23 13:48:39 +00:00
commit cbe7232aac
9 changed files with 151 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
build
.tox
layers
interfaces
trusty
.testrepository

13
copyright Normal file
View File

@ -0,0 +1,13 @@
Copyright 2016 Canonical Ltd.
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.

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
charm-tools
simplejson

1
src/layer.yaml Normal file
View File

@ -0,0 +1 @@
includes: ['layer:openstack', 'interface:barbican-hsm-plugin']

View File

@ -0,0 +1,37 @@
import charms_openstack.charm
import charms_openstack.adapters
def install():
"""Use the singleton from the BarbicanSoftHSMCharm to install the packages
on the unit
"""
BarbicanSoftHSMCharm.singleton.install()
class BarbicanSoftHSMCharm(charms_openstack.charm.OpenStackCharm):
service_name = 'barbican-softhsm'
name = 'softhsm'
release = 'mitaka'
# Packages that the service needs installed
packages = []
# Init services the charm manages
services = []
# Standard interface adapters class to use.
adapters_class = charms_openstack.adapters.OpenStackRelationAdapters
# Ports that need exposing
default_service = ''
api_ports = {}
# Database sync command (if needed)
sync_cmd = []
# The restart map defines which services should be restarted when a given
# file changes
restart_map = {
}

18
src/metadata.yaml Normal file
View File

@ -0,0 +1,18 @@
name: barbican-softhsm-plugin
summary: The softhsm security module for the barbican charm service
maintainer: OpenStack Charmers <openstack-charmers@lists.ubuntu.com>
subordinate: true
description: |
Barbican provides a secure storage for keys and other secrets and
additionally has features to provide certificates to OpenStack applications.
The barbican-softhsm-plugin is for testing purposes only, and demonstrates
the barbican-hsm-plugin interface for interfacing real HSM providers with
Barbican.
provides:
hsm:
interface: barbican-hsm-plugin
scope: container
requires:
juju-info:
interface: juju-info
scope: container

19
src/reactive/handlers.py Normal file
View File

@ -0,0 +1,19 @@
import charms.reactive as reactive
import charmhelpers.core.hookenv as hookenv
# This charm's library contains all of the handler code associated with
# congress
import charm.openstack.softhsm_plugin as softhsm_plugin
# use a synthetic state to ensure that it get it to be installed independent of
# the install hook.
@reactive.when_not('charm.installed')
def install_packages():
softhsm_plugin.install()
reactive.set_state('charm.installed')
@reactive.when('hsm.connected')
def hsm_connected(hsm):
hookenv.log("Setting my name to softhsm")
hsm.set_name('softhsm')

6
test-requirements.txt Normal file
View File

@ -0,0 +1,6 @@
flake8>=2.2.4,<=2.4.1
os-testr>=0.4.1
charms.reactive
mock>=1.2
coverage>=3.6
git+https://github.com/ajkavanagh/charm.openstack#egg=charms-openstack

49
tox.ini Normal file
View File

@ -0,0 +1,49 @@
[tox]
skipsdist = True
envlist = generate
skip_missing_interpreters = True
[testenv]
setenv = VIRTUAL_ENV={envdir}
PYTHONHASHSEED=0
TERM=linux
INTERFACE_PATH={toxinidir}/interfaces
LAYER_PATH={toxinidir}/layers
INTERFACE_PATH={toxinidir}/interfaces
JUJU_REPOSITORY={toxinidir}/build
passenv = http_proxy https_proxy
install_command =
pip install {opts} {packages}
deps =
-r{toxinidir}/requirements.txt
[testenv:build]
basepython = python2.7
commands =
charm-build --log-level DEBUG -o {toxinidir}/build src {posargs}
[testenv:py27]
basepython = python2.7
deps = -r{toxinidir}/test-requirements.txt
commands = ostestr {posargs}
[testenv:py34]
basepython = python3.4
deps = -r{toxinidir}/test-requirements.txt
commands = ostestr {posargs}
[testenv:py35]
basepython = python3.5
deps = -r{toxinidir}/test-requirements.txt
commands = ostestr {posargs}
[testenv:lint]
basepython = python2.7
deps = -r{toxinidir}/test-requirements.txt
commands = flake8 {posargs} src unit_tests
[testenv:venv]
commands = {posargs}
[flake8]
ignore = E402,E226