Skip to content

Commit

Permalink
chore: Remove devel
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc committed Jul 19, 2023
1 parent 6630f1c commit bebba4c
Show file tree
Hide file tree
Showing 205 changed files with 7,603 additions and 244 deletions.
Binary file added .coverage
Binary file not shown.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length=165
22 changes: 22 additions & 0 deletions .personal/.personnal/inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
anta_inventory:
hosts:
- host: 192.168.0.10
- host: 192.168.0.11
# Optional tag to assign to this device
tags: ['tag01', 'tag02']
- host: 192.168.0.12
- host: 192.168.0.13
- host: 192.168.0.14
- host: 192.168.0.15
networks:
- network: '192.168.110.0/24'
# Optional tag to assign to all devices in this subnet
tags: ['tag01', 'tag02']
ranges:
- start: 10.0.0.9
end: 10.0.0.11
# Optional tag to assign to all devices in this range
tags: ['tag01', 'tag02']
- start: 10.0.0.100
end: 10.0.0.101
26 changes: 26 additions & 0 deletions .personal/atd-dual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
anta_inventory:
hosts:
- host: 127.0.0.1
port: 3431
name: s1-brdr1
- host: 127.0.0.1
port: 3432
name: s1-brdr2
- host: 127.0.0.1
port: 3433
name: s1-core1
- host: 127.0.0.1
port: 3434
name: s1-core2
- host: 127.0.0.1
port: 3435
name: s1-host1
- host: 127.0.0.1
port: 3436
name: s1-host2
- host: 127.0.0.1
port: 3437
name: s1-leaf1
- host: 127.0.0.1
port: 3438
name: s1-leaf2
3 changes: 3 additions & 0 deletions .personal/atd-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export ANTA_USERNAME=arista
export ANTA_PASSWORD=aristan760
export ANTA_INVENTORY=~/anta/.personal/atd-dual.yml
3 changes: 3 additions & 0 deletions .personal/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export ANTA_USERNAME=arista
export ANTA_PASSWORD=@rista123
export ANTA_INVENTORY=~/anta/.personal/inv.yml
15 changes: 15 additions & 0 deletions .personal/inv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
anta_inventory:
hosts:
- host: 10.88.160.141
name: spine1
- host: 10.88.160.142
- host: 10.88.160.143
name: leaf1
- host: 10.88.160.144
name: leaf2
- host: 10.88.160.145
name: leaf3
- host: 10.88.160.146
name: leaf4
- host: 10.88.160.147
- host: 10.88.160.148
63 changes: 63 additions & 0 deletions .personal/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""
Example
"""
# This is needed to run the script for python < 3.10 for typing annotations
from __future__ import annotations

import asyncio
from copy import deepcopy
from pprint import pprint

from anta.inventory import AntaInventory
from anta.models import AntaCommand


async def main_loop(inv: AntaInventory, commands: list[str]) -> dict[str, list[AntaCommand]]:
"""
Take an inventory and a list of commands and:
1. try to connect to every device in the inventory
2. print a message for every device where connection could not be established
3. collect the results of the commands towards each device
Returns:
a dictionary where key is the device name and the value is the list of AntaCommand ran towards the device
"""
await inv.connect_inventory()

# Print a list of devices that could not be connected to
for device in inv.get_inventory(established_only=False).values():
if device.established is False:
print(f"Could not connect to device {device.name}")

# Make a list of coroutine to run commands towards each connected device
coros = []
# dict to keep track of the commands per device
result_dict = {}
print("DONE")
for name, device in inv.get_inventory(established_only=True).items():
anta_commands = [AntaCommand(command=command, ofmt="json") for command in commands]
result_dict[name] = anta_commands
coros.append(device.collect_commands(anta_commands))

# Run the coroutines
await asyncio.gather(*coros)

return result_dict


if __name__ == "__main__":
# Create the inventory
inventory = AntaInventory.parse(
inventory_file="inv.yml",
username="arista",
password="@rista123",
timeout=15,
)

# Create a list of commands with json output
commands = ["show version", "show ip bgp summary"]

# Run the main asyncio entry point
res = asyncio.run(main_loop(inventory, commands))

pprint(res)
27 changes: 27 additions & 0 deletions .personal/test_decorator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# testing

from anta.decorators import skip_on_platforms
from anta.inventory.models import InventoryDevice
from anta.result_manager.models import TestResult


@skip_on_platforms(platforms=["cEOSLab"]) # pylint: disable=missing-kwoa
def verify_dummy(device: InventoryDevice) -> TestResult:
"""
dummy test to check decorator
"""
result = TestResult(host=str(device.host), test="verify_dummy")
result.is_success()
return result


if __name__ == "__main__":
device1 = InventoryDevice(
host="42.42.42.42", hw_model="7504R", username="a", password="a", url="a"
)
device2 = InventoryDevice(
host="25.25.25.25", hw_model="cEOSLab", username="a", password="a", url="a"
)

print(verify_dummy(device1))
print(verify_dummy(device2))
10 changes: 10 additions & 0 deletions .personal/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
anta.tests.configuration:
- VerifyZeroTouch:
anta.tests.logging:
- VerifyLoggingHosts:
hosts:
- 1.1.1.1
anta.tests.multicast:
- VerifyIGMPSnoopingGlobal:
configuration: blah
6 changes: 6 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
anta
anta-310
3.7.13
3.9.13
3.10.3
3.11.1
Binary file added .tox/.tmp/package/1/anta-0.5.0.tar.gz
Binary file not shown.
Loading

0 comments on commit bebba4c

Please sign in to comment.