Skip to content

Commit

Permalink
Working load_async
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed Dec 5, 2023
1 parent d6a763f commit ba8a961
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nornir/init_nornir.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
from nornir.core.state import GlobalState


def load_inventory_async(
async def load_inventory_async(
config: Config,
) -> Inventory:
InventoryPluginRegister.auto_register()
inventory_plugin = InventoryPluginRegister.get_plugin(config.inventory.plugin)
inv = inventory_plugin(**config.inventory.options).load_async()
inv = await inventory_plugin(**config.inventory.options).load_async()

if config.inventory.transform_function:
TransformFunctionRegister.auto_register()
Expand All @@ -27,6 +27,7 @@ def load_inventory_async(
for h in inv.hosts.values():
transform_function(h, **(config.inventory.transform_function_options or {}))

return inv

def load_inventory(
config: Config,
Expand Down Expand Up @@ -92,7 +93,7 @@ def InitNornir(
)


def InitNornirAsync(
async def InitNornirAsync(
config_file: str = "",
dry_run: bool = False,
**kwargs: Any,
Expand Down Expand Up @@ -120,9 +121,10 @@ def InitNornirAsync(
data = GlobalState(dry_run=dry_run)

config.logging.configure()
inventory = await load_inventory_async(config)

return Nornir(
inventory=load_inventory_async(config),
inventory=inventory,
runner=load_runner(config),
config=config,
data=data,
Expand Down

0 comments on commit ba8a961

Please sign in to comment.