From 3fb83a7ab6a1f0210974dfc81e9b3647083d6db5 Mon Sep 17 00:00:00 2001 From: Julien Fortin Date: Fri, 26 Oct 2018 18:48:49 +0200 Subject: [PATCH] addons: vxlan: attr vxlan-port: add DRYRUN check -n sets DRYRUN flags, when DRYRUN is set many functions return True (like link_exists), in this case vxlanattrs is set to False because not cached. But since link_exists=True we still try to access it like a dictionary. Signed-off-by: Julien Fortin --- ifupdown2/addons/vxlan.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ifupdown2/addons/vxlan.py b/ifupdown2/addons/vxlan.py index abbad44..c21af7b 100644 --- a/ifupdown2/addons/vxlan.py +++ b/ifupdown2/addons/vxlan.py @@ -10,6 +10,7 @@ from ipaddr import IPNetwork, IPv4Address, IPv4Network, AddressValueError try: import ifupdown2.ifupdown.policymanager as policymanager + import ifupdown2.ifupdown.ifupdownflags as ifupdownflags from ifupdown2.nlmanager.nlmanager import Link @@ -21,6 +22,7 @@ try: from ifupdown2.ifupdownaddons.modulebase import moduleBase except ImportError: import ifupdown.policymanager as policymanager + import ifupdown.ifupdownflags as ifupdownflags from nlmanager.nlmanager import Link @@ -290,7 +292,7 @@ class vxlan(moduleBase): self.logger.warning('%s: vxlan-port: using default %s: invalid configured value %s' % (ifname, netlink.VXLAN_UDP_PORT, str(e))) vxlan_port = netlink.VXLAN_UDP_PORT - if link_exists: + if link_exists and not ifupdownflags.flags.DRYRUN: cache_port = vxlanattrs.get(Link.IFLA_VXLAN_PORT) if vxlan_port != cache_port: self.logger.warning('%s: vxlan-port (%s) cannot be changed - to apply the desired change please run: ifdown %s && ifup %s'