From 7413d64994b6b7f1e13c6789c68a68f260afa2a8 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Sun, 3 May 2015 22:46:49 +0000 Subject: [PATCH] Port remote_fs driver to use new driver model Port glusterfs and nfs drivers to ABC classes. Abstract San class must be ported as well, otherwise we will have a inheritance loop for IBM NAS driver. Change-Id: I905c0256402472de87c7fccb922c207ce5a0e483 Implements: blueprint abc-driver-update --- cinder/tests/unit/test_glusterfs.py | 4 ++-- cinder/tests/unit/test_pure.py | 7 ++++++- cinder/tests/unit/test_san.py | 15 ++++++++++++++- cinder/volume/drivers/glusterfs.py | 6 ++++-- cinder/volume/drivers/nfs.py | 5 +++-- cinder/volume/drivers/remotefs.py | 7 ++----- cinder/volume/drivers/san/san.py | 2 +- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/cinder/tests/unit/test_glusterfs.py b/cinder/tests/unit/test_glusterfs.py index 28dbecb61..b0043f7a3 100644 --- a/cinder/tests/unit/test_glusterfs.py +++ b/cinder/tests/unit/test_glusterfs.py @@ -1579,7 +1579,7 @@ class GlusterFsDriverTestCase(test.TestCase): mock_get_active_image_from_info,\ mock.patch.object(drv, '_qemu_img_info') as \ mock_qemu_img_info,\ - mock.patch.object(base_driver.VolumeDriver, 'backup_volume') as \ + mock.patch.object(base_driver.BaseVD, 'backup_volume') as \ mock_backup_volume: ctxt = context.RequestContext('fake_user', 'fake_project') volume = self._simple_volume() @@ -1606,7 +1606,7 @@ class GlusterFsDriverTestCase(test.TestCase): mock_get_active_image_from_info,\ mock.patch.object(drv, '_qemu_img_info') as \ mock_qemu_img_info,\ - mock.patch.object(base_driver.VolumeDriver, 'backup_volume') as \ + mock.patch.object(base_driver.BaseVD, 'backup_volume') as \ mock_backup_volume: ctxt = context.RequestContext('fake_user', 'fake_project') volume = self._simple_volume() diff --git a/cinder/tests/unit/test_pure.py b/cinder/tests/unit/test_pure.py index 49101c3de..075faafaa 100644 --- a/cinder/tests/unit/test_pure.py +++ b/cinder/tests/unit/test_pure.py @@ -214,9 +214,14 @@ class PureDriverTestCase(test.TestCase): class PureBaseVolumeDriverTestCase(PureDriverTestCase): + class fake_pure_base_volume_driver(pure.PureBaseVolumeDriver): + def initialize_connection(): + pass + def setUp(self): super(PureBaseVolumeDriverTestCase, self).setUp() - self.driver = pure.PureBaseVolumeDriver(configuration=self.mock_config) + self.driver = self.fake_pure_base_volume_driver( + configuration=self.mock_config) self.driver._array = self.array def test_generate_purity_host_name(self): diff --git a/cinder/tests/unit/test_san.py b/cinder/tests/unit/test_san.py index 951690177..447865555 100644 --- a/cinder/tests/unit/test_san.py +++ b/cinder/tests/unit/test_san.py @@ -40,12 +40,25 @@ class SanDriverTestCase(test.TestCase): self.configuration.ssh_max_pool_conn = 5 self.configuration.ssh_conn_timeout = 30 + class fake_san_driver(san.SanDriver): + def initialize_connection(): + pass + + def create_volume(): + pass + + def delete_volume(): + pass + + def terminate_connection(): + pass + @mock.patch.object(san.processutils, 'ssh_execute') @mock.patch.object(san.ssh_utils, 'SSHPool') @mock.patch.object(san.utils, 'check_ssh_injection') def test_ssh_formatted_command(self, mock_check_ssh_injection, mock_ssh_pool, mock_ssh_execute): - driver = san.SanDriver(configuration=self.configuration) + driver = self.fake_san_driver(configuration=self.configuration) cmd_list = ['uname', '-s'] expected_cmd = 'uname -s' driver.san_execute(*cmd_list) diff --git a/cinder/volume/drivers/glusterfs.py b/cinder/volume/drivers/glusterfs.py index 7b9b0e4dc..bd9e0fa6e 100644 --- a/cinder/volume/drivers/glusterfs.py +++ b/cinder/volume/drivers/glusterfs.py @@ -28,6 +28,7 @@ from cinder.i18n import _, _LE, _LI, _LW from cinder.image import image_utils from cinder.openstack.common import fileutils from cinder import utils +from cinder.volume import driver from cinder.volume.drivers import remotefs as remotefs_drv LOG = logging.getLogger(__name__) @@ -53,7 +54,8 @@ CONF = cfg.CONF CONF.register_opts(volume_opts) -class GlusterfsDriver(remotefs_drv.RemoteFSSnapDriver): +class GlusterfsDriver(remotefs_drv.RemoteFSSnapDriver, driver.CloneableVD, + driver.ExtendVD): """Gluster based cinder driver. Creates file on Gluster share for using it as block device on hypervisor. @@ -65,7 +67,7 @@ class GlusterfsDriver(remotefs_drv.RemoteFSSnapDriver): driver_volume_type = 'glusterfs' driver_prefix = 'glusterfs' volume_backend_name = 'GlusterFS' - VERSION = '1.2.0' + VERSION = '1.3.0' def __init__(self, execute=processutils.execute, *args, **kwargs): self._remotefsclient = None diff --git a/cinder/volume/drivers/nfs.py b/cinder/volume/drivers/nfs.py index 9d140aa83..043d770c6 100644 --- a/cinder/volume/drivers/nfs.py +++ b/cinder/volume/drivers/nfs.py @@ -28,9 +28,10 @@ from cinder import exception from cinder.i18n import _, _LE, _LI, _LW from cinder.image import image_utils from cinder import utils +from cinder.volume import driver from cinder.volume.drivers import remotefs -VERSION = '1.2.0' +VERSION = '1.3.0' LOG = logging.getLogger(__name__) @@ -72,7 +73,7 @@ CONF = cfg.CONF CONF.register_opts(nfs_opts) -class NfsDriver(remotefs.RemoteFSDriver): +class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver): """NFS based cinder driver. Creates file on NFS share for using it as block device on hypervisor. """ diff --git a/cinder/volume/drivers/remotefs.py b/cinder/volume/drivers/remotefs.py index 109e9ca9b..f502c4cce 100644 --- a/cinder/volume/drivers/remotefs.py +++ b/cinder/volume/drivers/remotefs.py @@ -120,7 +120,7 @@ def locked_volume_id_operation(f, external=False): return lvo_inner1 -class RemoteFSDriver(driver.VolumeDriver): +class RemoteFSDriver(driver.LocalVD, driver.TransferVD, driver.BaseVD): """Common base for drivers that work like NFS.""" driver_volume_type = None @@ -262,9 +262,6 @@ class RemoteFSDriver(driver.VolumeDriver): LOG.debug('Available shares %s', self._mounted_shares) - def create_cloned_volume(self, volume, src_vref): - raise NotImplementedError() - def delete_volume(self, volume): """Deletes a logical volume. @@ -606,7 +603,7 @@ class RemoteFSDriver(driver.VolumeDriver): return nas_option -class RemoteFSSnapDriver(RemoteFSDriver): +class RemoteFSSnapDriver(RemoteFSDriver, driver.SnapshotVD): """Base class for remotefs drivers implementing qcow2 snapshots. Driver must implement: diff --git a/cinder/volume/drivers/san/san.py b/cinder/volume/drivers/san/san.py index 3200a669d..a92f81bfd 100644 --- a/cinder/volume/drivers/san/san.py +++ b/cinder/volume/drivers/san/san.py @@ -77,7 +77,7 @@ CONF = cfg.CONF CONF.register_opts(san_opts) -class SanDriver(driver.VolumeDriver): +class SanDriver(driver.BaseVD): """Base class for SAN-style storage volumes A SAN-style storage value is 'different' because the volume controller -- 2.45.2