Run Operations
A Nornir Operation is one named action, for example "get the facts", with a different task for
each platform. Nornir selects the task for each host from a registry. nr.run_operation and
nr.arun_operation work with the ray runner.
How an Operation runs
- On the driver, Nornir selects the task for the host's platform and connection, and builds the task's input.
- The driver sends the worker the name of the selected task, not its code.
- The worker looks up that name in its own registry and runs the task.
- The driver checks the output of the Operation.
Register Operation tasks through entry points
A worker fills its registry from the packages installed on its node. An Operation task reaches the workers only when a package registers it through one of these entry points:
nornir.plugins.operationsnornir.plugins.operation_tasks
The name of an entry point in nornir.plugins.operations is the name of the Operation. The
name of an entry point in nornir.plugins.operation_tasks has the form
<operation>.<platform>.<connection>. Each value is module:attribute:
[project.entry-points."nornir.plugins.operations"]
get_version = "my_package.operations:GetVersion"
[project.entry-points."nornir.plugins.operation_tasks"]
"get_version.ios.netmiko" = "my_package.operations:get_version_ios"
"get_version.eos.netmiko" = "my_package.operations:get_version_eos"
The names get_version, my_package, ios, eos and netmiko are examples.
Install that package on every node that runs workers.
Tasks registered at runtime do not reach the workers
A task registered in your script with OperationRegistry.register() exists only in the
driver's process. A host whose platform selects such a task fails with
OperationTaskNotOnWorkerError. The error message says that the task must be registered
through an entry point.
The other hosts of the run are not affected.