Fixup icehouse driver handling, add test case

This commit is contained in:
James Page 2014-04-02 09:13:47 +01:00
parent 09015dc9a6
commit a44090317d
2 changed files with 34 additions and 3 deletions

View File

@ -1,12 +1,15 @@
from charmhelpers.core.hookenv import (
service_name,
is_relation_made
is_relation_made,
config
)
from charmhelpers.contrib.openstack.context import (
OSContextGenerator,
)
from charmhelpers.contrib.openstack.utils import get_os_codename_install_source
class CephSubordinateContext(OSContextGenerator):
interfaces = ['ceph-cinder']
@ -19,14 +22,18 @@ class CephSubordinateContext(OSContextGenerator):
if not is_relation_made('ceph', 'key'):
return {}
service = service_name()
if get_os_codename_install_source(config('openstack-origin')) \
>= "icehouse":
volume_driver = 'cinder.volume.drivers.rbd.RBDDriver'
else:
volume_driver = 'cinder.volume.driver.RBDDriver'
return {
"cinder": {
"/etc/cinder/cinder.conf": {
"sections": {
service: [
('volume_backend_name', service),
('volume_driver',
'cinder.volume.driver.RBDDriver'),
('volume_driver', volume_driver),
('rbd_pool', service),
('rbd_user', service),
]

View File

@ -7,6 +7,8 @@ from test_utils import (
TO_PATCH = [
'is_relation_made',
'service_name',
'config',
'get_os_codename_install_source'
]
@ -21,6 +23,7 @@ class TestCinderContext(CharmTestCase):
def test_ceph_related(self):
self.is_relation_made.return_value = True
self.get_os_codename_install_source.return_value = "havana"
service = 'mycinder'
self.service_name.return_value = service
self.assertEquals(
@ -38,3 +41,24 @@ class TestCinderContext(CharmTestCase):
}
}
}})
def test_ceph_related_icehouse(self):
self.is_relation_made.return_value = True
self.get_os_codename_install_source.return_value = "icehouse"
service = 'mycinder'
self.service_name.return_value = service
self.assertEquals(
contexts.CephSubordinateContext()(),
{"cinder": {
"/etc/cinder/cinder.conf": {
"sections": {
service: [
('volume_backend_name', service),
('volume_driver',
'cinder.volume.drivers.rbd.RBDDriver'),
('rbd_pool', service),
('rbd_user', service),
]
}
}
}})