Pre-release
This release is a pre-release and may not be stable for production use.
nornir_task_duration
Nornir processor plugin which calculates the duration of each task
This plugin will store the duration of each task as attribute in the Nornir result objects.
Installation
pip install nornir_task_duration
Purpose
The plugin will add new class attributes to the Nornir results:
- total_duration: this is the total duration to process all hosts, this is added to the AggregatedResult
- host_duration: this is the totoal duration to process a single host, this is added to the host's MultiResult
- duration: this is added to the Result of each task
Usage
This example shows the usage of the processor and an example how to print a summary. You may want to use the duration during the task execution or in another print plugin.
from nornir import InitNornir
from nornir.core.task import Result, Task, AggregatedResult, MultiResult
from nornir_task_duration.plugins.processors import TaskDuration
nr = InitNornir(
inventory={
"plugin": "YAMLInventory",
"options": {
"host_file": "tests/inventory/hosts.yaml",
"group_file": "tests/inventory/groups.yaml",
"defaults_file": "tests/inventory/defaults.yaml",
},
}
)
nrp = nr.with_processors([TaskDuration()])
results = nrp.run(task=some_task)
def printer(res):
if type(res) is AggregatedResult:
print(f"TOTAL DURATION:{res.total_duration}")
for r in res:
print(f" * HOST:{r} - DURATION:{res[r].host_duration}")
printer(res[r])
if type(res) is MultiResult:
for r in res:
printer(r)
if type(res) is Result:
print(f" -- task:{res.name} - duration:{res.duration}")
printer(results)
# TOTAL DURATION:12
# * HOST:test1 - DURATION:9
# -- task:ROOT-TASK - duration:9
# -- task:task1 - duration:4
# -- task:task2 - duration:3
# -- task:task2 - duration:3
# * HOST:test2 - DURATION:12
# -- task:ROOT-TASK - duration:12
# -- task:task1 - duration:4
# -- task:task2 - duration:3
# -- task:task2 - duration:3
Metadata
Release files for nornir-task-duration 0.0.1a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nornir_task_duration-0.0.1a0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nornir_task_duration-0.0.1a0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / nornir_task_duration-0.0.1a0.tar.gz
| Download URL | nornir_task_duration-0.0.1a0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1b7f2c9418ec858d2592522db8cc5e863bfd32f89ba942ab56d165cddb1c9ce
|
|
BLAKE2b-256 checksum How to use checksums |
b178c8c9f0fd895007f873afcd6f770f7f0b896c4d149c08cad14e1ff5f500a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.9 Darwin/22.2.0
|
Release files / nornir_task_duration-0.0.1a0-py3-none-any.whl
| Download URL | nornir_task_duration-0.0.1a0-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8854cf7d4bc65b445fac0c134c19a29ba74a5622544e932d754005bf520956a2
|
|
BLAKE2b-256 checksum How to use checksums |
ffe590d9fc32a3222cb042164109138b8e6959bf4935fc9a5aa0135b3ba42ea7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.9 Darwin/22.2.0
|