]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: address: remove old ip address when intf is moved to dhcp
authorJulien Fortin <julien@cumulusnetworks.com>
Tue, 16 Jul 2019 23:21:03 +0000 (01:21 +0200)
committerJulien Fortin <julien@cumulusnetworks.com>
Wed, 18 Sep 2019 10:49:21 +0000 (12:49 +0200)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
ifupdown2/addons/address.py

index f576dc02dc081b44fdbea6a64e105785fa161baa..4746e75049a661879cdca92be9d0c00e2f44a3ca 100644 (file)
@@ -856,6 +856,12 @@ class address(moduleBase):
         if addr_method not in ["dhcp", "ppp"]:
             self._inet_address_config(ifaceobj, ifaceobj_getfunc,
                                       force_reapply)
+        else:
+            # remove old addresses added by ifupdown2
+            # (if intf was moved from static config to dhcp)
+            for old_ifaceobj in statemanager.statemanager_api.get_ifaceobjs(ifaceobj.name) or []:
+                for addr in old_ifaceobj.get_attr_value("address") or []:
+                    self.ipcmd.addr_del(ifaceobj.name, addr)
 
         self.process_mtu(ifaceobj, ifaceobj_getfunc)