Ejemplo n.º 1
0
    def _run_profile(self, profile):
        process = profile.get_process(self.hook)
        if not process:
            self.logger.debug("%s process skipped." % self.hook.capitalize())
            return

        self.logger.debug("Running profile '%s'...", profile.name)
        protocol = Protocol(profile.name)
        # run the configured checks
        for name, config, interp in process.checks:
            self.logger.debug("Loading check %s...", name)
            check = self.checks.fetch(name, self.transaction)
            self.logger.debug("Starting check %s...", name)
            entry = check.run(config, interp)
            self.logger.debug("Check %s finished with %s.", name, entry.result)
            protocol.append(entry)

            # run the configured handlers when a message was returned
            if entry.msg:
                self.logger.debug("Running handler after check %s...",
                                  entry.check)
                self.handlers.singularize(self.transaction, process, entry)
                self.logger.debug("Handler after check %s finished.",
                                  entry.check)

            # cancel the _process chain when an abortonerror was detected.
            if interp == constants.ABORTONERROR and not protocol.success:
                msg = "Profile %s aborted after check %s."
                self.logger.debug(msg, profile.name, entry.check)
                break

        # cumulativ execution of all handlers.
        self.logger.debug("Running handler summarize...")
        self.handlers.summarize(self.transaction, process, protocol)
        self.logger.debug("Handler summarize finished.")

        if not protocol.success:
            self.result = constants.ERROR
        self.logger.debug("Profile %s finished.", profile.name)
Ejemplo n.º 2
0
 def setup_method(self, _):
     self._protocol = Protocol("test")
     self._entry = ProtocolEntry("dummy", dict(), constants.SUCCESS, "dummy")
     self._protocol.append(self._entry)