From 5504ee0d49d3377ec9174e6e814b465c1f3a7107 Mon Sep 17 00:00:00 2001 From: Laxmikant Chintakindi Date: Mon, 21 Oct 2024 15:02:02 +0530 Subject: [PATCH] Update error msg and add negative test --- ...e-p2p-links-ptp-profile-does-not-exist.yml | 29 +++++++++++++++++++ .../inventory/hosts.yml | 1 + .../core_interfaces_and_l3_edge/utils.py | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 ansible_collections/arista/avd/molecule/eos_designs_negative_unit_tests/inventory/host_vars/failure-p2p-links-ptp-profile-does-not-exist.yml diff --git a/ansible_collections/arista/avd/molecule/eos_designs_negative_unit_tests/inventory/host_vars/failure-p2p-links-ptp-profile-does-not-exist.yml b/ansible_collections/arista/avd/molecule/eos_designs_negative_unit_tests/inventory/host_vars/failure-p2p-links-ptp-profile-does-not-exist.yml new file mode 100644 index 00000000000..826e6522a09 --- /dev/null +++ b/ansible_collections/arista/avd/molecule/eos_designs_negative_unit_tests/inventory/host_vars/failure-p2p-links-ptp-profile-does-not-exist.yml @@ -0,0 +1,29 @@ +--- +type: l3leaf + +ptp_profiles: + - profile: PROFILE-1 + +l3leaf: + defaults: + loopback_ipv4_pool: 10.254.1.0/27 + vtep_loopback_ipv4_pool: 10.254.11.0/27 + nodes: + - name: failure-p2p-links-ptp-profile-does-not-exist + id: 1 + bgp_as: 65101 + mgmt_ip: 192.168.0.101/24 + ptp: + enabled: true + +l3_edge: + p2p_links: + - nodes: [failure-p2p-links-ptp-profile-does-not-exist, not-in-fabric] + interfaces: [Ethernet10, Ethernet11] + ip: [192.168.0.2/31, 192.168.0.3/31] + ptp: + enabled: true + profile: PROFILE DOES NOT EXIST + +expected_error_message: >- + PTP Profile 'PROFILE DOES NOT EXIST' referenced under l3_edge.p2p_links does not exist in `ptp_profiles`. diff --git a/ansible_collections/arista/avd/molecule/eos_designs_negative_unit_tests/inventory/hosts.yml b/ansible_collections/arista/avd/molecule/eos_designs_negative_unit_tests/inventory/hosts.yml index 219b33c3977..ac26c9f40ae 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_negative_unit_tests/inventory/hosts.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_negative_unit_tests/inventory/hosts.yml @@ -105,6 +105,7 @@ all: failure-missing-evpn-multicast-peg-rps: failure-missing-evpn-multicast-with-pim: failure-network-port-ptp-profile-does-not-exist: + failure-p2p-links-ptp-profile-does-not-exist: failure-no-local-path-group-in-default-policy: failure-adapter-ptp-profile-does-not-exist: failure-svi-grandparent-profile-does-not-exist: diff --git a/python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/utils.py b/python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/utils.py index 0d77b7db654..b96a1bafa3c 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/utils.py +++ b/python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/utils.py @@ -296,7 +296,7 @@ def _get_ethernet_cfg(self: AvdStructuredConfigCoreInterfacesAndL3Edge, p2p_link ptp_config = {} if (ptp_profile_name := get(p2p_link, "ptp.profile", default=self.shared_utils.ptp_profile_name)) is not None: - msg = f"PTP Profile '{ptp_profile_name}' referenced under {context} does not exist in `ptp_profiles`." + msg = f"PTP Profile '{ptp_profile_name}' referenced under {context}.p2p_links does not exist in `ptp_profiles`." ptp_config.update(get_item(self.shared_utils.ptp_profiles, "profile", ptp_profile_name, required=True, custom_error_msg=msg)) # Apply PTP profile config