Beispiel #1
0
    def run_task(self, task):
        """
        Run a single task.  Sets task.host and then invokes the run
        method for the task.

        :Parameters:
          - `task`: The task to run
        """

        ignore_errors = False
        if 'ignore_errors' in task:
            if task['ignore_errors'] in ('True', 'true', 1):
                ignore_errors = True

        task = instantiator(task, 'taboot.tasks', host=self._host)

        outputters = []
        for o in self._output:
            instance = instantiator(o, 'taboot.output',
                                           host=self._host,
                                           task=task)
            outputters.append(instance)

        try:
            result = task.run(self)
        except Exception, e:
            result = self._TaskResult(task, output=repr(e))
Beispiel #2
0
    def run_task(self, task):
        """
        Run a single task.  Sets task.host and then invokes the run
        method for the task.

        :Parameters:
          - `task`: The task to run
        """

        ignore_errors = False
        if 'ignore_errors' in task:
            if task['ignore_errors'] in ('True', 'true', 1):
                ignore_errors = True

        task = instantiator(task, 'taboot.tasks', host=self._host)

        outputters = []
        for o in self._output:
            instance = instantiator(o,
                                    'taboot.output',
                                    host=self._host,
                                    task=task)
            outputters.append(instance)

        try:
            result = task.run(self)
        except Exception, e:
            result = self._TaskResult(task, output=repr(e))
Beispiel #3
0
    def validate_concurrency(self):
        """
        Validate that concurrent and non-concurrent tasks don't exist
        in the same script.
        """
        # Still need to finish, need to get concurrency value if it
        # exists, then iterate through to see if there are any
        # non-conurrent tasks in, if so raise a
        # TabootConcurrencyException, will have to catch in cli.py
        #
        # XX: I'm thinking that we can offer the user the ability to
        # edit the script to correct

        log_debug("Concurrency validating %s...", self.fileName)
        log_debug("Concurrency: %s", self.getConcurrency())
        if self.getConcurrency() > 1 or self.getConcurrency() == "all":
            tasks = self.getTaskTypes()
            for task in tasks:
                task = instantiator(task, 'taboot.tasks', host="*")
                if not task.concurrentFriendly:
                    log_debug("Concurrency exception while validating %s",
                              self.fileName)
                    raise TabootConcurrencyException(task)
        log_debug("%s passed concurrency check.", self.fileName)

        return True
Beispiel #4
0
    def validate_concurrency(self):
        """
        Validate that concurrent and non-concurrent tasks don't exist
        in the same script.
        """
        # Still need to finish, need to get concurrency value if it
        # exists, then iterate through to see if there are any
        # non-conurrent tasks in, if so raise a
        # TabootConcurrencyException, will have to catch in cli.py
        #
        # XX: I'm thinking that we can offer the user the ability to
        # edit the script to correct

        log_debug("Concurrency validating %s...", self.fileName)
        log_debug("Concurrency: %s", self.getConcurrency())
        if self.getConcurrency() > 1 or self.getConcurrency() == "all":
            tasks = self.getTaskTypes()
            for task in tasks:
                task = instantiator(task, 'taboot.tasks', host="*")
                if not task.concurrentFriendly:
                    log_debug("Concurrency exception while validating %s",
                              self.fileName)
                    raise TabootConcurrencyException(task)
        log_debug("%s passed concurrency check.", self.fileName)

        return True
Beispiel #5
0
    def validate(self):
        """
        Verify that all tasks can be located, and all required
        elements are present.
        """
        script = self.yamlDoc
        elements_required = set(["hosts", "tasks"])
        elements_present = script.keys()

        self.elements_missing = elements_required.difference(elements_present)
        self.valid = (self.elements_missing == set())

        try:
            for task in self.getPreflightTypes():
                instantiator(task, host="*")
            for task in self.getTaskTypes():
                instantiator(task, host="*")
        except TabootTaskNotFoundException as e:
            self.valid = False
            self.unknown_tasks.add(e.args)
        except KeyError as e:
            self.valid = False
            self.elements_missing.add(e.args)
        return self.valid
Beispiel #6
0
    def validate(self):
        """
        Verify that all tasks can be located, and all required
        elements are present.
        """
        script = self.yamlDoc
        elements_required = set(["hosts", "tasks"])
        elements_present = script.keys()

        self.elements_missing = elements_required.difference(elements_present)
        self.valid = (self.elements_missing == set())

        try:
            for task in self.getPreflightTypes():
                instantiator(task, host="*")
            for task in self.getTaskTypes():
                instantiator(task, host="*")
        except TabootTaskNotFoundException as e:
            self.valid = False
            self.unknown_tasks.add(e.args)
        except KeyError as e:
            self.valid = False
            self.elements_missing.add(e.args)
        return self.valid
Beispiel #7
0
    def validateScript(self):
        # Validate that concurrent and non-concurrent tasks don't exist in the
        # same script.  Still need to finish, need to get concurrency value if
        # it exists, then iterate through to see if there are any non-conurrent
        # tasks in, if so raise a ConcurrencyException, will have to catch in
        # cli.py and I'm thinking that we can offer the user the ability to
        # edit the script to correct
        if self.getConcurrency() > 1:
            tasks = self.getTaskTypes()
            for task in tasks:
                task = instantiator(task, 'taboot.tasks', host="*")
                if (task.concurrentFriendly == False):
                    raise ConcurrencyException(task)

        # TODO add validation logic to ensure that hosts, tasks are present

        # TODO add additional validation logic and throw exception if invalid
        return True
Beispiel #8
0
    def validateScript(self):
        # Validate that concurrent and non-concurrent tasks don't exist in the
        # same script.  Still need to finish, need to get concurrency value if
        # it exists, then iterate through to see if there are any non-conurrent
        # tasks in, if so raise a ConcurrencyException, will have to catch in
        # cli.py and I'm thinking that we can offer the user the ability to
        # edit the script to correct
        if self.getConcurrency() > 1:
            tasks = self.getTaskTypes()
            for task in tasks:
                task = instantiator(task, 'taboot.tasks', host="*")
                if(task.concurrentFriendly == False):
                    raise ConcurrencyException(task)

        # TODO add validation logic to ensure that hosts, tasks are present

        # TODO add additional validation logic and throw exception if invalid
        return True