Esempio n. 1
0
    def acquireHostId(self, hostId, wait):
        self.log.info("Acquiring host id for domain %s (id=%s, wait=%s)",
                      self._sdUUID, hostId, wait)

        # Ensure that future calls to acquire() will wait until host id is
        # acquired.
        self._ready.valid = True

        with self._lock:
            try:
                with utils.stopwatch("sanlock.add_lockspace"):
                    sanlock.add_lockspace(self._lockspace_name,
                                          hostId,
                                          self._idsPath,
                                          wait=wait)
            except sanlock.SanlockException as e:
                if e.errno == errno.EINPROGRESS:
                    # if the request is not asynchronous wait for the ongoing
                    # lockspace operation to complete else silently continue,
                    # the host id has been acquired or it's in the process of
                    # being acquired (async).
                    if wait:
                        if not sanlock.inq_lockspace(self._lockspace_name,
                                                     hostId,
                                                     self._idsPath,
                                                     wait=True):
                            raise se.AcquireHostIdFailure(self._sdUUID, e)
                        self.log.info(
                            "Host id for domain %s successfully "
                            "acquired (id=%s, wait=%s)", self._sdUUID, hostId,
                            wait)
                        self._ready.set()
                elif e.errno == errno.EEXIST:
                    self.log.info(
                        "Host id for domain %s already acquired "
                        "(id=%s, wait=%s)", self._sdUUID, hostId, wait)
                    self._ready.set()
                else:
                    raise se.AcquireHostIdFailure(self._sdUUID, e)
            else:
                if wait:
                    self.log.info(
                        "Host id for domain %s successfully "
                        "acquired (id=%s, wait=%s)", self._sdUUID, hostId,
                        wait)
                    self._ready.set()
Esempio n. 2
0
    def acquireHostId(self, hostId, async):
        with self._lock:
            self.log.info("Acquiring host id for domain %s (id: %s)",
                          self._sdUUID, hostId)

            try:
                sanlock.add_lockspace(self._sdUUID, hostId, self._idsPath,
                                      async=async)
            except sanlock.SanlockException as e:
                if e.errno == errno.EINPROGRESS:
                    # if the request is not asynchronous wait for the ongoing
                    # lockspace operation to complete
                    if not async and not sanlock.inq_lockspace(
                            self._sdUUID, hostId, self._idsPath, wait=True):
                        raise se.AcquireHostIdFailure(self._sdUUID, e)
                    # else silently continue, the host id has been acquired
                    # or it's in the process of being acquired (async)
                elif e.errno != errno.EEXIST:
                    raise se.AcquireHostIdFailure(self._sdUUID, e)
Esempio n. 3
0
    def acquireHostId(self, hostId, wait):
        self.log.info("Acquiring host id for domain %s (id=%s, wait=%s)",
                      self._sdUUID, hostId, wait)

        # Ensure that future calls to acquire() will wait until host id is
        # acquired.
        self._ready.valid = True

        with self._lock:
            try:
                with utils.stopwatch("sanlock.add_lockspace"):
                    sanlock.add_lockspace(self._sdUUID, hostId, self._idsPath,
                                          **{'async': not wait})
            except sanlock.SanlockException as e:
                if e.errno == errno.EINPROGRESS:
                    # if the request is not asynchronous wait for the ongoing
                    # lockspace operation to complete else silently continue,
                    # the host id has been acquired or it's in the process of
                    # being acquired (async).
                    if wait:
                        if not sanlock.inq_lockspace(self._sdUUID, hostId,
                                                     self._idsPath, wait=True):
                            raise se.AcquireHostIdFailure(self._sdUUID, e)
                        self.log.info("Host id for domain %s successfully "
                                      "acquired (id=%s, wait=%s)",
                                      self._sdUUID, hostId, wait)
                        self._ready.set()
                elif e.errno == errno.EEXIST:
                    self.log.info("Host id for domain %s already acquired "
                                  "(id=%s, wait=%s)",
                                  self._sdUUID, hostId, wait)
                    self._ready.set()
                else:
                    raise se.AcquireHostIdFailure(self._sdUUID, e)
            else:
                if wait:
                    self.log.info("Host id for domain %s successfully "
                                  "acquired (id=%s, wait=%s)",
                                  self._sdUUID, hostId, wait)
                    self._ready.set()