aristanetworks / anta

What do you call an ant with frogs legs?
https://anta.arista.com/
Apache License 2.0
46 stars 24 forks source link

Specifying same device with different names in the inventory won't raise an error #818

Open mtache opened 1 week ago

mtache commented 1 week ago

AntaDevice equality is based on (host, port) tuple (https://github.com/aristanetworks/anta/blob/main/anta/device.py#L302).

However, we accept that the user specifies multiple identical devices (same (host, port) tuple) with the different names, leading to inconsistent output:

Inventory:

anta_inventory:
  hosts:
  - host: localhost
    name: spine1
  - host: localhost
    name: spine2
  - host: localhost
    name: leaf1a
  - host: localhost
    name: leaf1b
  - host: localhost
    name: leaf2a
  - host: localhost
    name: leaf2b

Logs:

--- ANTA NRFU Run Information ---
Number of devices: 6 (6 established)
Total number of selected tests: 738
Maximum number of open file descriptors for the current ANTA process: 16384
---------------------------------
Running ANTA tests completed in: 0:00:00.322.
Cache statistics for 'spine1': 168 hits / 228 command(s) (73.68%) <<<<<<<<<<<< all commands are run on the same device
Cache statistics for 'spine2': 0 hits / 0 command(s) (0.00%)
Cache statistics for 'leaf1a': 0 hits / 0 command(s) (0.00%)
Cache statistics for 'leaf1b': 0 hits / 0 command(s) (0.00%)
Cache statistics for 'leaf2a': 0 hits / 0 command(s) (0.00%)
Cache statistics for 'leaf2b': 0 hits / 0 command(s) (0.00%)
mtache commented 1 week ago

As discussed, this use case is not supported. We should raise an error if the user specifies the same device with different names in the inventory.