]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Updated violin driver check for volume objects
authorRyan Lucio <rlucio@vmem.com>
Wed, 18 Nov 2015 00:08:42 +0000 (16:08 -0800)
committerRyan Lucio <rlucio@vmem.com>
Mon, 30 Nov 2015 23:22:45 +0000 (15:22 -0800)
Fixed bug where both vmem 6000 drivers were trying to export luns as
snapshots when using the base volume driver's copy_volume_data()
function.

Bug was observed during recent CI runs.

Change-Id: I254102f4d3f8a80bf7801b677e7fe6199bc723a2
Closes-Bug: 1517240

cinder/tests/unit/test_v6000_fcp.py
cinder/tests/unit/test_v6000_iscsi.py
cinder/volume/drivers/violin/v6000_fcp.py
cinder/volume/drivers/violin/v6000_iscsi.py

index 280df3d933025fb46aa8f59b47f0d3f91d1a8859..190aecb867806d0e4edcc9b417fcf8ae96bf2958 100644 (file)
@@ -21,8 +21,9 @@ import mock
 from oslo_utils import units
 
 from cinder import context
-from cinder.db.sqlalchemy import models
 from cinder import exception
+from cinder.objects import snapshot as csnap
+from cinder.objects import volume as cvol
 from cinder import test
 from cinder.tests.unit import fake_vmem_client as vmemclient
 from cinder.volume import configuration as conf
@@ -210,7 +211,7 @@ class V6000FCPDriverTestCase(test.TestCase):
         igroup = None
         target_wwns = self.driver.gateway_fc_wwns
         init_targ_map = {}
-        volume = mock.Mock(spec=models.Volume)
+        volume = mock.Mock(spec=cvol.Volume)
 
         self.driver.common.vip = self.setup_mock_vshare()
         self.driver._export_lun = mock.Mock(return_value=lun_id)
@@ -234,7 +235,7 @@ class V6000FCPDriverTestCase(test.TestCase):
         igroup = None
         target_wwns = self.driver.gateway_fc_wwns
         init_targ_map = {}
-        snapshot = mock.Mock(spec=models.Snapshot)
+        snapshot = mock.Mock(spec=csnap.Snapshot)
 
         self.driver.common.vip = self.setup_mock_vshare()
         self.driver._export_snapshot = mock.Mock(return_value=lun_id)
@@ -257,7 +258,7 @@ class V6000FCPDriverTestCase(test.TestCase):
     def test_terminate_connection(self):
         target_wwns = self.driver.gateway_fc_wwns
         init_targ_map = {}
-        volume = mock.Mock(spec=models.Volume)
+        volume = mock.Mock(spec=cvol.Volume)
 
         self.driver.common.vip = self.setup_mock_vshare()
         self.driver._unexport_lun = mock.Mock()
@@ -281,7 +282,7 @@ class V6000FCPDriverTestCase(test.TestCase):
     def test_terminate_connection_snapshot_object(self):
         target_wwns = self.driver.gateway_fc_wwns
         init_targ_map = {}
-        snapshot = mock.Mock(spec=models.Snapshot)
+        snapshot = mock.Mock(spec=csnap.Snapshot)
 
         self.driver.common.vip = self.setup_mock_vshare()
         self.driver._unexport_snapshot = mock.Mock()
index ae5841392171ff5b6c9e488caeaa42ef76f2f996..d12dd76d4c63931194cefbd9a07a0309c3c75219 100644 (file)
@@ -21,8 +21,9 @@ import mock
 from oslo_utils import units
 
 from cinder import context
-from cinder.db.sqlalchemy import models
 from cinder import exception
+from cinder.objects import snapshot as csnap
+from cinder.objects import volume as cvol
 from cinder import test
 from cinder.tests.unit import fake_vmem_client as vmemclient
 from cinder.volume import configuration as conf
@@ -244,7 +245,7 @@ class V6000ISCSIDriverTestCase(test.TestCase):
         tgt = self.driver.array_info[0]
         iqn = "%s%s:%s" % (self.conf.iscsi_target_prefix,
                            tgt['node'], target_name)
-        volume = mock.MagicMock(spec=models.Volume)
+        volume = mock.MagicMock(spec=cvol.Volume)
 
         def getitem(name):
             return VOLUME[name]
@@ -273,7 +274,7 @@ class V6000ISCSIDriverTestCase(test.TestCase):
         tgt = self.driver.array_info[0]
         iqn = "%s%s:%s" % (self.conf.iscsi_target_prefix,
                            tgt['node'], target_name)
-        snapshot = mock.MagicMock(spec=models.Snapshot)
+        snapshot = mock.MagicMock(spec=csnap.Snapshot)
 
         def getitem(name):
             return SNAPSHOT[name]
@@ -303,7 +304,7 @@ class V6000ISCSIDriverTestCase(test.TestCase):
         tgt = self.driver.array_info[0]
         iqn = "%s%s:%s" % (self.conf.iscsi_target_prefix,
                            tgt['node'], target_name)
-        volume = mock.MagicMock(spec=models.Volume)
+        volume = mock.MagicMock(spec=cvol.Volume)
 
         def getitem(name):
             return VOLUME[name]
@@ -332,7 +333,7 @@ class V6000ISCSIDriverTestCase(test.TestCase):
         self.assertEqual(volume['id'], props['data']['volume_id'])
 
     def test_terminate_connection(self):
-        volume = mock.MagicMock(spec=models.Volume)
+        volume = mock.MagicMock(spec=cvol.Volume)
 
         self.driver.common.vip = self.setup_mock_vshare()
         self.driver._unexport_lun = mock.Mock()
@@ -344,7 +345,7 @@ class V6000ISCSIDriverTestCase(test.TestCase):
         self.assertTrue(result is None)
 
     def test_terminate_connection_with_snapshot_object(self):
-        snapshot = mock.MagicMock(spec=models.Snapshot)
+        snapshot = mock.MagicMock(spec=csnap.Snapshot)
 
         self.driver.common.vip = self.setup_mock_vshare()
         self.driver._unexport_snapshot = mock.Mock()
index 5054f6c0528d14e8cbf43e25e8ce7049e3b85398..f3adcffb53d8996ff4ebae1984df6285a127ac6f 100644 (file)
@@ -40,7 +40,6 @@ from oslo_utils import units
 from six.moves import range
 
 from cinder import context
-from cinder.db.sqlalchemy import models
 from cinder import exception
 from cinder.i18n import _, _LE, _LI, _LW
 from cinder import utils
@@ -155,10 +154,11 @@ class V6000FCDriver(driver.FibreChannelDriver):
             igroup = self.common._get_igroup(volume, connector)
             self._add_igroup_member(connector, igroup)
 
-        if isinstance(volume, models.Volume):
-            lun_id = self._export_lun(volume, connector, igroup)
-        else:
+        if hasattr(volume, 'volume_id'):
             lun_id = self._export_snapshot(volume, connector, igroup)
+        else:
+            lun_id = self._export_lun(volume, connector, igroup)
+
         self.common.vip.basic.save_config()
 
         target_wwns, init_targ_map = self._build_initiator_target_map(
@@ -179,10 +179,10 @@ class V6000FCDriver(driver.FibreChannelDriver):
     def terminate_connection(self, volume, connector, force=False, **kwargs):
         """Terminates the connection (target<-->initiator)."""
 
-        if isinstance(volume, models.Volume):
-            self._unexport_lun(volume)
-        else:
+        if hasattr(volume, 'volume_id'):
             self._unexport_snapshot(volume)
+        else:
+            self._unexport_lun(volume)
 
         self.common.vip.basic.save_config()
 
index 726d29400016b4bab0ddd61e0f477156df5976d7..2b69d95f9c07a317183112ea87ced8140b10cb07 100644 (file)
@@ -41,7 +41,6 @@ from oslo_service import loopingcall
 from oslo_utils import units
 
 from cinder import context
-from cinder.db.sqlalchemy import models
 from cinder import exception
 from cinder.i18n import _, _LE, _LI, _LW
 from cinder import utils
@@ -183,10 +182,10 @@ class V6000ISCSIDriver(driver.ISCSIDriver):
         tgt = self._get_iscsi_target()
         target_name = self.TARGET_GROUP_NAME
 
-        if isinstance(volume, models.Volume):
-            lun = self._export_lun(volume, connector, igroup)
-        else:
+        if hasattr(volume, 'volume_id'):
             lun = self._export_snapshot(volume, connector, igroup)
+        else:
+            lun = self._export_lun(volume, connector, igroup)
 
         iqn = "%s%s:%s" % (self.configuration.iscsi_target_prefix,
                            tgt['node'], target_name)
@@ -207,10 +206,10 @@ class V6000ISCSIDriver(driver.ISCSIDriver):
 
     def terminate_connection(self, volume, connector, force=False, **kwargs):
         """Terminates the connection (target<-->initiator)."""
-        if isinstance(volume, models.Volume):
-            self._unexport_lun(volume)
-        else:
+        if hasattr(volume, 'volume_id'):
             self._unexport_snapshot(volume)
+        else:
+            self._unexport_lun(volume)
         self.common.vip.basic.save_config()
 
     def get_volume_stats(self, refresh=False):