github nornir-automation/nornir v3.7.0a1

pre-release47 minutes ago

With 3.7.0a1, you can follow the progress of a run, cancel it, and set time limits, with the tasks and the runner that you already use. Applications that run an event loop can also run async def tasks and load the inventory on that loop. Existing scripts keep working, and ThreadedRunner is still the default runner.

Note

3.7.0a1 is a pre-release. Install it with pip install "nornir==3.7.0a1". pip install --upgrade nornir does not install it. The new APIs can still change before 3.7.0, so do not use it in production.

Testing the 3.7 pre-releases explains how to install it, what to test, and where to send feedback.

New features

  • Follow, cancel and time-limit runs. Follow each host with nr.stream(). Start a run in the background with nr.submit(), and stop it with handle.cancel(). Set a time limit for each host with per_host_timeout. This works with synchronous tasks on ThreadedRunner and SerialRunner (stream only), and with AsyncioRunner. How-to guide (#1086, #1113)
  • Run async def tasks. Select the asyncio runner and call await nr.arun(...) to run tasks on the event loop of your application. Connection plugins can now support sync, asyncio or both. How-to guide (#1085, #1111)
  • Load the inventory from an async application. nr = await AInitNornir(...) takes the same arguments as InitNornir and does not block the event loop. Existing inventory plugins work with it. How-to guide (#1087, #1112)

To test the async features against real systems, use the pre-releases of two plugins: nornir-scrapli==1.6.0a1 for network devices and nornir-infrahub==1.3.0a1 for the inventory. They are also examples for plugin developers. See Plugins that use the new APIs.

Behaviour changes

  • Nornir.run and Task.run now raise AsyncTaskOnSyncRunError for an async def task. Before, the task did not run, but the host was reported as successful (#1111).
  • A task that contains yield now runs. Before, the task did not run, but the host was reported as successful (#1113).
  • InitNornir now raises TransformFunctionNotSyncError for a transform function defined with async def. Before, the transform function did not run (#1112).
  • Host.close_connections now tries to close every connection, then raises the first error. Before, it stopped at the first connection that it could not close (#1111).

Send feedback

Comment on the issue of the feature (#1085, #1086, #1087), or open a new issue for a bug. You can also write in the #nornir channel of the OpsMill Discord server or in the networktocode Slack team.

The changelog has the complete list of changes.

Full Changelog: v3.6.1...v3.7.0a1

Don't miss a new nornir release

NewReleases is sending notifications on new releases.