]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
SONAR: addressvirtual: Merge if statement with the enclosing one
authorJulien Fortin <jfortin@nvidia.com>
Mon, 30 May 2022 20:40:48 +0000 (22:40 +0200)
committerJulien Fortin <jfortin@nvidia.com>
Thu, 4 May 2023 11:21:55 +0000 (13:21 +0200)
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
ifupdown2/addons/addressvirtual.py

index 1ec979e440d5e21b045012662ddfc4d6522eb940..de3b0e563454623a1f7c72c411d4dcebe7d98220 100644 (file)
@@ -420,9 +420,8 @@ class addressvirtual(AddonWithIpBlackList, moduleBase):
         ifname = ifaceobj.name
 
         update_mtu = lower_iface_mtu = lower_iface_mtu_str = None
-        if ifupdownconfig.config.get("adjust_logical_dev_mtu", "1") != "0":
-            if ifaceobj.lowerifaces and intf_config_list:
-                update_mtu = True
+        if ifupdownconfig.config.get("adjust_logical_dev_mtu", "1") != "0" and ifaceobj.lowerifaces and intf_config_list:
+            update_mtu = True
 
         if update_mtu:
             lower_iface_mtu = self.cache.get_link_mtu(ifaceobj.name)
@@ -686,11 +685,10 @@ class addressvirtual(AddonWithIpBlackList, moduleBase):
                         "ips": ip4,
                         "id": vrrp_id
                     })
-            elif not ip4 and not ifquery:
+            elif not ip4 and not ifquery and self.cache.link_exists(macvlan_ip4_ifname):
                 # special check to see if all ipv4 were removed from the vrrp
                 # configuration, if so we need to remove the associated macvlan
-                if self.cache.link_exists(macvlan_ip4_ifname):
-                    self.netlink.link_del(macvlan_ip4_ifname)
+                self.netlink.link_del(macvlan_ip4_ifname)
 
             if ip6 or ifquery:
                 merged_with_existing_obj = False
@@ -718,11 +716,10 @@ class addressvirtual(AddonWithIpBlackList, moduleBase):
                         "ips": ip6,
                         "id": vrrp_id
                     })
-            elif not ip6 and not ifquery:
+            elif not ip6 and not ifquery and self.cache.link_exists(macvlan_ip6_ifname):
                 # special check to see if all ipv6 were removed from the vrrp
                 # configuration, if so we need to remove the associated macvlan
-                if self.cache.link_exists(macvlan_ip6_ifname):
-                    self.netlink.link_del(macvlan_ip6_ifname)
+                self.netlink.link_del(macvlan_ip6_ifname)
 
         if not ifquery:
             # check if vrrp attribute was removed/re-assigned