]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port remote_fs driver to use new driver model
authorJenkins <jenkins@review.openstack.org>
Sun, 3 May 2015 22:46:49 +0000 (22:46 +0000)
committerMarc Koderer <marc@koderer.com>
Mon, 8 Jun 2015 11:02:03 +0000 (13:02 +0200)
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
cinder/tests/unit/test_pure.py
cinder/tests/unit/test_san.py
cinder/volume/drivers/glusterfs.py
cinder/volume/drivers/nfs.py
cinder/volume/drivers/remotefs.py
cinder/volume/drivers/san/san.py

index 28dbecb6123f165d7898cb629d177366500bb7c0..b0043f7a3b854feb6133ca19d06447ccaf36a86d 100644 (file)
@@ -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()
index 49101c3de70c00cf9ee87c66d8b81848adb10ae5..075faafaa3d23082c9a0882665cd076de425ec99 100644 (file)
@@ -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):
index 9516901779b7a4eac2177b6fe4e1b78ef69fa1cf..447865555a8fbfcbfee8d09a9c925433d4b30bf6 100644 (file)
@@ -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)
index 7b9b0e4dc2908703203c90f512707c4813a57991..bd9e0fa6e84e348b69cac29a934d64230de836da 100644 (file)
@@ -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
index 9d140aa834be8cb11983877e99f6e7c800c81236..043d770c66471b300fe52073722f49056e57e9b1 100644 (file)
@@ -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.
     """
index 109e9ca9b3a2b3be1dd96d2c30408e60e7695137..f502c4cce0bd32413b207cc5cbd846d0b8af29ba 100644 (file)
@@ -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:
index 3200a669d08e5dbc488afad7321ffd240da8c5ad..a92f81bfd1f9b662509ab7d3566ad763ab868eea 100644 (file)
@@ -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