Пример #1
0
    def run(self, runner):
        """
        The runner that gets passed in contains state that can be
        access via dict-like access.  PreManifest uses this to write
        to the rpm.Premanifest field.  So we'll check to make sure the
        pre-manifest is there by looking for that state.
        """
        try:
            pre_manifest = runner['rpm.PreManifest']
        except:
            return TaskResult(
                self,
                success=False,
                output="You must use PreManifest before PostManifest")

        # ok, so now we have something to compare against so we get
        # new state...
        result = super(command.Run, self).run(runner)

        old_list = pre_manifest.splitlines(1)
        new_list = result.output.splitlines(1)

        differ = self._Differ()
        diff_output = list(differ.compare(old_list, new_list))
        diff_output = [line for line in diff_output if line[0] in ('+', '-')]

        result.output = ''.join(diff_output)

        return result
Пример #2
0
 def run(self, runner):
     import time
     start = time.time()
     tcflush(sys.stdin, TCIFLUSH)
     raw_input(self._message)
     return TaskResult(self, success=True,
                       output="Paused for %s seconds" %
                       (time.time() - start))
Пример #3
0
 def _process_result(self, result):
     t = TaskResult(self)
     if result[0] == 0:
         t.success = True
     else:
         t.success = False
     t.output = result[1]
     return t
Пример #4
0
    def _process_result(self, result):
        t = TaskResult(self)

        if result.startswith("Fail: "):
            t.success = False
        else:
            t.sucess = True
        t.output = result
        return t
Пример #5
0
 def _process_result(self, result):
     t = TaskResult(self)
     t.success = True
     for r in result:
         if r.startswith("Fail: "):
             t.success = t.success & False
         else:
             t.sucess = t.success & True
     t.output = "".join(result)
     return t
Пример #6
0
 def run(self, runner):
     output = ""
     success = True
     for proxy in self.proxies:
         toggler = ToggleHost(self.jkaction, self._host, host=proxy)
         result = toggler.run(runner)
         output += "%s:\n" % proxy
         output += "%s\n" % result.output
         if result.success == False:
             success = False
             break
     return TaskResult(self, success=success, output=output)
Пример #7
0
    def run(self, runner):
        for x in range(self._max_attempts):
            result = runner.run_task(self._task)
            if result.success:
                return result
            time.sleep(self._sleep_interval)

        # exhausted max_attempts
        if self._fail_task != None:
            return runner.run_task(self._fail_task)
        else:
            # return a "failed" TaskResult, stop executing further tasks
            return TaskResult(self,
                              success=False,
                              output="Max attempts of %s reached running %s" %
                              (self._max_attempts, repr(self._task)))
Пример #8
0
    def _process_result(self, result):
        t = TaskResult(self)
        if len(result) > 0:
            t.success = True
            if self._action == JK_ENABLE:
                verb = 'Enabled'
            elif self._action == JK_DISABLE:
                verb = 'Disabled'
            elif self._action == JK_STOP:
                verb = 'Stopped'

            t.output = "%s AJP on the following balancer/worker " \
                "pairs:\n" % verb
            for balancer, worker in result:
                t.output += "%s:  %s\n" % (balancer, worker)
        else:
            t.success = False
            t.output = "Failed to find worker host"
        return t
Пример #9
0
 def run(self, runner):
     import time
     time.sleep(self._seconds)
     return TaskResult(self, success=True,
                       output="Paused for %s minutes" %
                       self._minutes)
Пример #10
0
 def run(self, *args):
     return TaskResult(self, success=True, output=self.input)
Пример #11
0
 def run(self, *args):
     return TaskResult(self, success=True)