ANTA Inventory API
AntaInventory
¶
Bases: dict[str, AntaDevice]
Inventory abstraction for ANTA framework.
max_potential_connections
property
¶
max_potential_connections: int | None
Max potential connections of this inventory.
add_device
¶
add_device(device: AntaDevice) -> None
Add a device to final inventory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
AntaDevice
|
Device object to be added. |
required |
Source code in anta/inventory/__init__.py
462 463 464 465 466 467 468 469 470 471 | |
connect_inventory
async
¶
connect_inventory() -> None
Run refresh() coroutines for all AntaDevice objects in this inventory.
Source code in anta/inventory/__init__.py
477 478 479 480 481 482 483 484 485 486 487 | |
disconnect_inventory
async
¶
disconnect_inventory() -> None
Run disconnect() coroutines for all AntaDevice objects in this inventory.
Source code in anta/inventory/__init__.py
493 494 495 496 497 498 499 500 501 | |
dump
¶
dump() -> AntaInventoryInput
Dump the AntaInventory to an AntaInventoryInput.
Each hosts is dumped individually.
Source code in anta/inventory/__init__.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
get_inventory
¶
get_inventory(*, established_only: bool = False, tags: set[str] | None = None, devices: set[str] | None = None) -> AntaInventory
Return a filtered inventory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
established_only
|
bool
|
Whether or not to include only established devices. |
False
|
tags
|
set[str] | None
|
Tags to filter devices. |
None
|
devices
|
set[str] | None
|
Names to filter devices. |
None
|
Returns:
| Type | Description |
|---|---|
AntaInventory
|
An inventory with filtered AntaDevice objects. |
Source code in anta/inventory/__init__.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
is_base_class
¶
is_base_class(device: AntaDevice) -> TypeIs[AntaDevice]
Check the type of device, return True if the device is an AntaDevice.
Source code in anta/inventory/__init__.py
489 490 491 | |
parse
staticmethod
¶
parse(filename: str | Path, username: str, password: str, enable_password: str | None = None, timeout: float | None = None, file_format: Literal['yaml', 'json'] = 'yaml', *, enable: bool = False, insecure: bool = False, disable_cache: bool = False, use_session_auth: bool | None = None) -> AntaInventory
Create an AntaInventory instance from an inventory file.
The inventory devices are AsyncEOSDevice instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | Path
|
Path to device inventory YAML file. |
required |
username
|
str
|
Username to use to connect to devices. |
required |
password
|
str
|
Password to use to connect to devices. |
required |
enable_password
|
str | None
|
Enable password to use if required. |
None
|
timeout
|
float | None
|
Global timeout value in seconds for outgoing eAPI calls. None means no timeout. |
None
|
file_format
|
Literal['yaml', 'json']
|
Whether the inventory file is in JSON or YAML. |
'yaml'
|
enable
|
bool
|
Whether or not the commands need to be run in enable mode towards the devices. |
False
|
insecure
|
bool
|
Disable SSH Host Key validation. |
False
|
disable_cache
|
bool
|
Disable cache globally. |
False
|
use_session_auth
|
bool | None
|
Session authentication override. |
None
|
Raises:
| Type | Description |
|---|---|
InventoryRootKeyError
|
Root key of inventory is missing. |
InventoryIncorrectSchemaError
|
Inventory file is not following AntaInventory Schema. |
Source code in anta/inventory/__init__.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
AntaInventoryInput
¶
Bases: BaseModel
Device inventory input model.
to_json
¶
to_json() -> str
Return a JSON representation string of this model.
Returns:
| Type | Description |
|---|---|
The JSON representation string of this model.
|
|
Source code in anta/inventory/models.py
139 140 141 142 143 144 145 146 | |
yaml
¶
yaml() -> str
Return a YAML representation string of this model.
Returns:
| Type | Description |
|---|---|
str
|
The YAML representation string of this model. |
Source code in anta/inventory/models.py
125 126 127 128 129 130 131 132 133 134 135 136 137 | |
AntaInventoryHost
¶
Bases: AntaInventoryBaseModel
Host entry of AntaInventoryInput.
Attributes:
| Name | Type | Description |
|---|---|---|
host |
Hostname | IPvAnyAddress
|
IP Address or FQDN of the device. |
port |
Port | None
|
Custom eAPI port to use. |
name |
str | None
|
Custom name of the device. |
tags |
set[str]
|
Tags of the device. |
disable_cache |
bool
|
Disable cache for this device. |
use_session_auth |
bool
|
Use session based authentication for this device if supported. |
ssl_params |
SSLParameters | None
|
SSL parameters for this device. |
AntaInventoryNetwork
¶
Bases: AntaInventoryBaseModel
Network entry of AntaInventoryInput.
Attributes:
| Name | Type | Description |
|---|---|---|
network |
IPvAnyNetwork
|
Subnet to use for scanning. |
tags |
set[str]
|
Tags of the devices in this network. |
disable_cache |
bool
|
Disable cache for all devices in this network. |
use_session_auth |
bool
|
Use session based authentication for all devices if supported in this network. |
ssl_params |
SSLParameters | None
|
SSL parameters for all devices in this network. |
AntaInventoryRange
¶
Bases: AntaInventoryBaseModel
IP Range entry of AntaInventoryInput.
Attributes:
| Name | Type | Description |
|---|---|---|
start |
IPvAnyAddress
|
IPv4 or IPv6 address for the beginning of the range. |
stop |
IPvAnyAddress
|
IPv4 or IPv6 address for the end of the range. |
tags |
set[str]
|
Tags of the devices in this IP range. |
disable_cache |
bool
|
Disable cache for all devices in this IP range. |
use_session_auth |
bool
|
Use session based authentication for all devices if supported in this IP range. |
ssl_params |
SSLParameters | None
|
SSL parameters for all devices in this IP range. |