summaryrefslogtreecommitdiff
path: root/plugins/module_utils
diff options
context:
space:
mode:
authoromnom62 <omnom62@outlook.com>2026-07-02 07:37:05 +1000
committeromnom62 <omnom62@outlook.com>2026-07-02 07:37:05 +1000
commit266ef040a0ecad4249755167a7c36027d6b8b509 (patch)
tree413dcefed4bfc62ed6fa922188125274494b6ad6 /plugins/module_utils
parenteccc8b0e0d7ad816ad0eb7faca649cae3e0083e8 (diff)
downloadvyos.vyos-266ef040a0ecad4249755167a7c36027d6b8b509.tar.gz
vyos.vyos-266ef040a0ecad4249755167a7c36027d6b8b509.zip
T8516: bugfixes
Diffstat (limited to 'plugins/module_utils')
-rw-r--r--plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py41
1 files changed, 27 insertions, 14 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..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", [])