Updated violin driver check for volume objects

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
This commit is contained in:
Ryan Lucio 2015-11-17 16:08:42 -08:00
parent 3f9e80986a
commit 19f3fa013f
4 changed files with 26 additions and 25 deletions

View 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()

View 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()

View 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()

View 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):