Allows libvirt to set a serial number for a volume

The serial number defaults to the volume_id of the volume being
attached. We may expose a method in the future to set a different
serial number when creating or attaching a volume.

The purpose of this change is to give users a consistent place
they can find their volume. It should show up now in most flavors
of linux under /disk/by-id/virtio-<volume_uuid>

Fixes bug 1004328

Change-Id: Id1c56b5b23d799deb7da2d39ae57ecb48965c55f
This commit is contained in:
Vishvananda Ishaya
2012-08-16 11:28:27 -07:00
parent 6cb3520587
commit 425b671752

View File

@@ -154,6 +154,24 @@ class LibvirtVolumeTestCase(test.TestCase):
'host': 'fake_host'
}
def test_libvirt_volume_driver_serial(self):
vol_driver = volume_driver.VolumeDriver()
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
name = 'volume-00000001'
vol = {'id': 1, 'name': name}
connection_info = {
'driver_volume_type': 'fake',
'data': {
'device_path': '/foo',
},
'serial': 'fake_serial',
}
mount_device = "vde"
conf = libvirt_driver.connect_volume(connection_info, mount_device)
tree = conf.format_dom()
self.assertEqual(tree.get('type'), 'block')
self.assertEqual(tree.find('./serial').text, 'fake_serial')
def test_libvirt_iscsi_driver(self):
# NOTE(vish) exists is to make driver assume connecting worked
self.stubs.Set(os.path, 'exists', lambda x: True)