Remove duplicated fake drivers

We don't need to have several fake drivers like FakeISCSIDriver. Let's
leave only one copy of each in tests directory. They could be used for
unit, functional and integrational tests as well.

Change-Id: I45f852544ff9ca9d4ab50546e036afb4f1e31904
This commit is contained in:
Ivan Kolodyazhny 2016-06-13 14:31:52 +03:00
parent caee4d0459
commit ffecc60a25
2 changed files with 23 additions and 128 deletions

View File

@ -35,6 +35,9 @@ class FakeISCSIDriver(lvm.LVMVolumeDriver):
"""No setup necessary in fake mode."""
pass
def create_volume(self, volume):
pass
def initialize_connection(self, volume, connector):
volume_metadata = {}
@ -50,9 +53,29 @@ class FakeISCSIDriver(lvm.LVMVolumeDriver):
return {'driver_volume_type': 'iscsi',
'data': {'access_mode': access_mode}}
def initialize_connection_snapshot(self, snapshot, connector):
return {
'driver_volume_type': 'iscsi',
}
def terminate_connection(self, volume, connector, **kwargs):
pass
def _update_pools_and_stats(self, data):
fake_pool = {}
fake_pool.update(dict(
pool_name=data["volume_backend_name"],
total_capacity_gb='infinite',
free_capacity_gb='infinite',
provisioned_capacity_gb=0,
reserved_percentage=100,
QoS_support=False,
filter_function=self.get_filter_function(),
goodness_function=self.get_goodness_function()
))
data["pools"].append(fake_pool)
self._stats = data
@staticmethod
def fake_execute(cmd, *_args, **_kwargs):
"""Execute that simply logs the command."""
@ -60,7 +83,6 @@ class FakeISCSIDriver(lvm.LVMVolumeDriver):
class FakeISERDriver(FakeISCSIDriver):
"""Logs calls instead of executing."""
def __init__(self, *args, **kwargs):
super(FakeISERDriver, self).__init__(execute=self.fake_execute,
*args, **kwargs)
@ -71,11 +93,6 @@ class FakeISERDriver(FakeISCSIDriver):
'data': {}
}
@staticmethod
def fake_execute(cmd, *_args, **_kwargs):
"""Execute that simply logs the command."""
return (None, None)
class FakeFibreChannelDriver(driver.FibreChannelDriver):

View File

@ -2659,109 +2659,6 @@ class ISCSIDriver(VolumeDriver):
self._update_pools_and_stats(data)
class FakeISCSIDriver(ISCSIDriver):
"""Logs calls instead of executing."""
def __init__(self, *args, **kwargs):
super(FakeISCSIDriver, self).__init__(execute=self.fake_execute,
*args, **kwargs)
def _update_pools_and_stats(self, data):
fake_pool = {}
fake_pool.update(dict(
pool_name=data["volume_backend_name"],
total_capacity_gb='infinite',
free_capacity_gb='infinite',
provisioned_capacity_gb=0,
reserved_percentage=100,
QoS_support=False,
filter_function=self.get_filter_function(),
goodness_function=self.get_goodness_function()
))
data["pools"].append(fake_pool)
self._stats = data
def create_volume(self, volume):
pass
def check_for_setup_error(self):
"""No setup necessary in fake mode."""
pass
def initialize_connection(self, volume, connector):
return {
'driver_volume_type': 'iscsi',
'discard': False,
}
def initialize_connection_snapshot(self, snapshot, connector):
return {
'driver_volume_type': 'iscsi',
}
def terminate_connection(self, volume, connector, **kwargs):
pass
def terminate_connection_snapshot(self, snapshot, connector, **kwargs):
pass
@staticmethod
def fake_execute(cmd, *_args, **_kwargs):
"""Execute that simply logs the command."""
LOG.debug("FAKE ISCSI: %s", cmd)
return (None, None)
def create_volume_from_snapshot(self, volume, snapshot):
"""Creates a volume from a snapshot."""
pass
def create_cloned_volume(self, volume, src_vref):
"""Creates a clone of the specified volume."""
pass
def delete_volume(self, volume):
"""Deletes a volume."""
pass
def create_snapshot(self, snapshot):
"""Creates a snapshot."""
pass
def delete_snapshot(self, snapshot):
"""Deletes a snapshot."""
pass
def local_path(self, volume):
return '/tmp/volume-%s' % volume.id
def ensure_export(self, context, volume):
"""Synchronously recreates an export for a volume."""
pass
def create_export(self, context, volume, connector):
"""Exports the volume.
Can optionally return a Dictionary of changes to the volume object to
be persisted.
"""
pass
def create_export_snapshot(self, context, snapshot, connector):
"""Exports the snapshot.
Can optionally return a Dictionary of changes to the snapshot object to
be persisted.
"""
pass
def remove_export(self, context, volume):
"""Removes an export for a volume."""
pass
def remove_export_snapshot(self, context, snapshot):
"""Removes an export for a snapshot."""
pass
class ISERDriver(ISCSIDriver):
"""Executes commands relating to ISER volumes.
@ -2830,25 +2727,6 @@ class ISERDriver(ISCSIDriver):
self._update_pools_and_stats(data)
class FakeISERDriver(FakeISCSIDriver):
"""Logs calls instead of executing."""
def __init__(self, *args, **kwargs):
super(FakeISERDriver, self).__init__(execute=self.fake_execute,
*args, **kwargs)
def initialize_connection(self, volume, connector):
return {
'driver_volume_type': 'iser',
'data': {}
}
@staticmethod
def fake_execute(cmd, *_args, **_kwargs):
"""Execute that simply logs the command."""
LOG.debug("FAKE ISER: %s", cmd)
return (None, None)
class FibreChannelDriver(VolumeDriver):
"""Executes commands relating to Fibre Channel volumes."""
def __init__(self, *args, **kwargs):