def run(self, task, **kwargs):
        """
        This is a utility method to call a task from within a task. For instance:

            def grouped_tasks(task):
                task.run(my_first_task)
                task.run(my_second_task)

            nornir.run(grouped_tasks)

        This method will ensure the subtask is run only for the host in the current thread.
        """
        if not self.host or not self.nornir:
            msg = (
                "You have to call this after setting host and nornir attributes. ",
                "You probably called this from outside a nested task",
            )
            raise Exception(msg)

        if "severity_level" not in kwargs:
            kwargs["severity_level"] = self.severity_level
        task = Task(task, **kwargs)
        r = task.start(self.host, self.nornir)
        self.results.append(r[0] if len(r) == 1 else r)

        if r.failed:
            # Without this we will keep running the grouped task
            raise NornirSubTaskError(task=task, result=r)

        return r
def run ( self , task , ** kwargs ) : if not self . host or not self . nornir : msg = ( "You have to call this after setting host and nornir attributes. " , "You probably called this from outside a nested task" , ) raise Exception ( msg ) if "severity_level" not in kwargs : kwargs [ "severity_level" ] = self . severity_level task = Task ( task , ** kwargs ) r = task . start ( self . host , self . nornir ) self . results . append ( r [ 0 ] if len ( r ) == 1 else r ) if r . failed : raise NornirSubTaskError ( task = task , result = r ) return r
This is a utility method to call a task from within a task. For instance:

            def grouped_tasks(task):
                task.run(my_first_task)
                task.run(my_second_task)

            nornir.run(grouped_tasks)

        This method will ensure the subtask is run only for the host in the current thread.