Skip to content

Commit

Permalink
Refactor(eos_designs)!: Import AvdIpAddressing class from PyAVD (#4422)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausHolbechArista authored Sep 5, 2024
1 parent cf03230 commit f1ea566
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 35 deletions.
11 changes: 10 additions & 1 deletion ansible_collections/arista/avd/docs/porting-guides/5.x.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,16 @@ The following ansible plugins have been removed from the `arista.avd` Ansible co

TODO: Level 3 sections for each change with details on how to migrate

### AvdInterfaceDescriptions breaking changes
### Base class for custom IP addressing `AvdIpAddressing` was moved

The `AvdIpAddressing` class was moved from the Ansible collection to `pyavd.api.ip_addressing`. Import statements must be updated.

```diff
- from ansible_collections.arista.avd.roles.eos_designs.python_modules.ip_addressing import AvdIpAddressing
+ from pyavd.api.ip_addressing import AvdIpAddressing
```

### Base class for custom interface descriptions `AvdInterfaceDescriptions` breaking changes

The `AvdInterfaceDescriptions` class and the associated `InterfaceDescriptionData` data class were moved from the Ansible collection
to `pyavd.api.interface_descriptions`. Import statements must be updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# that can be found in the LICENSE file.
from functools import cached_property

# TODO: AVD5.0 change this to import from PyAVD instead and remove the python_modules folder.
from ansible_collections.arista.avd.roles.eos_designs.python_modules.ip_addressing import AvdIpAddressing
from pyavd.api.ip_addressing import AvdIpAddressing


class CustomAvdIpAddressing(AvdIpAddressing):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
# TODO: Add tests for rfc5549, overlay_routing_protocol: none with bgp peers etc under network services (since this uplink type expands bgp support there)
overlay_routing_protocol: none
# This is set to true by default on the nodes with uplink_type == p2p-vrfs
# new_network_services_bgp_vrf_config: true

node_type_keys:
# modify spine to get l3 network_services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
from .yaml_dumper import NoAliasDumper, YamlDumper
from .yaml_loader import YamlLoader

# TODO: AVD5.0.0 Some utils are exposed in custom modules code, so we will need to keep it here until 5.0
# TODO: The pyavd imports can be removed once validate_state has been moved to pyavd.
try:
from pyavd._utils import default, get, template, template_var
from pyavd._utils import default, get
except ImportError as e:
default = get = template = template_var = RaiseOnUse(ImportError(f"The 'arista.avd' collection requires the 'pyavd' Python library. Got import error {e}"))
default = get = RaiseOnUse(ImportError(f"The 'arista.avd' collection requires the 'pyavd' Python library. Got import error {e}"))

__all__ = [
"compile_searchpath",
Expand All @@ -34,7 +34,5 @@
"YamlLoader",
"default",
"get",
"template",
"template_var",
"write_file",
]
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
All Python modules have been moved to PyAVD in the folder /python-avd/pyavd/_eos_designs/structured_config/

Base classes from ip_addressing and interface_descriptions can be imported from pyavd.api.ip_addressing and pyavd.api.interface_descriptions.

This file was deleted.

1 change: 0 additions & 1 deletion python-avd/pyavd/_cv/workflows/deploy_configs_to_cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async def deploy_configs_to_cv(configs: list[CVEosConfig], result: DeployToCvRes
- Upload Configlets and assign to devices.
TODO: See if this can be optimized to check if the configlets are already in place and correct. A hash would have been nice.
TODO: Split long configs into multiple configlets for 990KB chunks. Need to figure out how to batch it.
"""
LOGGER.info("deploy_configs_to_cv: %s", len(configs))

Expand Down
1 change: 0 additions & 1 deletion python-avd/pyavd/_cv/workflows/deploy_to_cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ async def deploy_to_cv(
For any device referred under `configs`, `device_tags` and `interface_tags` the device:
- The device must be present in the CloudVision Inventory and onboarded to the "Inventory & Topology Studio".
- TODO: See if we can relax the I&T requirement and add the device if it is missing.
- TODO: See if we can onboard ZTP devices and/or preprovision.
- The hostname will we updated in the I&T Studio.
- The `serial_number` and `system_mac_address` properties will be inplace updated in the given CVDevice objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from functools import cached_property
from typing import TYPE_CHECKING

from pyavd._eos_designs.ip_addressing import AvdIpAddressing
from pyavd._utils import get, load_python_class, merge
from pyavd.api.ip_addressing import AvdIpAddressing

if TYPE_CHECKING:
from . import SharedUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ def _generate_ipsec_key(self: AvdStructuredConfigNetworkServices, name: str, sal
Run type-7 obfuscation using a algorithmic salt so we ensure the same key every time.
TODO: Maybe introduce some formatting with max length of each element, since the keys can be come very very long.
TODO: Maybe introduce some formatting with max length of each element, since the keys can become very very long.
"""
secret = f"{self.shared_utils.hostname}_{name}_{salt}"
type_7_salt = sum(salt.encode("utf-8")) % 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ def _address_family_rtc(self: AvdStructuredConfigOverlay) -> dict | None:
core_peer_group["default_route_target"] = {"only": True}
peer_groups.append(core_peer_group)

# Transposing the Jinja2 logic which is that if the selfevpn_overlay_core peer group is not
# configured thenthe default_route_target is applied in the evpn_overlay_peers peer group.
# Transposing the Jinja2 logic: if the evpn_overlay_core peer group is not
# configured then the default_route_target is applied in the evpn_overlay_peers peer group.
elif self.shared_utils.evpn_role == "server":
evpn_overlay_peers["default_route_target"] = {"only": True}

Expand Down
File renamed without changes.

0 comments on commit f1ea566

Please sign in to comment.