From 0eb3014195a3e300e6179296c2cfabfa4e785821 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Tue, 28 Jul 2015 10:19:07 -0400 Subject: [PATCH] Remove RetypeVD class, fix NFS driver retype retype() only exists in the deprecated VolumeDriver() class and not BaseVD. This means that drivers inheriting from *VD hit attribute errors when trying to call driver.retype(). The thinking here is that RetypeVD isn't really necessary, since all drivers must implement some version of the retype method (even if it's a no-op with just a standard return code). Therefore, just rely on this being in the base driver class(es) rather than making it a separate abc class. Closes-Bug: #1478987 Related-Bug: #1471807 Change-Id: Ie0c6f23caf68080a05a10cc7ad245878a057fb02 --- cinder/tests/unit/test_nfs.py | 14 +++++++ cinder/volume/driver.py | 41 ++----------------- cinder/volume/drivers/ibm/gpfs.py | 2 +- .../drivers/ibm/storwize_svc/__init__.py | 1 - cinder/volume/drivers/ibm/xiv_ds8k.py | 1 - cinder/volume/drivers/rbd.py | 2 +- .../drivers/san/hp/hp_lefthand_iscsi.py | 1 - 7 files changed, 20 insertions(+), 42 deletions(-) diff --git a/cinder/tests/unit/test_nfs.py b/cinder/tests/unit/test_nfs.py index 0365d3a732b..f7617f2331d 100644 --- a/cinder/tests/unit/test_nfs.py +++ b/cinder/tests/unit/test_nfs.py @@ -1308,3 +1308,17 @@ class NfsDriverDoSetupTestCase(test.TestCase): v1, v2, mock.sentinel) + + def test_retype_is_there(self): + "Ensure that driver.retype() is there.""" + + drv = nfs.NfsDriver(configuration=self.configuration) + v1 = DumbVolume() + + ret = drv.retype(self.context, + v1, + mock.sentinel.new_type, + mock.sentinel.diff, + mock.sentinel.host) + + self.assertEqual((False, None), ret) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index f1489bcbc6e..d21d91a624c 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -922,6 +922,9 @@ class BaseVD(object): def validate_connector_has_setting(connector, setting): pass + def retype(self, context, volume, new_type, diff, host): + return False, None + # ####### Interface methods for DataPath (Connector) ######## @abc.abstractmethod def ensure_export(self, context, volume): @@ -1101,42 +1104,6 @@ class ExtendVD(object): return -@six.add_metaclass(abc.ABCMeta) -class RetypeVD(object): - @abc.abstractmethod - def retype(self, context, volume, new_type, diff, host): - """Convert the volume to be of the new type. - - Returns either: - A boolean indicating whether the retype occurred, or - A tuple (retyped, model_update) where retyped is a boolean - indicating if the retype occurred, and the model_update includes - changes for the volume db. - if diff['extra_specs'] includes 'replication' then: - if ('True', _ ) then replication should be disabled: - Volume replica should be deleted - volume['replication_status'] should be changed to 'disabled' - volume['replication_extended_status'] = None - volume['replication_driver_data'] = None - if (_, 'True') then replication should be enabled: - Volume replica (secondary) should be created, and replication - should be setup between the volume and the newly created - replica - volume['replication_status'] = 'copying' - volume['replication_extended_status'] = driver specific value - volume['replication_driver_data'] = driver specific value - - :param ctxt: Context - :param volume: A dictionary describing the volume to migrate - :param new_type: A dictionary describing the volume type to convert to - :param diff: A dictionary with the difference between the two types - :param host: A dictionary describing the host to migrate to, where - host['host'] is its name, and host['capabilities'] is a - dictionary of its reported capabilities. - """ - return False, None - - @six.add_metaclass(abc.ABCMeta) class TransferVD(object): def accept_transfer(self, context, volume, new_user, new_project): @@ -1297,7 +1264,7 @@ class ReplicaVD(object): class VolumeDriver(ConsistencyGroupVD, TransferVD, ManageableVD, ExtendVD, CloneableVD, CloneableImageVD, SnapshotVD, ReplicaVD, - RetypeVD, LocalVD, MigrateVD, BaseVD): + LocalVD, MigrateVD, BaseVD): """This class will be deprecated soon. Please use the abstract classes above for new drivers. diff --git a/cinder/volume/drivers/ibm/gpfs.py b/cinder/volume/drivers/ibm/gpfs.py index 1849c30ccb7..be952ceb282 100644 --- a/cinder/volume/drivers/ibm/gpfs.py +++ b/cinder/volume/drivers/ibm/gpfs.py @@ -110,7 +110,7 @@ def _sizestr(size_in_g): class GPFSDriver(driver.ConsistencyGroupVD, driver.ExtendVD, driver.LocalVD, driver.TransferVD, driver.CloneableVD, driver.CloneableImageVD, driver.SnapshotVD, - driver.RetypeVD, driver.MigrateVD, + driver.MigrateVD, driver.BaseVD): """Implements volume functions using GPFS primitives. diff --git a/cinder/volume/drivers/ibm/storwize_svc/__init__.py b/cinder/volume/drivers/ibm/storwize_svc/__init__.py index 5ef14515f7a..a1a8620fae7 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/__init__.py +++ b/cinder/volume/drivers/ibm/storwize_svc/__init__.py @@ -133,7 +133,6 @@ class StorwizeSVCDriver(san.SanDriver, driver.MigrateVD, driver.ReplicaVD, driver.ConsistencyGroupVD, driver.CloneableVD, driver.CloneableImageVD, - driver.RetypeVD, driver.TransferVD): """IBM Storwize V7000 and SVC iSCSI/FC volume driver. diff --git a/cinder/volume/drivers/ibm/xiv_ds8k.py b/cinder/volume/drivers/ibm/xiv_ds8k.py index 93a24e206e4..93caceaa4a4 100644 --- a/cinder/volume/drivers/ibm/xiv_ds8k.py +++ b/cinder/volume/drivers/ibm/xiv_ds8k.py @@ -67,7 +67,6 @@ class XIVDS8KDriver(san.SanDriver, driver.ConsistencyGroupVD, driver.CloneableVD, driver.CloneableImageVD, - driver.RetypeVD, driver.TransferVD): """Unified IBM XIV and DS8K volume driver.""" diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 6697cc986e0..43751cbe3b5 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -264,7 +264,7 @@ class RADOSClient(object): return int(features) -class RBDDriver(driver.RetypeVD, driver.TransferVD, driver.ExtendVD, +class RBDDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD, driver.CloneableImageVD, driver.SnapshotVD, driver.BaseVD): """Implements RADOS block device (RBD) volume commands.""" diff --git a/cinder/volume/drivers/san/hp/hp_lefthand_iscsi.py b/cinder/volume/drivers/san/hp/hp_lefthand_iscsi.py index ed118ec5dc6..0a065207c15 100644 --- a/cinder/volume/drivers/san/hp/hp_lefthand_iscsi.py +++ b/cinder/volume/drivers/san/hp/hp_lefthand_iscsi.py @@ -50,7 +50,6 @@ class HPLeftHandISCSIDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD, driver.SnapshotVD, - driver.RetypeVD, driver.MigrateVD, driver.BaseVD): """Executes commands relating to HP/LeftHand SAN ISCSI volumes.