Exemplo n.º 1
0
    def startMonitoring(self, sdUUID, hostId, poolDomain=True):
        with self._lock:
            if self._shutting_down:
                raise se.ShuttingDownError()

            monitor = self._monitors.get(sdUUID)

            # TODO: Replace with explicit attach.
            if monitor is not None:
                if not poolDomain:
                    # Expected when hosted engine agent is restarting.
                    log.debug("Monitor for %s is already running", sdUUID)
                    return

                if monitor.poolDomain:
                    log.warning("Monitor for %s is already attached to pool",
                                sdUUID)
                    return

                # An external storage domain attached to the pool.
                # From this point, the storage domain is managed by Vdsm.
                # Expected during Vdsm startup when using hosted engine.
                log.info("Attaching monitor for %s to the pool", sdUUID)
                monitor.poolDomain = True
                return

            log.info("Start monitoring %s", sdUUID)
            monitor = MonitorThread(sdUUID, hostId, self._interval,
                                    self.onDomainStateChange, self._checker)
            monitor.poolDomain = poolDomain
            monitor.start()
            # The domain should be added only after it successfully started.
            self._monitors[sdUUID] = monitor
Exemplo n.º 2
0
    def stopMonitoring(self, sdUUIDs):
        with self._lock:
            if self._shutting_down:
                raise se.ShuttingDownError()

            sdUUIDs = frozenset(sdUUIDs)
            monitors = [
                monitor for monitor in self._monitors.values()
                if monitor.sdUUID in sdUUIDs
            ]

        self._stopMonitors(monitors)
Exemplo n.º 3
0
    def shutdown(self):
        """
        Called during shutdown to stop all monitors without releasing the host
        id. To stop monitors and release the host id, use stopMonitoring().
        """
        log.info("Shutting down domain monitors")
        with self._lock:
            if self._shutting_down:
                raise se.ShuttingDownError()

            # Set the shutdown flag to prevent new calls for stop or start
            # monitoring which would modify the monitor dicts. We don't
            # want to hold the lock itself during entire shutdown not to hang
            # other operations as it can take a while.
            self._shutting_down = True

        self._stopMonitors(list(self._monitors.values()), shutdown=True)
        self._checker.stop()