nornir.core.__init__
- class nornir.core.__init__.Nornir(inventory: Inventory, config: Config | None = None, data: GlobalState | None = None, processors: Processors | None = None, runner: RunnerPlugin | None = None)
This is the main object to work with. It contains the inventory and it serves as task dispatcher.
- Parameters:
inventory (
nornir.core.inventory.Inventory
) – Inventory to work withdata (GlobalState) – shared data amongst different iterations of nornir
dry_run (
bool
) – Whether if we are testing the changes or notconfig (
nornir.core.configuration.Config
) – Configuration object
- inventory
Inventory to work with
- 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
- close_connections(on_good: bool = True, on_failed: bool = False) None
- dict() Dict[str, Any]
Return a dictionary representing the object.
- filter(*args: Any, **kwargs: Any) Nornir
See
nornir.core.inventory.Inventory.filter()
- Returns:
A new object with same configuration as
self
but filtered inventory.- Return type:
- run(task: Callable[[...], Any], raise_on_error: bool | None = None, on_good: bool = True, on_failed: bool = False, name: str | None = None, **kwargs: Any) AggregatedResult
Run task over all the hosts in the inventory.
- Parameters:
task (
callable
) – function or callable that will be run against each device in the inventoryraise_on_error (
bool
) – Override raise_on_error behavioron_good (
bool
) – Whether to run or not this task on hosts marked as goodon_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:
- property runner: RunnerPlugin
- with_processors(processors: List[Processor]) Nornir
Given a list of Processor objects return a copy of the nornir object with the processors assigned to the copy. The original object is left unmodified.
- with_runner(runner: RunnerPlugin) Nornir
Given a runner return a copy of the nornir object with the runner assigned to the copy. The original object is left unmodified.