summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-10-22 01:24:32 +0000
committerGerrit Code Review <review@openstack.org>2012-10-22 01:24:32 +0000
commit8cb329b2a03f1d04f13c38244477e53ca4a321f0 (patch)
treebed6dbeb3d7a36f4b5562fe1442789174be21712 /nova/tests
parentf1155fc9491070b58ac2908f82a324388ed3c27e (diff)
parentaf51b46b1e08b26c07bd32019e54b9c521cb7813 (diff)
Merge "Allow local rbd user and secret_uuid configuration"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_libvirt.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index 7de72266b..43b4d4813 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -299,6 +299,38 @@ class LibvirtVolumeTestCase(test.TestCase):
libvirt_driver.disconnect_volume(connection_info, mount_device)
connection_info = vol_driver.terminate_connection(vol, self.connr)
+ def test_libvirt_rbd_driver_auth_enabled_flags_override(self):
+ vol_driver = volume_driver.RBDDriver()
+ libvirt_driver = volume.LibvirtNetVolumeDriver(self.fake_conn)
+ name = 'volume-00000001'
+ vol = {'id': 1, 'name': name}
+ connection_info = vol_driver.initialize_connection(vol, self.connr)
+ uuid = '875a8070-d0b9-4949-8b31-104d125c9a64'
+ user = 'foo'
+ secret_type = 'ceph'
+ connection_info['data']['auth_enabled'] = True
+ connection_info['data']['auth_username'] = user
+ connection_info['data']['secret_type'] = secret_type
+ connection_info['data']['secret_uuid'] = uuid
+
+ flags_uuid = '37152720-1785-11e2-a740-af0c1d8b8e4b'
+ flags_user = 'bar'
+ self.flags(rbd_user=flags_user,
+ rbd_secret_uuid=flags_uuid)
+
+ mount_device = "vde"
+ conf = libvirt_driver.connect_volume(connection_info, mount_device)
+ tree = conf.format_dom()
+ self.assertEqual(tree.get('type'), 'network')
+ self.assertEqual(tree.find('./source').get('protocol'), 'rbd')
+ rbd_name = '%s/%s' % (FLAGS.rbd_pool, name)
+ self.assertEqual(tree.find('./source').get('name'), rbd_name)
+ self.assertEqual(tree.find('./auth').get('username'), flags_user)
+ self.assertEqual(tree.find('./auth/secret').get('type'), secret_type)
+ self.assertEqual(tree.find('./auth/secret').get('uuid'), flags_uuid)
+ libvirt_driver.disconnect_volume(connection_info, mount_device)
+ connection_info = vol_driver.terminate_connection(vol, self.connr)
+
def test_libvirt_rbd_driver_auth_disabled(self):
vol_driver = volume_driver.RBDDriver()
libvirt_driver = volume.LibvirtNetVolumeDriver(self.fake_conn)
@@ -324,6 +356,40 @@ class LibvirtVolumeTestCase(test.TestCase):
libvirt_driver.disconnect_volume(connection_info, mount_device)
connection_info = vol_driver.terminate_connection(vol, self.connr)
+ def test_libvirt_rbd_driver_auth_disabled_flags_override(self):
+ vol_driver = volume_driver.RBDDriver()
+ libvirt_driver = volume.LibvirtNetVolumeDriver(self.fake_conn)
+ name = 'volume-00000001'
+ vol = {'id': 1, 'name': name}
+ connection_info = vol_driver.initialize_connection(vol, self.connr)
+ uuid = '875a8070-d0b9-4949-8b31-104d125c9a64'
+ user = 'foo'
+ secret_type = 'ceph'
+ connection_info['data']['auth_enabled'] = False
+ connection_info['data']['auth_username'] = user
+ connection_info['data']['secret_type'] = secret_type
+ connection_info['data']['secret_uuid'] = uuid
+
+ # NOTE: Supplying the rbd_secret_uuid will enable authentication
+ # locally in nova-compute even if not enabled in nova-volume/cinder
+ flags_uuid = '37152720-1785-11e2-a740-af0c1d8b8e4b'
+ flags_user = 'bar'
+ self.flags(rbd_user=flags_user,
+ rbd_secret_uuid=flags_uuid)
+
+ mount_device = "vde"
+ conf = libvirt_driver.connect_volume(connection_info, mount_device)
+ tree = conf.format_dom()
+ self.assertEqual(tree.get('type'), 'network')
+ self.assertEqual(tree.find('./source').get('protocol'), 'rbd')
+ rbd_name = '%s/%s' % (FLAGS.rbd_pool, name)
+ self.assertEqual(tree.find('./source').get('name'), rbd_name)
+ self.assertEqual(tree.find('./auth').get('username'), flags_user)
+ self.assertEqual(tree.find('./auth/secret').get('type'), secret_type)
+ self.assertEqual(tree.find('./auth/secret').get('uuid'), flags_uuid)
+ libvirt_driver.disconnect_volume(connection_info, mount_device)
+ connection_info = vol_driver.terminate_connection(vol, self.connr)
+
def test_libvirt_lxc_volume(self):
self.stubs.Set(os.path, 'exists', lambda x: True)
vol_driver = volume_driver.ISCSIDriver()