From d1714de91e73137ad621509e417b679ebc8160ad Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 21 Feb 2017 13:50:04 -0500 Subject: [PATCH] Fix volume_driver configuration < ocata For releases prior to ocata, the volume_driver key must be provided by the CephContext to ensure that a single driver is set for cinder. Specialize behaviour for >= ocata only, resolving issues with pre ocata deployments with direct relations to ceph. Change-Id: I9ff47853ab0726ed5c77c67f21f873349bc64f7b --- hooks/cinder_contexts.py | 6 +++++- unit_tests/test_cinder_contexts.py | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/hooks/cinder_contexts.py b/hooks/cinder_contexts.py index 1ef0638a..8aec95d6 100644 --- a/hooks/cinder_contexts.py +++ b/hooks/cinder_contexts.py @@ -70,8 +70,12 @@ class CephContext(OSContextGenerator): volume_driver = 'cinder.volume.drivers.rbd.RBDDriver' else: volume_driver = 'cinder.volume.driver.RBDDriver' + if os_release('cinder-common') >= "ocata": + driver_key = 'ceph_volume_driver' + else: + driver_key = 'volume_driver' return { - 'ceph_volume_driver': volume_driver, + driver_key: volume_driver, # ensure_ceph_pool() creates pool based on service name. 'rbd_pool': service, 'rbd_user': service, diff --git a/unit_tests/test_cinder_contexts.py b/unit_tests/test_cinder_contexts.py index 97fe8808..f0cb716c 100644 --- a/unit_tests/test_cinder_contexts.py +++ b/unit_tests/test_cinder_contexts.py @@ -75,7 +75,7 @@ class TestCinderContext(CharmTestCase): self.service_name.return_value = service self.assertEquals( contexts.CephContext()(), - {'ceph_volume_driver': 'cinder.volume.driver.RBDDriver', + {'volume_driver': 'cinder.volume.driver.RBDDriver', 'rbd_pool': service, 'rbd_user': service, 'host': service}) @@ -85,6 +85,18 @@ class TestCinderContext(CharmTestCase): self.os_release.return_value = 'icehouse' service = 'mycinder' self.service_name.return_value = service + self.assertEquals( + contexts.CephContext()(), + {'volume_driver': 'cinder.volume.drivers.rbd.RBDDriver', + 'rbd_pool': service, + 'rbd_user': service, + 'host': service}) + + def test_ceph_related_ocata(self): + self.relation_ids.return_value = ['ceph:0'] + self.os_release.return_value = 'ocata' + service = 'mycinder' + self.service_name.return_value = service self.assertEquals( contexts.CephContext()(), {'ceph_volume_driver': 'cinder.volume.drivers.rbd.RBDDriver',