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
This commit is contained in:
Eric Harney 2015-07-28 10:19:07 -04:00
parent 7e84f149e8
commit 0eb3014195
7 changed files with 20 additions and 42 deletions

View File

@ -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)

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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."""

View File

@ -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."""

View File

@ -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.