]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Clean up QTree when deleting volume on NetApp storage box.
authorRushi Agrawal <rushi.agr@gmail.com>
Tue, 22 Jan 2013 00:58:58 +0000 (06:28 +0530)
committerRushi Agrawal <rushi.agr@gmail.com>
Tue, 22 Jan 2013 01:09:39 +0000 (06:39 +0530)
Previously, deleting a Cinder volume would leave a QTree on NetApp
storage box. This commit fixes the issue.

Fixes bug 1099414

Change-Id: I95f1d6b802f4abfad421d34f1c000b75fb72c41e

cinder/tests/test_netapp.py
cinder/volume/drivers/netapp.py

index 21b39e4f3d6ad46f8b235c499cc4e52a44047dc2..72ba362f782b2cc13b2affb3123d60a51b653c15 100644 (file)
@@ -498,6 +498,7 @@ WSDL_TYPES = """<types>
     <xsd:all>
         <xsd:element name="HostId" type="na:ObjId"/>
         <xsd:element name="LunPath" type="na:ObjName"/>
+        <xsd:element name="QtreeId" type="na:ObjName"/>
     </xsd:all>
 </xsd:complexType>
 <xsd:simpleType name="ObjId">
@@ -812,6 +813,7 @@ class FakeDfmServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
                         <na:LunInfo>
                             <na:HostId>0</na:HostId>
                             <na:LunPath>%s</na:LunPath>
+                            <na:QtreeId>volume-00000001</na:QtreeId>
                         </na:LunInfo>
                     </na:Luns>
                     <na:Records>1</na:Records>
index 3ce77c5c2191580d6cda6abf4bc50345221f7160..032ad5f503766c8bb4c58ccffb30509c520e6f05 100644 (file)
@@ -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):