Change in vdsm[master]: sp: Move spm validation methods to StoragePool

nsoffer at redhat.com nsoffer at redhat.com
Mon Jul 13 16:29:46 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: sp: Move spm validation methods to StoragePool
......................................................................

sp: Move spm validation methods to StoragePool

These helpers were defined in hsm, but they check the pool internal
state and constants, which hsm should not be involved with. This will
allow using a new StoragePool that does not have an spmRole, needed for
the new SDM mode.

Change-Id: I115896cc67634741d7227fc00d8b294b3fe48ac6
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
2 files changed, 16 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/42/43542/1

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 1b9de05..7b3bed9 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -310,16 +310,6 @@
         except se.StorageDomainDoesNotExist:
             pass
 
-    def validateSPM(self, spUUID):
-        pool = self.getPool(spUUID)
-        if pool.spmRole != sp.SPM_ACQUIRED:
-            raise se.SpmStatusError(spUUID)
-
-    def validateNotSPM(self, spUUID):
-        pool = self.getPool(spUUID)
-        if pool.spmRole != sp.SPM_FREE:
-            raise se.IsSpm(spUUID)
-
     @classmethod
     def getPool(cls, spUUID):
         if spUUID not in cls.pools:
@@ -561,15 +551,14 @@
 
         # This code is repeated twice for performance reasons
         # Avoid waiting for the lock for validate.
-        self.getPool(spUUID)
-        self.validateNotSPM(spUUID)
+        self.getPool(spUUID).validateNotSPM()
 
         vars.task.getExclusiveLock(STORAGE, spUUID)
         pool = self.getPool(spUUID)
         # We should actually just return true if we are SPM after lock,
         # but seeing as it would break the API with Engine,
         # it's easiest to fail.
-        self.validateNotSPM(spUUID)
+        pool.validateNotSPM()
         self._hsmSchedule("spmStart", pool.startSpm, prevID, prevLVER,
                           maxHostID, domVersion)
 
@@ -865,8 +854,8 @@
                 pool.hsmMailer.sendExtendMsg(volDict, newSize, callbackFunc)
 
     def _spmSchedule(self, spUUID, name, func, *args):
-        self.validateSPM(spUUID)
         pool = self.getPool(spUUID)
+        pool.validateSPM()
         self.taskMng.scheduleJob("spm", pool.tasksDir, vars.task,
                                  name, func, *args)
 
@@ -904,7 +893,7 @@
             # should not be issued (and executed) on the SPM. At the
             # moment we just ignore it for legacy reasons but in the
             # future vdsm could raise an exception.
-            self.validateNotSPM(spUUID)
+            self.getPool(spUUID).validateNotSPM()
         except se.IsSpm:
             self.log.info("Ignoring the refreshStoragePool request "
                           "(the host is the SPM)")
@@ -1135,7 +1124,7 @@
                              spUUID, self.pools)
             return
 
-        self.validateNotSPM(spUUID)
+        self.getPool(spUUID).validateNotSPM()
 
         vars.task.getExclusiveLock(STORAGE, spUUID)
         pool = self.getPool(spUUID)
@@ -1143,7 +1132,7 @@
         return self._disconnectPool(pool, hostID, remove)
 
     def _disconnectPool(self, pool, hostID, remove):
-        self.validateNotSPM(pool.spUUID)
+        pool.validateNotSPM()
         with rmanager.acquireResource(STORAGE, HSM_DOM_MON_LOCK,
                                       rm.LockType.exclusive):
             res = pool.disconnect()
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 9166f60..4a8b67c 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -111,6 +111,16 @@
         return self._backend.getSpmStatus()
 
     @unsecured
+    def validateSPM(self):
+        if self.spmRole != SPM_ACQUIRED:
+            raise se.SpmStatusError(self.spUUID)
+
+    @unsecured
+    def validateNotSPM(self):
+        if self.spmRole != SPM_FREE:
+            raise se.IsSpm(self.spUUID)
+
+    @unsecured
     def setBackend(self, backend):
         self.log.info('updating pool %s backend from type %s instance 0x%x '
                       'to type %s instance 0x%x', self.spUUID,


-- 
To view, visit https://gerrit.ovirt.org/43542
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I115896cc67634741d7227fc00d8b294b3fe48ac6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list