Inventory module
AntaInventory ¶
Bases: dict
Inventory abstraction for ANTA framework.
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
208 209 210 211 212 213 214 |
|
connect_inventory
async
¶
connect_inventory() -> None
Run refresh()
coroutines for all AntaDevice objects in this inventory.
Source code in anta/inventory/__init__.py
220 221 222 223 224 225 226 227 228 229 230 |
|
get_inventory ¶
get_inventory(
established_only: bool = False,
tags: Optional[List[str]] = None,
) -> AntaInventory
Returns a filtered inventory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
established_only |
bool
|
Whether or not to include only established devices. Default False. |
False
|
tags |
Optional[List[str]]
|
List of tags to filter devices. |
None
|
Returns:
Name | Type | Description |
---|---|---|
AntaInventory |
AntaInventory
|
An inventory with filtered AntaDevice objects. |
Source code in anta/inventory/__init__.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
parse
staticmethod
¶
parse(
inventory_file: str,
username: str,
password: str,
enable_password: Optional[str] = None,
timeout: Optional[float] = None,
insecure: bool = False,
) -> AntaInventory
Create an AntaInventory instance from an inventory file. The inventory devices are AsyncEOSDevice instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inventory_file |
str
|
Path to inventory YAML file where user has described his inputs |
required |
username |
str
|
Username to use to connect to devices |
required |
password |
str
|
Password to use to connect to devices |
required |
timeout |
float
|
timeout in seconds for every API call. |
None
|
Raises:
Type | Description |
---|---|
InventoryRootKeyError
|
Root key of inventory is missing. |
InventoryIncorrectSchema
|
Inventory file is not following AntaInventory Schema. |
InventoryUnknownFormat
|
Output format is not supported. |
Source code in anta/inventory/__init__.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|