Add fsid and mon_hosts. Also add a simple README
This commit is contained in:
parent
a938732659
commit
2b25f30532
|
@ -0,0 +1,2 @@
|
||||||
|
.idea
|
||||||
|
*.swp
|
|
@ -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)
|
||||||
|
```
|
15
requires.py
15
requires.py
|
@ -6,34 +6,41 @@ from charms.reactive import is_state
|
||||||
|
|
||||||
class CephClient(RelationBase):
|
class CephClient(RelationBase):
|
||||||
scope = scopes.GLOBAL
|
scope = scopes.GLOBAL
|
||||||
auto_accessors = ['key', 'auth', 'public_address']
|
auto_accessors = ['key', 'fsid', 'auth', 'mon_hosts']
|
||||||
|
|
||||||
@hook('{requires:ceph-admin}-relation-{joined,changed}')
|
@hook('{requires:ceph-admin}-relation-{joined,changed}')
|
||||||
def changed(self):
|
def changed(self):
|
||||||
self.set_state('{relation_name}.connected')
|
self.set_state('{relation_name}.connected')
|
||||||
key = None
|
key = None
|
||||||
|
fsid = None
|
||||||
auth = None
|
auth = None
|
||||||
public_addr = None
|
mon_hosts = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
key = self.key
|
key = self.key
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
fsid = self.fsid
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
auth = self.auth
|
auth = self.auth
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
public_addr = self.public_address
|
mon_hosts = self.mon_hosts
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'key': key,
|
'key': key,
|
||||||
|
'fsid': fsid,
|
||||||
'auth': auth,
|
'auth': auth,
|
||||||
'public_address': public_addr
|
'mon_hosts': mon_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
if all(data.values()):
|
if all(data.values()):
|
||||||
|
|
Loading…
Reference in New Issue