From 0ab1a93edf36f40906a4605dd481878be9d8662f Mon Sep 17 00:00:00 2001 From: gmuloc Date: Mon, 18 Dec 2023 23:34:21 +0100 Subject: [PATCH 1/4] Fix(eos_designs): Empty description under network-ports --- .../configs/network-ports-tests.1.cfg | 20 +++++++++++++++++++ .../network-ports-tests.1.yml | 20 +++++++++++++++++++ .../group_vars/NETWORK_PORTS_TESTS.yml | 7 +++++++ 3 files changed, 47 insertions(+) diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg index e48cf393a93..7560d7457d8 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg @@ -538,6 +538,26 @@ interface Ethernet14 no shutdown switchport ! +interface Ethernet51 + description + shutdown + switchport +! +interface Ethernet52 + description + shutdown + switchport +! +interface Ethernet53 + description + shutdown + switchport +! +interface Ethernet54 + description + shutdown + switchport +! interface Vlan4094 description MLAG_PEER no shutdown diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml index d24069a88f3..ec3ad7522de 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml @@ -669,6 +669,26 @@ ethernet_interfaces: description: CONNECTED_ENDPOINT_OVERWRITING_NETWORK_PORT_Eth42 shutdown: false type: switched +- name: Ethernet51 + peer_type: network_port + description: '' + shutdown: true + type: switched +- name: Ethernet52 + peer_type: network_port + description: '' + shutdown: true + type: switched +- name: Ethernet53 + peer_type: network_port + description: '' + shutdown: true + type: switched +- name: Ethernet54 + peer_type: network_port + description: '' + shutdown: true + type: switched mlag_configuration: domain_id: mlag local_interface: Vlan4094 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml index ec46283be76..5c2e597c569 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml @@ -85,6 +85,13 @@ network_ports: - Ethernet12 description: Config overwriting base config + # Test no description + - switches: + - network-ports-tests.1 + switch_ports: + - Ethernet51-54 + enabled: false + servers: - name: CONNECTED_ENDPOINT_OVERWRITING_NETWORK_PORT adapters: From 8dfa152c08c55af5f4c0474fbd904e6dfec1dc73 Mon Sep 17 00:00:00 2001 From: gmuloc Date: Mon, 18 Dec 2023 23:42:04 +0100 Subject: [PATCH 2/4] Fix(eos_designs): Properly strip empty strings --- .../intended/configs/network-ports-tests.1.cfg | 4 ---- .../intended/structured_configs/network-ports-tests.1.yml | 4 ---- .../python_modules/connected_endpoints/ethernet_interfaces.py | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg index 7560d7457d8..3207eb3114b 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg @@ -539,22 +539,18 @@ interface Ethernet14 switchport ! interface Ethernet51 - description shutdown switchport ! interface Ethernet52 - description shutdown switchport ! interface Ethernet53 - description shutdown switchport ! interface Ethernet54 - description shutdown switchport ! diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml index ec3ad7522de..174dd455bd4 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml @@ -671,22 +671,18 @@ ethernet_interfaces: type: switched - name: Ethernet51 peer_type: network_port - description: '' shutdown: true type: switched - name: Ethernet52 peer_type: network_port - description: '' shutdown: true type: switched - name: Ethernet53 peer_type: network_port - description: '' shutdown: true type: switched - name: Ethernet54 peer_type: network_port - description: '' shutdown: true type: switched mlag_configuration: diff --git a/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/ethernet_interfaces.py b/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/ethernet_interfaces.py index 5705932afd7..d236ee1efde 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/ethernet_interfaces.py +++ b/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/ethernet_interfaces.py @@ -181,4 +181,4 @@ def _get_ethernet_interface_cfg(self, adapter: dict, node_index: int, connected_ if (flowcontrol_received := get(adapter, "flowcontrol.received")) is not None: ethernet_interface["flowcontrol"] = {"received": flowcontrol_received} - return strip_null_from_data(ethernet_interface) + return strip_null_from_data(ethernet_interface, strip_values_tuple=(None, "")) From a89dff8d40f06884a66454b7dd6b49460fd0eed4 Mon Sep 17 00:00:00 2001 From: gmuloc Date: Mon, 18 Dec 2023 23:48:48 +0100 Subject: [PATCH 3/4] CI: Run da pre-commit --- .../inventory/group_vars/NETWORK_PORTS_TESTS.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml index 5c2e597c569..300d3facb96 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml @@ -87,7 +87,7 @@ network_ports: # Test no description - switches: - - network-ports-tests.1 + - network-ports-tests.1 switch_ports: - Ethernet51-54 enabled: false From 4f81f8c90a5078bd86917e6a8e618f5dff7150ee Mon Sep 17 00:00:00 2001 From: gmuloc Date: Mon, 18 Dec 2023 23:54:52 +0100 Subject: [PATCH 4/4] Fix(eos_designs): Apply same fix for port-channels --- .../intended/configs/network-ports-tests-2.cfg | 13 +++++++++++++ .../network-ports-tests-2.yml | 18 ++++++++++++++++++ .../group_vars/NETWORK_PORTS_TESTS.yml | 7 +++++++ .../port_channel_interfaces.py | 4 ++-- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests-2.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests-2.cfg index d088adac1c7..785454c18e7 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests-2.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests-2.cfg @@ -49,6 +49,11 @@ interface Port-Channel42 switchport mlag 42 ! +interface Port-Channel43 + no shutdown + switchport + mlag 43 +! interface Port-Channel101 description MLAG_PEER_network-ports-tests.1_Po101 no shutdown @@ -559,6 +564,14 @@ interface Ethernet12 switchport mode trunk phone switchport ! +interface Ethernet51 + no shutdown + channel-group 43 mode active +! +interface Ethernet52 + no shutdown + channel-group 43 mode active +! interface Vlan4094 description MLAG_PEER no shutdown diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests-2.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests-2.yml index 4b49983238a..6f2bced6a1a 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests-2.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests-2.yml @@ -69,6 +69,10 @@ port_channel_interfaces: type: switched shutdown: false mlag: 42 +- name: Port-Channel43 + type: switched + shutdown: false + mlag: 43 ethernet_interfaces: - name: Ethernet10/1 peer: network-ports-tests.1 @@ -710,6 +714,20 @@ ethernet_interfaces: channel_group: id: 42 mode: active +- name: Ethernet51 + peer_type: network_port + shutdown: false + type: port-channel-member + channel_group: + id: 43 + mode: active +- name: Ethernet52 + peer_type: network_port + shutdown: false + type: port-channel-member + channel_group: + id: 43 + mode: active mlag_configuration: domain_id: mlag local_interface: Vlan4094 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml index 300d3facb96..d4afdf86189 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml @@ -91,6 +91,13 @@ network_ports: switch_ports: - Ethernet51-54 enabled: false + - switches: + - network-ports-tests.2 + switch_ports: + - Ethernet51-52 + port_channel: + channel_id: 43 + mode: "active" servers: - name: CONNECTED_ENDPOINT_OVERWRITING_NETWORK_PORT diff --git a/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/port_channel_interfaces.py b/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/port_channel_interfaces.py index 540376a3d8d..e654b33cde0 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/port_channel_interfaces.py +++ b/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/port_channel_interfaces.py @@ -183,7 +183,7 @@ def _get_port_channel_interface_cfg(self, adapter: dict, port_channel_interface_ } ) - return strip_null_from_data(port_channel_interface) + return strip_null_from_data(port_channel_interface, strip_values_tuple=(None, "")) def _get_port_channel_subinterface_cfg(self, subinterface: dict, adapter: dict, port_channel_subinterface_name: str, channel_group_id: int) -> dict: """ @@ -215,4 +215,4 @@ def _get_port_channel_subinterface_cfg(self, subinterface: dict, adapter: dict, "route_target": generate_route_target(short_esi), } - return strip_null_from_data(port_channel_interface) + return strip_null_from_data(port_channel_interface, strip_values_tuple=(None, ""))