From 266ef040a0ecad4249755167a7c36027d6b8b509 Mon Sep 17 00:00:00 2001 From: omnom62 Date: Thu, 2 Jul 2026 07:37:05 +1000 Subject: T8516: bugfixes --- .../vyos/config/l3_interfaces/l3_interfaces.py | 41 ++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'plugins/module_utils') diff --git a/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py index a23494cd..2506abb5 100644 --- a/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py @@ -254,26 +254,39 @@ class L3_interfaces(ConfigBase): return commands def _state_deleted(self, want, have): - """The command generator when state is deleted - - :rtype: A list - :returns: the commands necessary to remove the current configuration - of the provided objects - """ commands = [] want_copy = deepcopy(remove_empties(want)) have_copy = deepcopy(have) if have_copy is not None: if all(v in (None, {}, []) for k, v in want_copy.items() if k != "name"): - commands.append( - self._compute_commands( - key=None, - value=None, - interface=want_copy["name"], - remove=True, - ), - ) + # Only delete L3 attributes we own — do not touch L2 config + have_vifs = have_copy.pop("vifs", []) or [] + + for addr_family in ("ipv4", "ipv6"): + for addr in have_copy.get(addr_family) or []: + commands.append( + self._compute_commands( + key="address", + value=addr["address"], + interface=want_copy["name"], + remove=True, + ), + ) + + for have_vif in have_vifs: + for addr_family in ("ipv4", "ipv6"): + for addr in have_vif.get(addr_family) or []: + commands.append( + self._compute_commands( + key="address", + value=addr["address"], + interface=want_copy["name"], + vif=have_vif["vlan_id"], + remove=True, + ), + ) + return commands want_vifs = want_copy.pop("vifs", []) -- cgit v1.2.3