Add LibvirtGPFSVolumeDriver class

Currently, GPFS use LibvirtVolumeDriver to generate the libvirt
xml configuration when attaching a gpfs volume. But the driver
always set the disk_type to 'block' which should be 'file' for
GPFS volume.

This patch create a new volume driver class for GPFS, the class
can generate the right xml configuration for GPFS volume.

Change-Id: Ica1cf3558baeea12b519bda50c61cea446429364
Closes-Bug:#1405044
This commit is contained in:
lqslan 2014-12-23 15:35:11 +08:00
parent e66a3b36a0
commit 8c62b79610
3 changed files with 31 additions and 0 deletions

View File

@ -1350,3 +1350,17 @@ Setting up iSCSI targets: unused
export_string, export_mnt_base),
('umount', export_mnt_base)]
self.assertEqual(expected_commands, self.executes)
def test_libvirt_gpfs_driver_get_config(self):
libvirt_driver = volume.LibvirtGPFSVolumeDriver(self.fake_conn)
connection_info = {
'driver_volume_type': 'gpfs',
'data': {
'device_path': '/gpfs/foo',
},
'serial': 'fake_serial',
}
conf = libvirt_driver.get_config(connection_info, self.disk_info)
tree = conf.format_dom()
self.assertEqual('file', tree.get('type'))
self.assertEqual('fake_serial', tree.find('./serial').text)

View File

@ -180,6 +180,8 @@ libvirt_opts = [
'LibvirtFibreChannelVolumeDriver',
'scality='
'nova.virt.libvirt.volume.LibvirtScalityVolumeDriver',
'gpfs='
'nova.virt.libvirt.volume.LibvirtGPFSVolumeDriver',
],
help='DEPRECATED. Libvirt handlers for remote volumes. '
'This option is deprecated and will be removed in the '

View File

@ -1252,3 +1252,18 @@ class LibvirtScalityVolumeDriver(LibvirtBaseVolumeDriver):
msg = _LW("Cannot mount Scality SOFS, check syslog for errors")
LOG.warn(msg)
raise exception.NovaException(msg)
class LibvirtGPFSVolumeDriver(LibvirtBaseVolumeDriver):
"""Class for volumes backed by gpfs volume."""
def __init__(self, connection):
super(LibvirtGPFSVolumeDriver,
self).__init__(connection, is_block_dev=False)
def get_config(self, connection_info, disk_info):
"""Returns xml for libvirt."""
conf = super(LibvirtGPFSVolumeDriver,
self).get_config(connection_info, disk_info)
conf.source_type = "file"
conf.source_path = connection_info['data']['device_path']
return conf