initial commit, fleshed out basic interface function, readme, etc
This commit is contained in:
commit
d9cfff2e4f
|
@ -0,0 +1,32 @@
|
||||||
|
# Overview
|
||||||
|
|
||||||
|
Basic interface for sending Cinder subordinate backend configuration to
|
||||||
|
principle Cinder charms.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
## Requires
|
||||||
|
|
||||||
|
This interface layer will set the following state:
|
||||||
|
|
||||||
|
* `{relation_name}.connected` The relation is established, but the charm may
|
||||||
|
not have provided any backend information.
|
||||||
|
|
||||||
|
For example, the subordinate would handle the `cinder-backend.connected` state
|
||||||
|
with something like:
|
||||||
|
|
||||||
|
```python
|
||||||
|
@when('cinder-backend.connected')
|
||||||
|
def configure_cinder(cinder_principal):
|
||||||
|
config = {'api-endpoint': '1.2.3.4',
|
||||||
|
'admin-username': 'admin',
|
||||||
|
'admin-password': 'openstack',
|
||||||
|
'api-version': '1.0'}
|
||||||
|
cinder_principle.configure_principal(
|
||||||
|
backend_name='my_backend', configuration=config)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# Contact Information
|
||||||
|
|
||||||
|
- <michael.skalka@canonical.com>
|
|
@ -0,0 +1,4 @@
|
||||||
|
name: cinder-backend
|
||||||
|
summary: OpenStack Cinder backend interface
|
||||||
|
version: 1
|
||||||
|
repo: https://github.com/mskalka/interface-cinder-backend
|
|
@ -0,0 +1,44 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
from charms.reactive import RelationBase
|
||||||
|
from charms.reactive import hook
|
||||||
|
from charms.reactive import scopes
|
||||||
|
|
||||||
|
|
||||||
|
class CinderBackendProvides(RelationBase):
|
||||||
|
|
||||||
|
scope = scopes.GLOBAL
|
||||||
|
|
||||||
|
@hook('{provides:cinder-backend}-relation-joined')
|
||||||
|
def cinder_backend_joined(self):
|
||||||
|
conv = self.conversation()
|
||||||
|
conv.set_state('{relation_name}.joined')
|
||||||
|
self.set_state('{relation_name}.connected')
|
||||||
|
self.set_state('{relation_name}.available')
|
||||||
|
|
||||||
|
@hook('{provides:cinder-backend}-relation-{broken, departed}')
|
||||||
|
def cinder_backend_departed(self):
|
||||||
|
conv = self.conversation()
|
||||||
|
conv.remove_state('{relation_name}.joined')
|
||||||
|
self.remove_state('{relation_name}.available')
|
||||||
|
self.remove_state('{relation_name}.connected')
|
||||||
|
conv.set_state('{relation_name}.departing')
|
||||||
|
|
||||||
|
def configure_principal(self, backend_name, configuration):
|
||||||
|
"""Send principle cinder-backend information"""
|
||||||
|
conv = self.conversation()
|
||||||
|
|
||||||
|
subordinate_configuration = {
|
||||||
|
"cinder": {
|
||||||
|
"/etc/cinder/cinder.conf": {
|
||||||
|
"sections": {
|
||||||
|
backend_name: configuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
conv.set_remote(backend_name=backend_name
|
||||||
|
subordinate_configuration=configuration)
|
Loading…
Reference in New Issue