diff options
Diffstat (limited to 'plugins/module_utils/network')
| -rw-r--r-- | plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py | 39 |
1 files changed, 31 insertions, 8 deletions
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..f7b76af9 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 @@ -256,6 +256,10 @@ class L3_interfaces(ConfigBase): def _state_deleted(self, want, have): """The command generator when state is deleted + Deletes only the L3 address attributes (base interface and VIFs) + owned by this module, never the interface subtree, so L2 settings + are preserved. + :rtype: A list :returns: the commands necessary to remove the current configuration of the provided objects @@ -266,14 +270,33 @@ class L3_interfaces(ConfigBase): 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", []) |
