Initial cut of interface

This commit is contained in:
James Page 2017-01-27 11:10:44 +00:00
commit 8672c63475
7 changed files with 137 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.tox
.testrepository

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=openstack/charm-interface-keystone-domain-backend

37
README.md Normal file
View File

@ -0,0 +1,37 @@
# Overview
This interface layer handles the communication with Keystone via the
'keystone-domain-backend' interface protocol.
# Usage
## Provides
The interface layer will set the following state:
* `{relation_name}.connected` The relation is established.
For example:
```python
from charms.reactive import when
@when('domain-backend.connected')
@when('configuration.complete')
def configure_domain(domain):
domain.domain_name('mynewkeystonedomain')
domain.trigger_restart()
```
Typically a domain backend charm should validate that that it
has sufficient and good configuration for the domain backend,
write its configuration to
`/etc/keystone/domains/keystone.<domain-name>.conf` and then
trigger a restart of keystone using the `trigger_restart`
method of the inteface, supplying the domain name at this
point in time as well.
The keystone charm will create the domain in the keystone
database, mapping to the underlying domain configuration
on disk.

3
interface.yaml Normal file
View File

@ -0,0 +1,3 @@
name: keystone-domain-backend
summary: Interface for configuring Keystone Domain specific identity backends
maintainer: OpenStack Charmers <openstack-charmers@lists.ubuntu.com>

49
provides.py Normal file
View File

@ -0,0 +1,49 @@
# Copyright 2017 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.
import uuid
from charms.reactive import RelationBase
from charms.reactive import hook
from charms.reactive import scopes
class KeystoneDomainBackendProvides(RelationBase):
scope = scopes.GLOBAL
@hook('{provides:keystone-domain-backend}-relation-joined')
def joined(self):
self.set_state('{relation_name}.connected')
@hook('{provides:keystone-domain-backend}-relation-{broken,departed}')
def departed(self):
self.remove_state('{relation_name}.connected')
def domain_name(self, name):
"""
Set the domain name for the identity backend
"""
relation_info = {
'domain-name': name,
}
self.set_remote(**relation_info)
def trigger_restart(self):
"""
Trigger a restart of keystone
"""
relation_info = {
'restart-nonce': str(uuid.uuid4())
}
self.set_remote(**relation_info)

2
test-requirements.txt Normal file
View File

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

40
tox.ini Normal file
View File

@ -0,0 +1,40 @@
[tox]
envlist = pep8,py27,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: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 = python2.7
deps = -r{toxinidir}/test-requirements.txt
commands = flake8 {posargs}
[testenv:venv]
commands = {posargs}
[flake8]
ignore = E402,E226