Add fsid and mon_hosts. Also add a simple README

This commit is contained in:
Chris Holcombe 2016-08-25 09:39:23 -07:00
parent a938732659
commit 2b25f30532
3 changed files with 52 additions and 4 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea
*.swp

39
README.md Normal file
View File

@ -0,0 +1,39 @@
# Overview
This interface layer handles the communication between the Ceph Monitor Syslog
and an client that requires an admin key.
# Usage
## Requires
Charms requiring this interface gather logs and forward them to a provider.
This interface layer will set the following states, as appropriate:
* `{relation_name}.available` The ceph client has been related to a provider.
The following accessors will be available:
- key - The admin cephx key
- auth - Whether or not strict auth is supported
- mon_hosts - The public addresses list of the monitor cluster
Client example:
```python
@when('ceph-admin.available')
def ceph_connected(ceph_info):
charm_ceph_conf = os.path.join(os.sep, 'etc', 'ceph', 'ceph.conf')
cephx_key = os.path.join(os.sep, 'etc', 'ceph', 'ceph.client.admin.keyring')
ceph_context = {
'auth_supported': ceph_client.auth,
'mon_hosts': ceph_client.mon_hosts,
}
with open(charm_ceph_conf, 'w') as cephconf:
cephconf.write(render_template('ceph.conf', ceph_context))
# Write out the cephx_key also
with open(cephx_key, 'w') as cephconf:
cephconf.write(ceph_client.key)
```

View File

@ -6,34 +6,41 @@ from charms.reactive import is_state
class CephClient(RelationBase):
scope = scopes.GLOBAL
auto_accessors = ['key', 'auth', 'public_address']
auto_accessors = ['key', 'fsid', 'auth', 'mon_hosts']
@hook('{requires:ceph-admin}-relation-{joined,changed}')
def changed(self):
self.set_state('{relation_name}.connected')
key = None
fsid = None
auth = None
public_addr = None
mon_hosts = None
try:
key = self.key
except AttributeError:
pass
try:
fsid = self.fsid
except AttributeError:
pass
try:
auth = self.auth
except AttributeError:
pass
try:
public_addr = self.public_address
mon_hosts = self.mon_hosts
except AttributeError:
pass
data = {
'key': key,
'fsid': fsid,
'auth': auth,
'public_address': public_addr
'mon_hosts': mon_hosts
}
if all(data.values()):