libvirt: move the LibvirtGPFSVolumeDriver into it's own module

Part of blueprint consolidate-libvirt-fs-volume-drivers

Change-Id: If275ed3101a76c0ccbb42df4261e5125eed74674
This commit is contained in:
Matt Riedemann 2015-06-18 11:23:29 -07:00
parent b8b4d5cf53
commit 377e60e3b4
5 changed files with 61 additions and 30 deletions

View File

@ -0,0 +1,32 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from nova.tests.unit.virt.libvirt.volume import test_volume
from nova.virt.libvirt.volume import gpfs
class LibvirtGPFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
def test_libvirt_gpfs_driver_get_config(self):
libvirt_driver = gpfs.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

@ -922,17 +922,3 @@ 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

@ -285,7 +285,7 @@ libvirt_volume_drivers = [
'fibre_channel='
'nova.virt.libvirt.volume.volume.LibvirtFibreChannelVolumeDriver',
'scality=nova.virt.libvirt.volume.volume.LibvirtScalityVolumeDriver',
'gpfs=nova.virt.libvirt.volume.volume.LibvirtGPFSVolumeDriver',
'gpfs=nova.virt.libvirt.volume.gpfs.LibvirtGPFSVolumeDriver',
'quobyte=nova.virt.libvirt.volume.quobyte.LibvirtQuobyteVolumeDriver',
]

View File

@ -0,0 +1,28 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from nova.virt.libvirt.volume import volume as libvirt_volume
class LibvirtGPFSVolumeDriver(libvirt_volume.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

View File

@ -763,18 +763,3 @@ class LibvirtScalityVolumeDriver(LibvirtBaseVolumeDriver):
msg = _("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