NEC driver: fix a snapshot detach error
In NEC driver, _fc_terminate_connection() refers to Volume.volume_attachment of an argument. However, the argument is a snapshot object when a snapshot is being detached. The snapshot object does not have the "volume_attachment" attribute. This patch avoids referring to the "volume_attachment" attribute when the argument is a snapshot. Change-Id: Ibc5fa0901ae9c0766f98d623357bade266598bff Closes-Bug: #1887885
This commit is contained in:
parent
be4a682890
commit
6e8dd2f0c0
@ -1284,8 +1284,12 @@ class NonDisruptiveBackup_test(volume_helper.MStorageDSVDriver,
|
||||
attachment = volume_attachment.VolumeAttachmentList(
|
||||
objects=[attach_object])
|
||||
snap.volume_attachment = attachment
|
||||
ret = self.fc_terminate_connection_snapshot(snap, connector)
|
||||
mocker = self.mock_object(self, '_is_multi_attachment',
|
||||
mock.Mock(wraps=self._is_multi_attachment))
|
||||
ret = self.fc_terminate_connection_snapshot(snap, connector,
|
||||
is_snapshot=True)
|
||||
self.assertEqual('fibre_channel', ret['driver_volume_type'])
|
||||
mocker.assert_not_called()
|
||||
|
||||
def test_remove_export_snapshot(self):
|
||||
snap = DummySnapshot('46045673-41e7-44a7-9333-02f07feab04b')
|
||||
|
@ -24,6 +24,7 @@ from oslo_utils import units
|
||||
from cinder import coordination
|
||||
from cinder import exception
|
||||
from cinder.i18n import _
|
||||
from cinder import utils
|
||||
from cinder.volume.drivers.nec import cli
|
||||
from cinder.volume.drivers.nec import volume_common
|
||||
from cinder.volume import volume_utils
|
||||
@ -1325,14 +1326,12 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
||||
'(%(msgparm)s) (%(exception)s)',
|
||||
{'msgparm': msgparm, 'exception': e})
|
||||
|
||||
def _fc_terminate_connection(self, volume, connector):
|
||||
@utils.trace
|
||||
def _fc_terminate_connection(self, vol_or_snap, connector,
|
||||
is_snapshot=False):
|
||||
"""Disallow connection from connector."""
|
||||
LOG.debug('_fc_terminate_connection'
|
||||
'(Volume ID = %(id)s, connector = %(connector)s) Start.',
|
||||
{'id': volume.id, 'connector': connector})
|
||||
|
||||
if connector is not None and (
|
||||
self._is_multi_attachment(volume, connector)):
|
||||
if not is_snapshot and connector is not None and (
|
||||
self._is_multi_attachment(vol_or_snap, connector)):
|
||||
return
|
||||
|
||||
xml = self._cli.view_all(self._properties['ismview_path'])
|
||||
@ -1354,10 +1353,15 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
||||
info['data'] = {'target_wwn': target_wwns,
|
||||
'initiator_target_map': init_targ_map}
|
||||
|
||||
if is_snapshot:
|
||||
# Detaching the snapshot is performed in the
|
||||
# remove_export_snapshot.
|
||||
return info
|
||||
|
||||
if connector is not None and self._properties['ldset_name'] == '':
|
||||
# delete LD from LD set.
|
||||
ldname = self.get_ldname(
|
||||
volume.id, self._properties['ld_name_format'])
|
||||
vol_or_snap.id, self._properties['ld_name_format'])
|
||||
if ldname not in lds:
|
||||
LOG.debug('Logical Disk `%s` has unbound already.', ldname)
|
||||
return info
|
||||
@ -1374,19 +1378,14 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
||||
'Logical Disk Set (%s)') % errnum)
|
||||
raise exception.VolumeBackendAPIException(data=msg)
|
||||
|
||||
LOG.debug('_fc_terminate_connection'
|
||||
'(Volume ID = %(id)s, connector = %(connector)s, '
|
||||
'info = %(info)s) End.',
|
||||
{'id': volume.id,
|
||||
'connector': connector,
|
||||
'info': info})
|
||||
return info
|
||||
|
||||
def fc_terminate_connection_snapshot(self, snapshot, connector, **kwargs):
|
||||
msgparm = ('Volume ID = %(id)s, Connector = %(connector)s'
|
||||
% {'id': snapshot.id, 'connector': connector})
|
||||
try:
|
||||
ret = self._fc_terminate_connection(snapshot, connector)
|
||||
ret = self._fc_terminate_connection(snapshot, connector,
|
||||
is_snapshot=True)
|
||||
LOG.info('Terminated FC Connection snapshot(%s)', msgparm)
|
||||
self.remove_export_snapshot(None, snapshot)
|
||||
return ret
|
||||
|
@ -357,7 +357,7 @@ driver.lenovo=missing
|
||||
driver.linbit_linstor=missing
|
||||
driver.lvm=missing
|
||||
driver.macrosan=missing
|
||||
driver.nec=missing
|
||||
driver.nec=complete
|
||||
driver.netapp_ontap=missing
|
||||
driver.netapp_solidfire=missing
|
||||
driver.nexenta=missing
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
`Bug #1887885 <https://bugs.launchpad.net/cinder/+bug/1887885>`_:
|
||||
In NEC driver, fix a snapshot detach error.
|
||||
|
Loading…
Reference in New Issue
Block a user