Expose rbd-pool-name
In some situations an existing rbd pool may already be populated with images that are in use. This is the case when migrating from the old topology where cinder had a direct relation to ceph-mon. Change-Id: I93eb801ca4a166f862d5d86711d9476c61851344
This commit is contained in:
parent
4e3bf3e7f3
commit
df6b239526
@ -34,3 +34,8 @@ options:
|
||||
type: boolean
|
||||
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.
|
||||
|
@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
config,
|
||||
service_name,
|
||||
is_relation_made,
|
||||
leader_get,
|
||||
@ -51,9 +52,13 @@ class CephSubordinateContext(OSContextGenerator):
|
||||
else:
|
||||
volume_driver = 'cinder.volume.driver.RBDDriver'
|
||||
|
||||
if config('rbd-pool-name'):
|
||||
pool_name = config('rbd-pool-name')
|
||||
else:
|
||||
pool_name = service
|
||||
section = {service: [('volume_backend_name', service),
|
||||
('volume_driver', volume_driver),
|
||||
('rbd_pool', service),
|
||||
('rbd_pool', pool_name),
|
||||
('rbd_user', service),
|
||||
('rbd_secret_uuid', leader_get('secret-uuid')),
|
||||
('rbd_ceph_conf', ceph_config_file())]}
|
||||
|
@ -19,6 +19,7 @@ from test_utils import (
|
||||
)
|
||||
|
||||
TO_PATCH = [
|
||||
'config',
|
||||
'is_relation_made',
|
||||
'service_name',
|
||||
'get_os_codename_package',
|
||||
@ -30,6 +31,7 @@ class TestCinderContext(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCinderContext, self).setUp(contexts, TO_PATCH)
|
||||
self.config.side_effect = self.test_config.get
|
||||
self.leader_get.return_value = 'libvirt-uuid'
|
||||
self.maxDiff = None
|
||||
|
||||
@ -111,3 +113,29 @@ class TestCinderContext(CharmTestCase):
|
||||
}
|
||||
}
|
||||
}})
|
||||
|
||||
def test_ceph_explicit_pool_name(self):
|
||||
self.test_config.set('rbd-pool-name', 'special_pool')
|
||||
self.is_relation_made.return_value = True
|
||||
self.get_os_codename_package.return_value = "mitaka"
|
||||
service = 'mycinder'
|
||||
self.service_name.return_value = service
|
||||
self.assertEqual(
|
||||
contexts.CephSubordinateContext()(),
|
||||
{"cinder": {
|
||||
"/etc/cinder/cinder.conf": {
|
||||
"sections": {
|
||||
service: [
|
||||
('volume_backend_name', service),
|
||||
('volume_driver',
|
||||
'cinder.volume.drivers.rbd.RBDDriver'),
|
||||
('rbd_pool', 'special_pool'),
|
||||
('rbd_user', service),
|
||||
('rbd_secret_uuid', 'libvirt-uuid'),
|
||||
('rbd_ceph_conf',
|
||||
'/var/lib/charm/mycinder/ceph.conf'),
|
||||
('report_discard_supported', True)
|
||||
]
|
||||
}
|
||||
}
|
||||
}})
|
||||
|
Loading…
Reference in New Issue
Block a user