From 1a50a2d6a408bf34f2f4cf101e7fd517dc281240 Mon Sep 17 00:00:00 2001 From: Sugetha Kalyanaraman Date: Tue, 29 Oct 2024 15:00:18 -0700 Subject: [PATCH] Moving logic to facts --- .../intended/configs/ptp-tests-leaf1.cfg | 12 +++++ .../intended/configs/ptp-tests-leaf2.cfg | 12 +++++ .../intended/configs/ptp-tests-spine1.cfg | 30 +++++++++++++ .../intended/configs/ptp-tests-spine2.cfg | 6 +++ .../structured_configs/ptp-tests-leaf1.yml | 18 ++++++++ .../structured_configs/ptp-tests-leaf2.yml | 18 ++++++++ .../structured_configs/ptp-tests-spine1.yml | 45 +++++++++++++++++++ .../structured_configs/ptp-tests-spine2.yml | 9 ++++ .../schema/eos_cli_config_gen.schema.yml | 3 -- .../_eos_designs/eos_designs_facts/uplinks.py | 9 +++- .../schema/eos_designs.schema.yml | 7 ++- .../underlay/ethernet_interfaces.py | 2 +- 12 files changed, 161 insertions(+), 10 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-leaf1.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-leaf1.cfg index bff0924582e..0bd983549e4 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-leaf1.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-leaf1.cfg @@ -87,6 +87,12 @@ interface Ethernet1 mtu 9214 no switchport ip address 10.254.2.1/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Ethernet2 description P2P_ptp-tests-spine1_Ethernet2 @@ -94,6 +100,12 @@ interface Ethernet2 mtu 9214 no switchport ip address 10.254.2.3/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Ethernet3 description SERVER_Endpoint-with-specific-PTP-profile_eth3 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-leaf2.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-leaf2.cfg index 3edcec80581..8bb47e0b6a1 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-leaf2.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-leaf2.cfg @@ -94,6 +94,12 @@ interface Ethernet1 mtu 9214 no switchport ip address 10.254.2.5/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Ethernet2 description P2P_ptp-tests-spine1_Ethernet4 @@ -101,6 +107,12 @@ interface Ethernet2 mtu 9214 no switchport ip address 10.254.2.7/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Ethernet5 description SERVER_video-endpoint_PCI2 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-spine1.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-spine1.cfg index 46f98c4bc21..5366d90dfc2 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-spine1.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-spine1.cfg @@ -40,6 +40,12 @@ interface Ethernet1 mtu 9214 no switchport ip address 10.254.2.0/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Ethernet2 description P2P_ptp-tests-leaf1_Ethernet2 @@ -47,6 +53,12 @@ interface Ethernet2 mtu 9214 no switchport ip address 10.254.2.2/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Ethernet3 description P2P_ptp-tests-leaf2_Ethernet1 @@ -54,6 +66,12 @@ interface Ethernet3 mtu 9214 no switchport ip address 10.254.2.4/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Ethernet4 description P2P_ptp-tests-leaf2_Ethernet2 @@ -61,6 +79,12 @@ interface Ethernet4 mtu 9214 no switchport ip address 10.254.2.6/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Ethernet6 description P2P_ptp-tests-spine2_Ethernet6 @@ -116,6 +140,12 @@ interface Ethernet10 mtu 9214 no switchport ip address 10.254.2.12/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Loopback0 description ROUTER_ID diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-spine2.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-spine2.cfg index 60bb9f58e84..cb813b34656 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-spine2.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/ptp-tests-spine2.cfg @@ -96,6 +96,12 @@ interface Ethernet10 mtu 9214 no switchport ip address 10.254.2.14/31 + ptp enable + ptp announce interval 0 + ptp announce timeout 3 + ptp delay-req interval -3 + ptp sync-message interval -3 + ptp transport ipv4 ! interface Loopback0 description ROUTER_ID diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-leaf1.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-leaf1.yml index a7cd0e07622..9add5c942b6 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-leaf1.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-leaf1.yml @@ -145,6 +145,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.1/31 - name: Ethernet2 peer: ptp-tests-spine1 @@ -155,6 +164,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.3/31 - name: Ethernet11 peer: ptp-tests-l2leaf1-ptp-disabled diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-leaf2.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-leaf2.yml index 13da77f9b23..55c2796be77 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-leaf2.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-leaf2.yml @@ -156,6 +156,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.5/31 - name: Ethernet2 peer: ptp-tests-spine1 @@ -166,6 +175,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.7/31 - name: Ethernet11 peer: ptp-tests-l2leaf1-ptp-disabled diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-spine1.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-spine1.yml index 0d6b8225f72..4be49c37a31 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-spine1.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-spine1.yml @@ -142,6 +142,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.0/31 - name: Ethernet2 peer: ptp-tests-leaf1 @@ -152,6 +161,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.2/31 - name: Ethernet3 peer: ptp-tests-leaf2 @@ -162,6 +180,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.4/31 - name: Ethernet4 peer: ptp-tests-leaf2 @@ -172,6 +199,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.6/31 - name: Ethernet10 peer: ptp-tests-restrict-uplinks-leaf1 @@ -182,6 +218,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.12/31 - name: Ethernet6 peer: ptp-tests-spine2 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-spine2.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-spine2.yml index 06da819b42f..d6793545dfb 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-spine2.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/ptp-tests-spine2.yml @@ -125,6 +125,15 @@ ethernet_interfaces: mtu: 9214 switchport: enabled: false + ptp: + announce: + interval: 0 + timeout: 3 + delay_req: -3 + sync_message: + interval: -3 + transport: ipv4 + enable: true ip_address: 10.254.2.14/31 - name: Ethernet6 peer: ptp-tests-spine1 diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml index b53adb3152a..0c853a01b8c 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml @@ -10645,9 +10645,6 @@ keys: clock_identity: type: str description: The clock-id in xx:xx:xx:xx:xx:xx format. - uplinks: - type: list - description: limit ptp to only specified interface source: type: dict keys: diff --git a/python-avd/pyavd/_eos_designs/eos_designs_facts/uplinks.py b/python-avd/pyavd/_eos_designs/eos_designs_facts/uplinks.py index 410f0f5fe63..c45241d9c13 100644 --- a/python-avd/pyavd/_eos_designs/eos_designs_facts/uplinks.py +++ b/python-avd/pyavd/_eos_designs/eos_designs_facts/uplinks.py @@ -188,7 +188,9 @@ def _get_p2p_uplink(self: EosDesignsFacts, uplink_index: int, uplink_interface: if self.shared_utils.uplink_ptp is not None: uplink["ptp"] = self.shared_utils.uplink_ptp - elif self.shared_utils.ptp_enabled: + elif self.shared_utils.ptp_enabled and ( + (self.shared_utils.ptp_uplinks and uplink["interface"] in self.shared_utils.ptp_uplinks) or (self.shared_utils.ptp_uplinks == []) + ): uplink["ptp"] = {"enable": True} if self.shared_utils.uplink_macsec is not None: @@ -264,7 +266,10 @@ def _get_l2_uplink( if self.shared_utils.uplink_ptp is not None: uplink["ptp"] = self.shared_utils.uplink_ptp - elif self.shared_utils.ptp_enabled: + + elif self.shared_utils.ptp_enabled and ( + (self.shared_utils.ptp_uplinks and uplink["interface"] in self.shared_utils.ptp_uplinks) or (self.shared_utils.ptp_uplinks == []) + ): uplink["ptp"] = {"enable": True} # Remove vlans if upstream switch does not have them #} diff --git a/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml b/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml index d52ca779116..8134bbbd17f 100644 --- a/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml +++ b/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml @@ -8792,7 +8792,9 @@ $defs: default: aes67-r16-2016 uplinks: type: list - description: limit ptp to only specified interface + items: + type: str + description: Limit PTP to the specified uplink interfaces. mlag: description: Configure PTP on the MLAG peer-link port-channel when PTP is enabled. By default PTP will not be configured on the MLAG @@ -9547,9 +9549,6 @@ $defs: type: bool default: false description: Enable PTP. - uplinks: - type: list - description: limit ptp to only specified interface sflow: type: bool description: Enable sFlow. Overrides `fabric_sflow` setting. diff --git a/python-avd/pyavd/_eos_designs/structured_config/underlay/ethernet_interfaces.py b/python-avd/pyavd/_eos_designs/structured_config/underlay/ethernet_interfaces.py index f6bd2f5413a..896941c93d7 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/underlay/ethernet_interfaces.py +++ b/python-avd/pyavd/_eos_designs/structured_config/underlay/ethernet_interfaces.py @@ -67,7 +67,7 @@ def ethernet_interfaces(self: AvdStructuredConfigUnderlay) -> list | None: ) # PTP - if get(link, "ptp.enable") is True and link["interface"] in self.shared_utils.ptp_uplinks: + if get(link, "ptp.enable") is True: ptp_config = {} # Apply PTP profile config if using the new ptp config style