Merge "Make the rbd pool name configurable"

This commit is contained in:
Zuul 2020-07-13 05:58:05 +00:00 committed by Gerrit Code Review
commit 8bad74f767
4 changed files with 28 additions and 3 deletions

View File

@ -110,6 +110,11 @@ options:
default: False
description: |
Optionally restrict Ceph key permissions to access pools as required.
rbd-pool-name:
default:
type: string
description: |
Optionally specify an existing rbd pool that cinder should map to.
worker-multiplier:
type: float
default:

View File

@ -111,9 +111,13 @@ class CephGlanceContext(OSContextGenerator):
keys="key"):
return {}
service = service_name()
if config('rbd-pool-name'):
pool_name = config('rbd-pool-name')
else:
pool_name = service
return {
# pool created based on service name.
'rbd_pool': service,
'rbd_pool': pool_name,
'rbd_user': service,
'expose_image_locations': config('expose-image-locations')
}

View File

@ -302,10 +302,14 @@ def ceph_joined():
def get_ceph_request():
service = service_name()
if config('rbd-pool-name'):
pool_name = config('rbd-pool-name')
else:
pool_name = service
rq = CephBrokerRq()
replicas = config('ceph-osd-replication-count')
weight = config('ceph-pool-weight')
rq.add_op_create_pool(name=service, replica_count=replicas,
rq.add_op_create_pool(name=pool_name, replica_count=replicas,
weight=weight, group='images', app_name='rbd')
if config('restrict-ceph-pools'):
rq.add_op_request_access_to_group(

View File

@ -107,13 +107,25 @@ class TestGlanceContexts(CharmTestCase):
self.is_relation_made.return_value = True
service = 'glance'
self.service_name.return_value = service
self.config.return_value = True
conf_dict = {
'rbd-pool-name': None,
'expose-image-locations': True}
self.config.side_effect = lambda x: conf_dict[x]
self.assertEqual(
contexts.CephGlanceContext()(),
{'rbd_pool': service,
'rbd_user': service,
'expose_image_locations': True})
self.config.assert_called_with('expose-image-locations')
# Check user supplied pool name:
conf_dict = {
'rbd-pool-name': 'mypoolname',
'expose-image-locations': True}
self.assertEqual(
contexts.CephGlanceContext()(),
{'rbd_pool': 'mypoolname',
'rbd_user': service,
'expose_image_locations': True})
def test_multistore_below_mitaka(self):
self.os_release.return_value = 'liberty'