From: Rushi Agrawal Date: Tue, 22 Jan 2013 00:58:58 +0000 (+0530) Subject: Clean up QTree when deleting volume on NetApp storage box. X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=31adf9abc57225fddd0f6d956f271f24bb8f576c;p=openstack-build%2Fcinder-build.git Clean up QTree when deleting volume on NetApp storage box. Previously, deleting a Cinder volume would leave a QTree on NetApp storage box. This commit fixes the issue. Fixes bug 1099414 Change-Id: I95f1d6b802f4abfad421d34f1c000b75fb72c41e --- diff --git a/cinder/tests/test_netapp.py b/cinder/tests/test_netapp.py index 21b39e4f3..72ba362f7 100644 --- a/cinder/tests/test_netapp.py +++ b/cinder/tests/test_netapp.py @@ -498,6 +498,7 @@ WSDL_TYPES = """ + @@ -812,6 +813,7 @@ class FakeDfmServerHandler(BaseHTTPServer.BaseHTTPRequestHandler): 0 %s + volume-00000001 1 diff --git a/cinder/volume/drivers/netapp.py b/cinder/volume/drivers/netapp.py index 3ce77c5c2..032ad5f50 100644 --- a/cinder/volume/drivers/netapp.py +++ b/cinder/volume/drivers/netapp.py @@ -433,10 +433,11 @@ class NetAppISCSIDriver(driver.ISCSIDriver): def _remove_destroy(self, name, project): """Remove the LUN from the dataset, also destroying it. - Remove the LUN from the dataset and destroy the actual LUN on the - storage system. + Remove the LUN from the dataset and destroy the actual LUN and Qtree + on the storage system. """ lun = self._lookup_lun_for_volume(name, project) + lun_details = self._get_lun_details(lun.id) member = self.client.factory.create('DatasetMemberParameter') member.ObjectNameOrId = lun.id members = self.client.factory.create('ArrayOfDatasetMemberParameter') @@ -444,6 +445,22 @@ class NetAppISCSIDriver(driver.ISCSIDriver): server = self.client.service lock_id = server.DatasetEditBegin(DatasetNameOrId=lun.dataset.id) + try: + server.DatasetRemoveMember(EditLockId=lock_id, Destroy=True, + DatasetMemberParameters=members) + res = server.DatasetEditCommit(EditLockId=lock_id, + AssumeConfirmation=True) + except (suds.WebFault, Exception): + server.DatasetEditRollback(EditLockId=lock_id) + msg = _('Failed to remove and delete dataset LUN member') + raise exception.VolumeBackendAPIException(data=msg) + + for info in res.JobIds.JobInfo: + self._wait_for_job(info.JobId) + + # Note: it's not possible to delete Qtree & his LUN in one transaction + member.ObjectNameOrId = lun_details.QtreeId + lock_id = server.DatasetEditBegin(DatasetNameOrId=lun.dataset.id) try: server.DatasetRemoveMember(EditLockId=lock_id, Destroy=True, DatasetMemberParameters=members) @@ -451,7 +468,7 @@ class NetAppISCSIDriver(driver.ISCSIDriver): AssumeConfirmation=True) except (suds.WebFault, Exception): server.DatasetEditRollback(EditLockId=lock_id) - msg = _('Failed to remove and delete dataset member') + msg = _('Failed to remove and delete dataset Qtree member') raise exception.VolumeBackendAPIException(data=msg) def create_volume(self, volume):