Add support of a common volume_backend_name
Previously, we didn't have a control over volume_backend_name other than the default app name in the Juju model. A common backend name to multiple backends with the same character is useful because those can be treated as a single virtual backend associated with a single volume type. Change-Id: I4b57f7979837d21a1b116007f3da707ee154792b Closes-Bug: #1884511
This commit is contained in:
parent
709b184259
commit
d9873fd22c
10
config.yaml
10
config.yaml
@ -24,6 +24,16 @@ options:
|
||||
created for the pool. The number of placement groups for a pool can
|
||||
only be increased, never decreased - so it is important to identify the
|
||||
percent of data that will likely reside in the pool.
|
||||
volume-backend-name:
|
||||
default:
|
||||
type: string
|
||||
description: |
|
||||
Volume backend name for the backend. The default value is the
|
||||
application name in the Juju model, e.g. "cinder-ceph-mybackend"
|
||||
if it's deployed as `juju deploy cinder-ceph cinder-ceph-mybackend`.
|
||||
A common backend name can be set to multiple backends with the
|
||||
same characters so that those can be treated as a single virtual
|
||||
backend associated with a single volume type.
|
||||
backend-availability-zone:
|
||||
default:
|
||||
type: string
|
||||
|
@ -73,6 +73,11 @@ class CephSubordinateContext(OSContextGenerator):
|
||||
else:
|
||||
volume_driver = 'cinder.volume.driver.RBDDriver'
|
||||
|
||||
if config('volume-backend-name'):
|
||||
volume_backend_name = config('volume-backend-name')
|
||||
else:
|
||||
volume_backend_name = service
|
||||
|
||||
if config('pool-type') == 'erasure-coded':
|
||||
pool_name = (
|
||||
config('ec-rbd-metadata-pool') or
|
||||
@ -81,8 +86,7 @@ class CephSubordinateContext(OSContextGenerator):
|
||||
)
|
||||
else:
|
||||
pool_name = config('rbd-pool-name') or service
|
||||
|
||||
section = {service: [('volume_backend_name', service),
|
||||
section = {service: [('volume_backend_name', volume_backend_name),
|
||||
('volume_driver', volume_driver),
|
||||
('rbd_pool', pool_name),
|
||||
('rbd_user', service),
|
||||
|
@ -118,6 +118,32 @@ class TestCinderContext(CharmTestCase):
|
||||
}
|
||||
}})
|
||||
|
||||
def test_ceph_explicit_volume_backend_name(self):
|
||||
self.test_config.set('volume-backend-name', 'special-backend-name')
|
||||
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', 'special-backend-name'),
|
||||
('volume_driver',
|
||||
'cinder.volume.drivers.rbd.RBDDriver'),
|
||||
('rbd_pool', service),
|
||||
('rbd_user', service),
|
||||
('rbd_secret_uuid', 'libvirt-uuid'),
|
||||
('rbd_ceph_conf',
|
||||
'/var/lib/charm/mycinder/ceph.conf'),
|
||||
('report_discard_supported', True)
|
||||
]
|
||||
}
|
||||
}
|
||||
}})
|
||||
|
||||
def test_ceph_related_erasure_coded(self):
|
||||
self.is_relation_made.return_value = True
|
||||
self.get_os_codename_package.return_value = "queens"
|
||||
|
Loading…
Reference in New Issue
Block a user