nornir.core.__init__

class nornir.core.__init__.Nornir(inventory: nornir.core.inventory.Inventory, config: nornir.core.configuration.Config = None, data: nornir.core.state.GlobalState = None, processors: Optional[nornir.core.processor.Processors] = None, runner: Optional[nornir.core.plugins.runners.RunnerPlugin] = None)

This is the main object to work with. It contains the inventory and it serves as task dispatcher.

Parameters:
  • inventory

    Inventory to work with

    Type:nornir.core.inventory.Inventory
  • data

    shared data amongst different iterations of nornir

    Type:nornir.core.GlobalState
  • dry_run

    Whether if we are testing the changes or not

    Type:bool
  • config

    Configuration parameters

    Type:nornir.core.configuration.Config
  • close_connections(on_good=True, on_failed=False)

  • dict()

    Return a dictionary representing the object.

  • filter(\args, **kwargs*)

    See nornir.core.inventory.Inventory.filter()

    Returns:A new object with same configuration as self but filtered inventory.
    Return type:Nornir
  • classmethod get_validators()

  • run(task, raise_on_error=None, on_good=True, on_failed=False, name: Optional[str] = None, \*kwargs*)

    Run task over all the hosts in the inventory.

    Parameters:
    • task (callable) – function or callable that will be run against each device in the inventory
    • raise_on_error (bool) – Override raise_on_error behavior
    • on_good (bool) – Whether to run or not this task on hosts marked as good
    • on_failed (bool) – Whether to run or not this task on hosts marked as failed
    • **kwargs – additional argument to pass to task when calling it
    Raises:

    nornir.core.exceptions.NornirExecutionError – if at least a task fails and self.config.core.raise_on_error is set to True

    Returns:

    results of each execution

    Return type:

    nornir.core.task.AggregatedResult

  • classmethod validate(v)

  • with_processors(processors: List[nornir.core.processor.Processor]) → nornir.core.__init__.Nornir

    Given a list of Processor objects return a copy of the nornir object with the processors assigned to the copy. The orinal object is left unmodified.

  • with_runner(runner: nornir.core.plugins.runners.RunnerPlugin) → nornir.core.__init__.Nornir

    Given a runner return a copy of the nornir object with the runner assigned to the copy. The orinal object is left unmodified.