|
| 1 | +# Copyright (c) 2026 Arista Networks, Inc. |
| 2 | +# Use of this source code is governed by the Apache License 2.0 |
| 3 | +# that can be found in the LICENSE file. |
| 4 | + |
| 5 | +from __future__ import annotations |
| 6 | + |
| 7 | +from typing import TYPE_CHECKING, ClassVar |
| 8 | + |
| 9 | +from pyavd._eos_cli_config_gen.schema import EosCliConfigGen |
| 10 | +from pyavd._schema.models.avd_list import AvdList |
| 11 | +from pyavd._schema.models.avd_model import AvdModel |
| 12 | + |
| 13 | +if TYPE_CHECKING: |
| 14 | + from pyavd._utils import Undefined, UndefinedType |
| 15 | + |
| 16 | + |
| 17 | +class CvDeploy(AvdModel): |
| 18 | + """Subclass of AvdModel.""" |
| 19 | + |
| 20 | + class CvDeviceTagsItem(AvdModel): |
| 21 | + """Subclass of AvdModel.""" |
| 22 | + |
| 23 | + _fields: ClassVar[dict] = {"name": {"type": str}, "value": {"type": str}} |
| 24 | + name: str |
| 25 | + value: str |
| 26 | + |
| 27 | + if TYPE_CHECKING: |
| 28 | + |
| 29 | + def __init__(self, *, name: str | UndefinedType = Undefined, value: str | UndefinedType = Undefined) -> None: |
| 30 | + """ |
| 31 | + CvDeviceTagsItem. |
| 32 | +
|
| 33 | + Subclass of AvdModel. |
| 34 | +
|
| 35 | + Args: |
| 36 | + name: name |
| 37 | + value: value |
| 38 | +
|
| 39 | + """ |
| 40 | + |
| 41 | + class CvDeviceTags(AvdList[CvDeviceTagsItem]): |
| 42 | + """Subclass of AvdList with `CvDeviceTagsItem` items.""" |
| 43 | + |
| 44 | + CvDeviceTags._item_type = CvDeviceTagsItem |
| 45 | + |
| 46 | + class CvInterfaceTagsItem(AvdModel): |
| 47 | + """Subclass of AvdModel.""" |
| 48 | + |
| 49 | + class TagsItem(AvdModel): |
| 50 | + """Subclass of AvdModel.""" |
| 51 | + |
| 52 | + _fields: ClassVar[dict] = {"name": {"type": str}, "value": {"type": str}} |
| 53 | + name: str |
| 54 | + value: str |
| 55 | + |
| 56 | + if TYPE_CHECKING: |
| 57 | + |
| 58 | + def __init__(self, *, name: str | UndefinedType = Undefined, value: str | UndefinedType = Undefined) -> None: |
| 59 | + """ |
| 60 | + TagsItem. |
| 61 | +
|
| 62 | + Subclass of AvdModel. |
| 63 | +
|
| 64 | + Args: |
| 65 | + name: name |
| 66 | + value: value |
| 67 | +
|
| 68 | + """ |
| 69 | + |
| 70 | + class Tags(AvdList[TagsItem]): |
| 71 | + """Subclass of AvdList with `TagsItem` items.""" |
| 72 | + |
| 73 | + Tags._item_type = TagsItem |
| 74 | + |
| 75 | + _fields: ClassVar[dict] = {"interface": {"type": str}, "tags": {"type": Tags}} |
| 76 | + interface: str |
| 77 | + tags: Tags |
| 78 | + """Subclass of AvdList with `TagsItem` items.""" |
| 79 | + |
| 80 | + if TYPE_CHECKING: |
| 81 | + |
| 82 | + def __init__(self, *, interface: str | UndefinedType = Undefined, tags: Tags | UndefinedType = Undefined) -> None: |
| 83 | + """ |
| 84 | + CvInterfaceTagsItem. |
| 85 | +
|
| 86 | + Subclass of AvdModel. |
| 87 | +
|
| 88 | + Args: |
| 89 | + interface: interface |
| 90 | + tags: Subclass of AvdList with `TagsItem` items. |
| 91 | +
|
| 92 | + """ |
| 93 | + |
| 94 | + class CvInterfaceTags(AvdList[CvInterfaceTagsItem]): |
| 95 | + """Subclass of AvdList with `CvInterfaceTagsItem` items.""" |
| 96 | + |
| 97 | + CvInterfaceTags._item_type = CvInterfaceTagsItem |
| 98 | + |
| 99 | + class Metadata(AvdModel): |
| 100 | + """Subclass of AvdModel.""" |
| 101 | + |
| 102 | + _fields: ClassVar[dict] = { |
| 103 | + "is_deployed": {"type": bool}, |
| 104 | + "serial_number": {"type": str}, |
| 105 | + "system_mac_address": {"type": str}, |
| 106 | + "cv_tags": {"type": EosCliConfigGen.Metadata.CvTags}, |
| 107 | + "cv_pathfinder": {"type": EosCliConfigGen.Metadata.CvPathfinder}, |
| 108 | + } |
| 109 | + _allow_other_keys: ClassVar[bool] = True |
| 110 | + is_deployed: bool | None |
| 111 | + """Key only used for documentation or validation purposes.""" |
| 112 | + serial_number: str | None |
| 113 | + """ |
| 114 | + Serial Number of the device. |
| 115 | + Used only for documentation and deployment purposes. It is used by the |
| 116 | + 'cv_deploy' role. |
| 117 | + """ |
| 118 | + system_mac_address: str | None |
| 119 | + cv_tags: EosCliConfigGen.Metadata.CvTags |
| 120 | + cv_pathfinder: EosCliConfigGen.Metadata.CvPathfinder |
| 121 | + """Metadata used for CV Pathfinder visualization on CloudVision.""" |
| 122 | + |
| 123 | + if TYPE_CHECKING: |
| 124 | + |
| 125 | + def __init__( |
| 126 | + self, |
| 127 | + *, |
| 128 | + is_deployed: bool | None | UndefinedType = Undefined, |
| 129 | + serial_number: str | None | UndefinedType = Undefined, |
| 130 | + system_mac_address: str | None | UndefinedType = Undefined, |
| 131 | + cv_tags: EosCliConfigGen.Metadata.CvTags | UndefinedType = Undefined, |
| 132 | + cv_pathfinder: EosCliConfigGen.Metadata.CvPathfinder | UndefinedType = Undefined, |
| 133 | + ) -> None: |
| 134 | + """ |
| 135 | + Metadata. |
| 136 | +
|
| 137 | + Subclass of AvdModel. |
| 138 | +
|
| 139 | + Args: |
| 140 | + is_deployed: Key only used for documentation or validation purposes. |
| 141 | + serial_number: |
| 142 | + Serial Number of the device. |
| 143 | + Used only for documentation and deployment purposes. It is used by the |
| 144 | + 'cv_deploy' role. |
| 145 | + system_mac_address: system_mac_address |
| 146 | + cv_tags: cv_tags |
| 147 | + cv_pathfinder: Metadata used for CV Pathfinder visualization on CloudVision. |
| 148 | +
|
| 149 | + """ |
| 150 | + |
| 151 | + _fields: ClassVar[dict] = { |
| 152 | + "is_deployed": {"type": bool, "default": True}, |
| 153 | + "serial_number": {"type": str}, |
| 154 | + "system_mac_address": {"type": str}, |
| 155 | + "cv_device_tags": {"type": CvDeviceTags}, |
| 156 | + "cv_interface_tags": {"type": CvInterfaceTags}, |
| 157 | + "cv_pathfinder_metadata": {"type": EosCliConfigGen.Metadata.CvPathfinder}, |
| 158 | + "metadata": {"type": Metadata}, |
| 159 | + } |
| 160 | + _allow_other_keys: ClassVar[bool] = True |
| 161 | + is_deployed: bool |
| 162 | + """ |
| 163 | + When set to `false`, the device will be skipped from all operations performed by the `cv_deploy` |
| 164 | + role. |
| 165 | +
|
| 166 | + Default value: `True` |
| 167 | + """ |
| 168 | + serial_number: str | None |
| 169 | + """ |
| 170 | + Serial number of the device used to identify the device in CloudVision. |
| 171 | + Takes precedence over |
| 172 | + `system_mac_address` and `inventory_hostname`. |
| 173 | +
|
| 174 | + Device identification precedence: |
| 175 | + 1. |
| 176 | + `serial_number` (highest priority) |
| 177 | + 2. `system_mac_address` |
| 178 | + 3. `inventory_hostname` (lowest |
| 179 | + priority, used only if neither of the above is set) |
| 180 | + """ |
| 181 | + system_mac_address: str | None |
| 182 | + """ |
| 183 | + System MAC address of the device used to identify the device in CloudVision. |
| 184 | + Should match the MAC |
| 185 | + address shown in "show version" on the device. |
| 186 | + Used when `serial_number` is not set. |
| 187 | +
|
| 188 | + Device |
| 189 | + identification precedence: |
| 190 | + 1. `serial_number` (highest priority) |
| 191 | + 2. `system_mac_address` |
| 192 | + 3. |
| 193 | + `inventory_hostname` (lowest priority, used only if neither of the above is set) |
| 194 | + """ |
| 195 | + cv_device_tags: CvDeviceTags |
| 196 | + """ |
| 197 | + List of CloudVision device tags to be assigned to this device. |
| 198 | +
|
| 199 | + Subclass of AvdList with |
| 200 | + `CvDeviceTagsItem` items. |
| 201 | + """ |
| 202 | + cv_interface_tags: CvInterfaceTags |
| 203 | + """ |
| 204 | + List of CloudVision interface tags to be assigned to interfaces on this device. |
| 205 | +
|
| 206 | + Subclass of AvdList |
| 207 | + with `CvInterfaceTagsItem` items. |
| 208 | + """ |
| 209 | + cv_pathfinder_metadata: EosCliConfigGen.Metadata.CvPathfinder |
| 210 | + """Metadata used for CV Pathfinder visualization on CloudVision.""" |
| 211 | + metadata: Metadata |
| 212 | + """ |
| 213 | + Metadata from the `eos_designs` role, loaded automatically from structured configs. |
| 214 | + For standalone |
| 215 | + usage without `eos_designs`, use the other `cv_deploy` schema keys instead. |
| 216 | + If both are provided, |
| 217 | + `metadata` takes precedence. |
| 218 | +
|
| 219 | + Subclass of AvdModel. |
| 220 | + """ |
| 221 | + |
| 222 | + if TYPE_CHECKING: |
| 223 | + |
| 224 | + def __init__( |
| 225 | + self, |
| 226 | + *, |
| 227 | + is_deployed: bool | UndefinedType = Undefined, |
| 228 | + serial_number: str | None | UndefinedType = Undefined, |
| 229 | + system_mac_address: str | None | UndefinedType = Undefined, |
| 230 | + cv_device_tags: CvDeviceTags | UndefinedType = Undefined, |
| 231 | + cv_interface_tags: CvInterfaceTags | UndefinedType = Undefined, |
| 232 | + cv_pathfinder_metadata: EosCliConfigGen.Metadata.CvPathfinder | UndefinedType = Undefined, |
| 233 | + metadata: Metadata | UndefinedType = Undefined, |
| 234 | + ) -> None: |
| 235 | + """ |
| 236 | + CvDeploy. |
| 237 | +
|
| 238 | + Subclass of AvdModel. |
| 239 | +
|
| 240 | + Args: |
| 241 | + is_deployed: |
| 242 | + When set to `false`, the device will be skipped from all operations performed by the `cv_deploy` |
| 243 | + role. |
| 244 | + serial_number: |
| 245 | + Serial number of the device used to identify the device in CloudVision. |
| 246 | + Takes precedence over |
| 247 | + `system_mac_address` and `inventory_hostname`. |
| 248 | +
|
| 249 | + Device identification precedence: |
| 250 | + 1. |
| 251 | + `serial_number` (highest priority) |
| 252 | + 2. `system_mac_address` |
| 253 | + 3. `inventory_hostname` (lowest |
| 254 | + priority, used only if neither of the above is set) |
| 255 | + system_mac_address: |
| 256 | + System MAC address of the device used to identify the device in CloudVision. |
| 257 | + Should match the MAC |
| 258 | + address shown in "show version" on the device. |
| 259 | + Used when `serial_number` is not set. |
| 260 | +
|
| 261 | + Device |
| 262 | + identification precedence: |
| 263 | + 1. `serial_number` (highest priority) |
| 264 | + 2. `system_mac_address` |
| 265 | + 3. |
| 266 | + `inventory_hostname` (lowest priority, used only if neither of the above is set) |
| 267 | + cv_device_tags: |
| 268 | + List of CloudVision device tags to be assigned to this device. |
| 269 | +
|
| 270 | + Subclass of AvdList with |
| 271 | + `CvDeviceTagsItem` items. |
| 272 | + cv_interface_tags: |
| 273 | + List of CloudVision interface tags to be assigned to interfaces on this device. |
| 274 | +
|
| 275 | + Subclass of AvdList |
| 276 | + with `CvInterfaceTagsItem` items. |
| 277 | + cv_pathfinder_metadata: Metadata used for CV Pathfinder visualization on CloudVision. |
| 278 | + metadata: |
| 279 | + Metadata from the `eos_designs` role, loaded automatically from structured configs. |
| 280 | + For standalone |
| 281 | + usage without `eos_designs`, use the other `cv_deploy` schema keys instead. |
| 282 | + If both are provided, |
| 283 | + `metadata` takes precedence. |
| 284 | +
|
| 285 | + Subclass of AvdModel. |
| 286 | +
|
| 287 | + """ |
0 commit comments