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 (cherry picked from commit6e8dd2f0c0
) (cherry picked from commit7e98b66a17
)
This commit is contained in:
parent
73ba22632b
commit
39905d5df3
|
@ -1350,8 +1350,12 @@ class NonDisruptiveBackup_test(volume_helper.MStorageDSVDriver,
|
||||||
attachment = volume_attachment.VolumeAttachmentList(
|
attachment = volume_attachment.VolumeAttachmentList(
|
||||||
objects=[attach_object])
|
objects=[attach_object])
|
||||||
snap.volume_attachment = attachment
|
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'])
|
self.assertEqual('fibre_channel', ret['driver_volume_type'])
|
||||||
|
mocker.assert_not_called()
|
||||||
|
|
||||||
def test_remove_export_snapshot(self):
|
def test_remove_export_snapshot(self):
|
||||||
snap = DummySnapshot('46045673-41e7-44a7-9333-02f07feab04b')
|
snap = DummySnapshot('46045673-41e7-44a7-9333-02f07feab04b')
|
||||||
|
|
|
@ -24,6 +24,7 @@ from oslo_utils import units
|
||||||
from cinder import coordination
|
from cinder import coordination
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
|
from cinder import utils
|
||||||
from cinder.volume.drivers.nec import cli
|
from cinder.volume.drivers.nec import cli
|
||||||
from cinder.volume.drivers.nec import volume_common
|
from cinder.volume.drivers.nec import volume_common
|
||||||
from cinder.volume import volume_utils
|
from cinder.volume import volume_utils
|
||||||
|
@ -1324,14 +1325,12 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
||||||
'(%(msgparm)s) (%(exception)s)',
|
'(%(msgparm)s) (%(exception)s)',
|
||||||
{'msgparm': msgparm, 'exception': e})
|
{'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."""
|
"""Disallow connection from connector."""
|
||||||
LOG.debug('_fc_terminate_connection'
|
if not is_snapshot and connector is not None and (
|
||||||
'(Volume ID = %(id)s, connector = %(connector)s) Start.',
|
self._is_multi_attachment(vol_or_snap, connector)):
|
||||||
{'id': volume.id, 'connector': connector})
|
|
||||||
|
|
||||||
if connector is not None and (
|
|
||||||
self._is_multi_attachment(volume, connector)):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
xml = self._cli.view_all(self._properties['ismview_path'])
|
xml = self._cli.view_all(self._properties['ismview_path'])
|
||||||
|
@ -1353,10 +1352,15 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
||||||
info['data'] = {'target_wwn': target_wwns,
|
info['data'] = {'target_wwn': target_wwns,
|
||||||
'initiator_target_map': init_targ_map}
|
'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'] == '':
|
if connector is not None and self._properties['ldset_name'] == '':
|
||||||
# delete LD from LD set.
|
# delete LD from LD set.
|
||||||
ldname = self.get_ldname(
|
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:
|
if ldname not in lds:
|
||||||
LOG.debug('Logical Disk `%s` has unbound already.', ldname)
|
LOG.debug('Logical Disk `%s` has unbound already.', ldname)
|
||||||
return info
|
return info
|
||||||
|
@ -1373,19 +1377,14 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
||||||
'Logical Disk Set (%s)') % errnum)
|
'Logical Disk Set (%s)') % errnum)
|
||||||
raise exception.VolumeBackendAPIException(data=msg)
|
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
|
return info
|
||||||
|
|
||||||
def fc_terminate_connection_snapshot(self, snapshot, connector, **kwargs):
|
def fc_terminate_connection_snapshot(self, snapshot, connector, **kwargs):
|
||||||
msgparm = ('Volume ID = %(id)s, Connector = %(connector)s'
|
msgparm = ('Volume ID = %(id)s, Connector = %(connector)s'
|
||||||
% {'id': snapshot.id, 'connector': connector})
|
% {'id': snapshot.id, 'connector': connector})
|
||||||
try:
|
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)
|
LOG.info('Terminated FC Connection snapshot(%s)', msgparm)
|
||||||
self.remove_export_snapshot(None, snapshot)
|
self.remove_export_snapshot(None, snapshot)
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -374,7 +374,7 @@ driver.lenovo=missing
|
||||||
driver.linbit_linstor=missing
|
driver.linbit_linstor=missing
|
||||||
driver.lvm=missing
|
driver.lvm=missing
|
||||||
driver.macrosan=missing
|
driver.macrosan=missing
|
||||||
driver.nec=missing
|
driver.nec=complete
|
||||||
driver.netapp_ontap=missing
|
driver.netapp_ontap=missing
|
||||||
driver.netapp_solidfire=missing
|
driver.netapp_solidfire=missing
|
||||||
driver.nexenta=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