Maor Lipchuk has uploaded a new change for review.

Change subject: detach: Support force detach on Storage Domains with old pools.
......................................................................

detach: Support force detach on Storage Domains with old pools.

Force detach of storage domain only being supported on storage domains
which are part of pool.  For supporting import Data Storage Domain
feature, we should also support force detach of Storage Domain which are
not connected to any pool.

The force detach will clear the SP_UUID meta data of the imported
Stroage Dimain, when a BLANK_UUID will be passed from the client
and will enable the engine to attach it to other DC in ifferent setups.

Signed-off-by: Maor Lipchuk <[email protected]>
Change-Id: I4a6fb01775f7c834a3466e45b9b7ed9b4bd5c3be
---
M vdsm/storage/hsm.py
M vdsm/storage/sd.py
2 files changed, 35 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/03/29303/1

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 80ecdc6..7769ae7 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -742,6 +742,30 @@
                        in guids)
         pool.extendSD(sdUUID, dmDevs, force)
 
+    def _deatchStorageDomainFromOldPools(self, sdUUID):
+        # We are called with blank pool uuid, to avoid changing exiting
+        # API which we want to drop in next version anyway.
+        # So to get the pool we use the fact that there can be only one
+        # pool, and get the host id from it.
+        if len(self.pools) > 1:
+            raise AssertionError("Multiple pools are not supported")
+        try:
+            pool = self.pools.values()[0]
+        except IndexError:
+            raise se.StoragePoolNotConnected()
+
+        dom = sdCache.produce(sdUUID=sdUUID)
+        dom.acquireHostId(pool.id)
+        try:
+            dom.acquireClusterLock(pool.id)
+            try:
+                for domPoolUUID in dom.getPools():
+                    dom.detach(domPoolUUID)
+            finally:
+                dom.releaseClusterLock()
+        finally:
+            dom.releaseHostId(pool.id)
+
     @public
     def forcedDetachStorageDomain(self, sdUUID, spUUID, options=None):
         """Forced detach a storage domain from a storage pool.
@@ -753,11 +777,15 @@
         vars.task.setDefaultException(
             se.StorageDomainActionError(
                 "sdUUID=%s, spUUID=%s" % (sdUUID, spUUID)))
-        vars.task.getExclusiveLock(STORAGE, spUUID)
-        pool = self.getPool(spUUID)
-        if sdUUID == pool.masterDomain.sdUUID:
-            raise se.CannotDetachMasterStorageDomain(sdUUID)
-        pool.forcedDetachSD(sdUUID)
+
+        if spUUID == sd.BLANK_UUID:
+            self._deatchStorageDomainFromOldPools(sdUUID)
+        else:
+            vars.task.getExclusiveLock(STORAGE, spUUID)
+            pool = self.getPool(spUUID)
+            if sdUUID == pool.masterDomain.sdUUID:
+                raise se.CannotDetachMasterStorageDomain(sdUUID)
+            pool.forcedDetachSD(sdUUID)
 
     @public
     def detachStorageDomain(self, sdUUID, spUUID, msdUUID=None,
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index a868f38..be3cc34 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -525,6 +525,8 @@
         self.setMetaParam(DMDK_POOLS, pools)
 
     def detach(self, spUUID):
+        self.log.info('detaching storage domain %s from pool %s',
+                      self.sdUUID, spUUID)
         self.invalidateMetadata()
         pools = self.getPools()
         try:


-- 
To view, visit http://gerrit.ovirt.org/29303
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a6fb01775f7c834a3466e45b9b7ed9b4bd5c3be
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Maor Lipchuk <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to