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
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)
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)
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()
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()
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
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]
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]
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]
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()
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()
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
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(
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()
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
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)
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):