Federico Simoncelli has uploaded a new change for review. Change subject: sd: [wip] add getClusterLockOwnerId method ......................................................................
sd: [wip] add getClusterLockOwnerId method Change-Id: I10e64d74319ea6591a7edf8e17809d367a758386 Signed-off-by: Federico Simoncelli <fsimo...@redhat.com> --- M vdsm/storage/clusterlock.py M vdsm/storage/sd.py 2 files changed, 27 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/21426/1 diff --git a/vdsm/storage/clusterlock.py b/vdsm/storage/clusterlock.py index 6e4d8d6..d0da854 100644 --- a/vdsm/storage/clusterlock.py +++ b/vdsm/storage/clusterlock.py @@ -112,6 +112,9 @@ raise se.AcquireLockFailure(self._sdUUID, rc, out, err) self.log.debug("Clustered lock acquired successfully") + def getOwnerId(self): + pass # FIXME: missing implementation + def getLockUtilFullPath(self): return os.path.join(self.lockUtilPath, self.lockCmd) @@ -167,6 +170,9 @@ def getReservedId(self): return MAX_HOST_ID + + def getLockDisk(self): + return [(self._leasesPath, SDM_LEASE_OFFSET)] def acquireHostId(self, hostId, async): with self._lock: @@ -235,7 +241,7 @@ try: sanlock.acquire(self._sdUUID, SDM_LEASE_NAME, - [(self._leasesPath, SDM_LEASE_OFFSET)], + self.getLockDisk(), slkfd=SANLock._sanlock_fd) except sanlock.SanlockException as e: if e.errno != os.errno.EPIPE: @@ -250,14 +256,26 @@ self.log.debug("Cluster lock for domain %s successfully acquired " "(id: %s)", self._sdUUID, hostId) + def getOwnerId(self): + owners = sanlock.read_resource_owners( + self._sdUUID, SDM_LEASE_NAME, self.getLockDisk()) + + if len(owners) == 1: + return owners[0].get("host_id") + elif len(owners) > 1: + self.log.error("Cluster lock is reported to have more than " + "one owner: %s", owners) + raise RuntimeError("Cluster lock multiple owners error") + + return None + def release(self): with self._lock: self.log.info("Releasing cluster lock for domain %s", self._sdUUID) try: sanlock.release(self._sdUUID, SDM_LEASE_NAME, - [(self._leasesPath, SDM_LEASE_OFFSET)], - slkfd=SANLock._sanlock_fd) + self.getLockDisk(), slkfd=SANLock._sanlock_fd) except sanlock.SanlockException as e: raise se.ReleaseLockFailure(self._sdUUID, e) @@ -345,6 +363,9 @@ self.log.debug("Local lock for domain %s successfully acquired " "(id: %s)", self._sdUUID, hostId) + def getOwnerId(self): + pass # FIXME: missing implementation + def release(self): with self._globalLockMapSync: self.log.info("Releasing local lock for domain %s", self._sdUUID) diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py index 3249343..03d3274 100644 --- a/vdsm/storage/sd.py +++ b/vdsm/storage/sd.py @@ -489,6 +489,9 @@ def releaseClusterLock(self): self._clusterLock.release() + def getClusterLockOwnerId(self): + self._clusterLock.getOwnerId() + def attach(self, spUUID): self.invalidateMetadata() pools = self.getPools() -- To view, visit http://gerrit.ovirt.org/21426 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I10e64d74319ea6591a7edf8e17809d367a758386 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli <fsimo...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches