volume = {'id': '114774fb-e15a-4fae-8ee2-c9723e3645ef', 'size': 1,
'volume_name': 'lun1', 'host': 'hostname@backend#DDP',
'os_type': 'linux', 'provider_location': 'lun1',
- 'id': '114774fb-e15a-4fae-8ee2-c9723e3645ef',
+ 'name_id': '114774fb-e15a-4fae-8ee2-c9723e3645ef',
'provider_auth': 'provider a b', 'project_id': 'project',
'display_name': None, 'display_description': 'lun1',
'volume_type_id': None}
volume_sec = {'id': 'b6c01641-8955-4917-a5e3-077147478575',
'size': 2, 'volume_name': 'lun1',
'os_type': 'linux', 'provider_location': 'lun1',
- 'id': 'b6c01641-8955-4917-a5e3-077147478575',
+ 'name_id': 'b6c01641-8955-4917-a5e3-077147478575',
'provider_auth': None, 'project_id': 'project',
'display_name': None, 'display_description': 'lun1',
'volume_type_id': None}
volume_clone = {'id': 'b4b24b27-c716-4647-b66d-8b93ead770a5', 'size': 3,
'volume_name': 'lun1',
'os_type': 'linux', 'provider_location': 'cl_sm',
- 'id': 'b4b24b27-c716-4647-b66d-8b93ead770a5',
+ 'name_id': 'b4b24b27-c716-4647-b66d-8b93ead770a5',
'provider_auth': None,
'project_id': 'project', 'display_name': None,
'display_description': 'lun1',
volume_clone_large = {'id': 'f6ef5bf5-e24f-4cbb-b4c4-11d631d6e553',
'size': 6, 'volume_name': 'lun1',
'os_type': 'linux', 'provider_location': 'cl_lg',
- 'id': 'f6ef5bf5-e24f-4cbb-b4c4-11d631d6e553',
+ 'name_id': 'f6ef5bf5-e24f-4cbb-b4c4-11d631d6e553',
'provider_auth': None,
'project_id': 'project', 'display_name': None,
'display_description': 'lun1',
self.driver.delete_volume(self.volume)
def test_create_vol_snapshot_destroy(self):
+ self.driver.db = mock.Mock(
+ volume_get=mock.Mock(return_value=self.volume))
self.driver.create_volume(self.volume)
self.driver.create_snapshot(self.snapshot)
self.driver.create_volume_from_snapshot(self.volume_sec, self.snapshot)
self.driver.delete_snapshot(self.snapshot)
self.driver.delete_volume(self.volume)
+ self.assertEqual(1, self.driver.db.volume_get.call_count)
def test_map_unmap(self):
self.driver.create_volume(self.volume)
self.driver.delete_volume(self.volume)
def test_cloned_volume_destroy(self):
+ self.driver.db = mock.Mock(
+ volume_get=mock.Mock(return_value=self.volume))
self.driver.create_volume(self.volume)
- self.driver.create_cloned_volume(self.snapshot, self.volume)
+ self.driver.create_cloned_volume(self.volume_sec, self.volume)
+ self.assertEqual(1, self.driver.db.volume_get.call_count)
self.driver.delete_volume(self.volume)
def test_map_by_creating_host(self):
self.driver.get_volume_stats(refresh=True)
def test_create_vol_snapshot_diff_size_resize(self):
+ self.driver.db = mock.Mock(
+ volume_get=mock.Mock(return_value=self.volume))
self.driver.create_volume(self.volume)
self.driver.create_snapshot(self.snapshot)
self.driver.create_volume_from_snapshot(
self.volume_clone, self.snapshot)
+ self.assertEqual(1, self.driver.db.volume_get.call_count)
self.driver.delete_snapshot(self.snapshot)
self.driver.delete_volume(self.volume)
def test_create_vol_snapshot_diff_size_subclone(self):
+ self.driver.db = mock.Mock(
+ volume_get=mock.Mock(return_value=self.volume))
self.driver.create_volume(self.volume)
self.driver.create_snapshot(self.snapshot)
self.driver.create_volume_from_snapshot(
self.volume_clone_large, self.snapshot)
self.driver.delete_snapshot(self.snapshot)
+ self.assertEqual(1, self.driver.db.volume_get.call_count)
self.driver.delete_volume(self.volume)
@mock.patch.object(iscsi.NetAppEseriesISCSIDriver, '_get_volume',
def test_get_pool(self):
self.driver._objects['pools'] = [{'volumeGroupRef': 'fake_ref',
'label': 'ddp1'}]
- pool = self.driver.get_pool({'id': 'fake-uuid'})
+ pool = self.driver.get_pool({'name_id': 'fake-uuid'})
self.assertEqual(pool, 'ddp1')
@mock.patch.object(iscsi.NetAppEseriesISCSIDriver, '_get_volume',
mock.Mock(return_value={'volumeGroupRef': 'fake_ref'}))
def test_get_pool_no_pools(self):
self.driver._objects['pools'] = []
- pool = self.driver.get_pool({'id': 'fake-uuid'})
+ pool = self.driver.get_pool({'name_id': 'fake-uuid'})
self.assertEqual(pool, None)
@mock.patch.object(iscsi.NetAppEseriesISCSIDriver, '_get_volume',
def test_get_pool_no_match(self):
self.driver._objects['pools'] = [{'volumeGroupRef': 'fake_ref2',
'label': 'ddp2'}]
- pool = self.driver.get_pool({'id': 'fake-uuid'})
+ pool = self.driver.get_pool({'name_id': 'fake-uuid'})
self.assertEqual(pool, None)
@mock.patch.object(iscsi.NetAppEseriesISCSIDriver, '_create_volume',
def do_setup(self, context):
"""Any initialization the volume driver does while starting."""
+ self.context = context
na_utils.check_flags(self.REQUIRED_FLAGS, self.configuration)
port = self.configuration.netapp_server_port
if vol.get('label') == label:
self._cache_volume(vol)
return self._get_cached_volume(label)
- raise exception.NetAppDriverException(_("Volume %s not found."), uid)
+ raise exception.NetAppDriverException(_("Volume %(uid)s not found.")
+ % {'uid': uid})
def _get_cached_volume(self, label):
vol_id = self._objects['volumes']['label_ref'][label]
:param volume: The volume hosted by the driver.
:return: Name of the pool where given volume is hosted.
"""
- eseries_volume = self._get_volume(volume['id'])
+ eseries_volume = self._get_volume(volume['name_id'])
for pool in self._objects['pools']:
if pool['volumeGroupRef'] == eseries_volume['volumeGroupRef']:
return pool['label']
msg = _("Pool is not available in the volume host field.")
raise exception.InvalidHost(reason=msg)
- eseries_volume_label = utils.convert_uuid_to_es_fmt(volume['id'])
+ eseries_volume_label = utils.convert_uuid_to_es_fmt(volume['name_id'])
# get size of the requested volume creation
size_gb = int(volume['size'])
def delete_volume(self, volume):
"""Deletes a volume."""
try:
- vol = self._get_volume(volume['id'])
+ vol = self._get_volume(volume['name_id'])
self._delete_volume(vol['label'])
except KeyError:
LOG.info(_LI("Volume %s already deleted."), volume['id'])
"""Creates a snapshot."""
snap_grp, snap_image = None, None
snapshot_name = utils.convert_uuid_to_es_fmt(snapshot['id'])
- vol = self._get_volume(snapshot['volume_id'])
+ os_vol = self.db.volume_get(self.context, snapshot['volume_id'])
+ vol = self._get_volume(os_vol['name_id'])
vol_size_gb = int(vol['totalSizeInBytes']) / units.Gi
pools = self._get_sorted_avl_storage_pools(vol_size_gb)
try:
def initialize_connection(self, volume, connector):
"""Allow connection to connector and return connection info."""
initiator_name = connector['initiator']
- vol = self._get_latest_volume(volume['id'])
+ vol = self._get_latest_volume(volume['name_id'])
iscsi_details = self._get_iscsi_service_details()
iscsi_det = self._get_iscsi_portal_for_vol(vol, iscsi_details)
mapping = self._map_volume_to_host(vol, initiator_name)
def terminate_connection(self, volume, connector, **kwargs):
"""Disallow connection from connector."""
- vol = self._get_volume(volume['id'])
+ vol = self._get_volume(volume['name_id'])
host = self._get_host_with_port(connector['initiator'])
mapping = self._get_cached_vol_mapping_for_host(vol, host)
self._client.delete_volume_mapping(mapping['lunMappingRef'])
def extend_volume(self, volume, new_size):
"""Extend an existing volume to the new size."""
stage_1, stage_2 = 0, 0
- src_vol = self._get_volume(volume['id'])
+ src_vol = self._get_volume(volume['name_id'])
src_label = src_vol['label']
stage_label = 'tmp-%s' % utils.convert_uuid_to_es_fmt(uuid.uuid4())
extend_vol = {'id': uuid.uuid4(), 'size': new_size}