]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Storwize/SVC: Use VolumeDriver's copy vol<->image.
authorAvishay Traeger <avishay@il.ibm.com>
Mon, 22 Jul 2013 10:43:29 +0000 (13:43 +0300)
committerAvishay Traeger <avishay@il.ibm.com>
Wed, 24 Jul 2013 20:13:58 +0000 (23:13 +0300)
Inherit the VolumeDriver copy volume<->image functions. This patch also
creates a new SanDriver class which is protocol-agnostic, and leaves
the SanISCSIDriver class for drivers that wish to use it.

Change-Id: Iad5cb030545ef7f4e01d006f1e63cdeeec713bf6

cinder/volume/drivers/san/san.py
cinder/volume/drivers/san/solaris.py
cinder/volume/drivers/storwize_svc.py

index 09ea3e29b5c226cd8b11ba342401bf34575a8ae5..ad532810eba662927c3733df081801d6c4308e17 100644 (file)
@@ -30,7 +30,7 @@ from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
 from cinder import utils
-from cinder.volume.driver import ISCSIDriver
+from cinder.volume import driver
 
 LOG = logging.getLogger(__name__)
 
@@ -76,7 +76,7 @@ CONF = cfg.CONF
 CONF.register_opts(san_opts)
 
 
-class SanISCSIDriver(ISCSIDriver):
+class SanDriver(driver.VolumeDriver):
     """Base class for SAN-style storage volumes
 
     A SAN-style storage value is 'different' because the volume controller
@@ -85,16 +85,14 @@ class SanISCSIDriver(ISCSIDriver):
     """
 
     def __init__(self, *args, **kwargs):
-        super(SanISCSIDriver, self).__init__(*args, **kwargs)
+        execute = kwargs.pop('execute', self.san_execute)
+        super(SanDriver, self).__init__(execute=execute,
+                                        *args, **kwargs)
         self.configuration.append_config_values(san_opts)
         self.run_local = self.configuration.san_is_local
         self.sshpool = None
 
-    def _build_iscsi_target_name(self, volume):
-        return "%s%s" % (self.configuration.iscsi_target_prefix,
-                         volume['name'])
-
-    def _execute(self, *cmd, **kwargs):
+    def san_execute(self, *cmd, **kwargs):
         if self.run_local:
             return utils.execute(*cmd, **kwargs)
         else:
@@ -172,6 +170,11 @@ class SanISCSIDriver(ISCSIDriver):
         if not self.configuration.san_ip:
             raise exception.InvalidInput(reason=_("san_ip must be set"))
 
-    def create_cloned_volume(self, volume, src_vref):
-        """Create a cloen of the specified volume."""
-        raise NotImplementedError()
+
+class SanISCSIDriver(SanDriver, driver.ISCSIDriver):
+    def __init__(self, *args, **kwargs):
+        super(SanISCSIDriver, self).__init__(*args, **kwargs)
+
+    def _build_iscsi_target_name(self, volume):
+        return "%s%s" % (self.configuration.iscsi_target_prefix,
+                         volume['name'])
index 38ab52b4a8dc6d480fdfa786afc27459f2cdcbd0..cc6aa0e4754eaeab0818284dd92943541a13b967 100644 (file)
@@ -57,12 +57,11 @@ class SolarisISCSIDriver(SanISCSIDriver):
     Also make sure you can login using san_login & san_password/san_private_key
     """
     def __init__(self, *cmd, **kwargs):
-        super(SolarisISCSIDriver, self).__init__(*cmd,
-                                                 execute=self._execute,
-                                                 **kwargs)
+        super(SolarisISCSIDriver, self).__init__(execute=self.solaris_execute,
+                                                 *cmd, **kwargs)
         self.configuration.append_config_values(solaris_opts)
 
-    def _execute(self, *cmd, **kwargs):
+    def solaris_execute(self, *cmd, **kwargs):
         new_cmd = ['pfexec']
         new_cmd.extend(cmd)
         return super(SolarisISCSIDriver, self)._execute(*new_cmd,
index c2ed2ebcd89cbe4e4b5f94a39ee28ab568b85c46..efe3b8a3664688974ab55ff90b1a81a4a744fb41 100755 (executable)
@@ -105,7 +105,7 @@ CONF = cfg.CONF
 CONF.register_opts(storwize_svc_opts)
 
 
-class StorwizeSVCDriver(san.SanISCSIDriver):
+class StorwizeSVCDriver(san.SanDriver):
     """IBM Storwize V7000 and SVC iSCSI/FC volume driver.
 
     Version history:
@@ -1326,24 +1326,6 @@ class StorwizeSVCDriver(san.SanISCSIDriver):
                           src_id=src_volume['id'],
                           from_vol=True)
 
-    def copy_image_to_volume(self, context, volume, image_service, image_id):
-        opts = self._get_vdisk_params(volume['volume_type_id'])
-        if opts['protocol'] == 'iSCSI':
-            # Implemented in base iSCSI class
-            return super(StorwizeSVCDriver, self).copy_image_to_volume(
-                context, volume, image_service, image_id)
-        else:
-            raise NotImplementedError()
-
-    def copy_volume_to_image(self, context, volume, image_service, image_meta):
-        opts = self._get_vdisk_params(volume['volume_type_id'])
-        if opts['protocol'] == 'iSCSI':
-            # Implemented in base iSCSI class
-            return super(StorwizeSVCDriver, self).copy_volume_to_image(
-                context, volume, image_service, image_meta)
-        else:
-            raise NotImplementedError()
-
     def extend_volume(self, volume, new_size):
         LOG.debug(_('enter: extend_volume: volume %s') % volume['id'])
         ret = self._ensure_vdisk_no_fc_mappings(volume['name'],