Beispiel #1
0
    def poweron(self):
        if self.proc is not None:
            return defer.succeed(self)

        if not self.configured():
            return defer.fail(
                errors.BadConfigError(
                    _("Cannot start '%s': not configured") % self.name))
        if not self._properly_connected():
            return defer.fail(
                errors.NotConnectedError(
                    _("Cannot start '%s': not connected") % self.name))

        self._started_d = started = defer.Deferred()
        self._exited_d = defer.Deferred()
        d = self._check_links()
        d.addCallback(self._poweron)

        def start_related_events(_):
            self._start_related_events(on=True)
            return self

        d.addCallback(start_related_events)

        def eb(failure):
            if failure.check(defer.FirstError):
                failure = failure.value.subFailure
            started.errback(failure)

        # here self._started_d could be None because if child process is
        # created before reaching this point, process_stated is already called
        # and then self._started_d is unset
        d.addErrback(eb)
        return started
 def poweron(self):
     if self.proc is not None:
         return defer.succeed(self)
     elif os.path.exists(self.config["path"]):
         self.proc = bricks.FakeProcess(self)
         return defer.succeed(self)
     else:
         self.logger.debug(sock_not_exists, path=self.config["path"])
         msg = _("Socket does not exists: %s") % self.config["path"]
         return defer.fail(errors.BadConfigError(msg))
Beispiel #3
0
    def poweron(self):
        if self.scheduled:
            return
        if not self.configured():
            raise errors.BadConfigError("Event %s not configured" % self.name)

        deferred = defer.Deferred()
        self.scheduled = reactor.callLater(self.config["delay"],
                                           self.do_actions, deferred)
        self.notify_changed()
        return deferred
    def _create_cow(self, cowname):
        if abspath_qemu('qemu-img', return_relative=False) is None:
            msg = _("qemu-img not found! I can't create a new image.")
            return defer.fail(errors.BadConfigError(msg))

        logger.info(new_cow, base=self._get_base())
        args = ["create", "-b", self._get_base(), "-f",
                settings.get("cowfmt"), cowname]
        exit = getQemuOutputAndValue("qemu-img", args, os.environ)
        exit.addCallback(self._sync)
        exit.addCallback(lambda _: cowname)
        return exit