Skip to content

Inventory models

AntaInventoryInput

Bases: BaseModel

Device inventory input model.

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
100
101
102
103
104
105
106
107
108
109
110
111
112
def yaml(self) -> str:
    """Return a YAML representation string of this model.

    Returns
    -------
    str
        The YAML representation string of this model.
    """
    # TODO: Pydantic and YAML serialization/deserialization is not supported natively.
    # This could be improved.
    # https://github.com/pydantic/pydantic/issues/1043
    # Explore if this worth using this: https://github.com/NowanIlfideme/pydantic-yaml
    return yaml.safe_dump(yaml.safe_load(self.model_dump_json(serialize_as_any=True, exclude_unset=True)), indent=2, width=math.inf)

AntaInventoryHost

Bases: BaseModel

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.

AntaInventoryNetwork

Bases: BaseModel

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.

AntaInventoryRange

Bases: BaseModel

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.