Merging upstream version 1.1.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
50f8dbf7e8
commit
2044ea6182
196 changed files with 10121 additions and 3780 deletions
34
examples/parse_anta_inventory_file.py
Normal file
34
examples/parse_anta_inventory_file.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# Copyright (c) 2024 Arista Networks, Inc.
|
||||
# Use of this source code is governed by the Apache License 2.0
|
||||
# that can be found in the LICENSE file.
|
||||
"""Script that parses an ANTA inventory file, connects to devices and print their status."""
|
||||
|
||||
import asyncio
|
||||
|
||||
from anta.inventory import AntaInventory
|
||||
|
||||
|
||||
async def main(inv: AntaInventory) -> None:
|
||||
"""Read an AntaInventory and try to connect to every device in the inventory.
|
||||
|
||||
Print a message for every device connection status
|
||||
"""
|
||||
await inv.connect_inventory()
|
||||
|
||||
for device in inv.values():
|
||||
if device.established:
|
||||
print(f"Device {device.name} is online")
|
||||
else:
|
||||
print(f"Could not connect to device {device.name}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Create the AntaInventory instance
|
||||
inventory = AntaInventory.parse(
|
||||
filename="inventory.yaml",
|
||||
username="arista",
|
||||
password="@rista123",
|
||||
)
|
||||
|
||||
# Run the main coroutine
|
||||
res = asyncio.run(main(inventory))
|
Loading…
Add table
Add a link
Reference in a new issue