Add support for creating erasure coded pool
Initial implementation of custom status check.
This commit is contained in:
parent
b999330ab5
commit
64620a05d6
|
@ -15,11 +15,13 @@
|
|||
import socket
|
||||
import subprocess
|
||||
|
||||
import charms.reactive as reactive
|
||||
|
||||
import charms_openstack.charm
|
||||
import charms_openstack.adapters
|
||||
import charms_openstack.plugins
|
||||
|
||||
# import charmhelpers.core.host as ch_host
|
||||
import charmhelpers.core as ch_core
|
||||
|
||||
|
||||
class CephRBDMirrorCharmRelationAdapters(
|
||||
|
@ -55,6 +57,21 @@ class CephRBDMirrorCharm(charms_openstack.plugins.CephCharm):
|
|||
}
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def custom_assess_status_check(self):
|
||||
"""Provide mirrored pool statistics through juju status."""
|
||||
if (reactive.is_flag_set('config.rendered') and
|
||||
reactive.is_flag_set('ceph-local.available') and
|
||||
reactive.is_flag_set('ceph-remote.available')):
|
||||
endpoint = reactive.endpoint_from_flag('ceph-local.available')
|
||||
for pool, attrs in endpoint.pools.items():
|
||||
if 'rbd' in attrs['applications']:
|
||||
status = self.mirror_pool_status(pool)
|
||||
ch_core.hookenv.log('DEBUG: mirror_pool_status({}) = "{}"'
|
||||
.format(pool, status),
|
||||
level=ch_core.hookenv.INFO)
|
||||
return 'active', 'Custom'
|
||||
return None, None
|
||||
|
||||
def _mirror_pool_info(self, pool):
|
||||
output = subprocess.check_output(['rbd', '--id', self.ceph_id,
|
||||
'mirror', 'pool', 'info', pool],
|
||||
|
@ -74,7 +91,7 @@ class CephRBDMirrorCharm(charms_openstack.plugins.CephCharm):
|
|||
result = {}
|
||||
for line in output.splitlines():
|
||||
vp = line.split(':')
|
||||
result.update(vp[0], vp[1].lstrip().rstrip())
|
||||
result.update({vp[0]: vp[1].lstrip().rstrip()})
|
||||
return result
|
||||
|
||||
def mirror_pool_enable(self, pool):
|
||||
|
|
|
@ -98,6 +98,23 @@ def configure_pools():
|
|||
if 'rbd' in attrs['applications']:
|
||||
if not (charm_instance.mirror_pool_enabled(pool) and
|
||||
charm_instance.mirror_pool_has_peers(pool)):
|
||||
# TODO(fnordahl) add rest of attrs when creating pool
|
||||
remote.create_pool(pool, app_name='rbd')
|
||||
charm_instance.mirror_pool_enable(pool)
|
||||
pg_num = attrs['parameters'].get('pg_num', None)
|
||||
max_bytes = attrs['quota'].get('max_bytes', None)
|
||||
max_objects = attrs['quota'].get('max_objects', None)
|
||||
if 'erasure_code_profile' in attrs['parameters']:
|
||||
ec_profile = attrs['parameters'].get(
|
||||
'erasure_code_profile', None)
|
||||
remote.create_erasure_pool(pool,
|
||||
erasure_profile=ec_profile,
|
||||
pg_num=pg_num,
|
||||
app_name='rbd',
|
||||
max_bytes=max_bytes,
|
||||
max_objects=max_objects)
|
||||
else:
|
||||
size = attrs['parameters'].get('size', None)
|
||||
remote.create_replicated_pool(pool, replicas=size,
|
||||
pg_num=pg_num,
|
||||
app_name='rbd',
|
||||
max_bytes=max_bytes,
|
||||
max_objects=max_objects)
|
||||
|
|
Loading…
Reference in New Issue