]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: vxlan: ifquery: fix remote-ip handling
authorRoopa Prabhu <roopa@cumulusnetworks.com>
Thu, 26 Jan 2017 22:34:32 +0000 (14:34 -0800)
committerRoopa Prabhu <roopa@cumulusnetworks.com>
Thu, 26 Jan 2017 22:57:33 +0000 (14:57 -0800)
Ticket: CM-14628
Reviewed By: julien, nikhil, vivek, mallik
Testing Done: Tested with vxlan config and remote ips added externally

Recent handling of vxlan-purge-routes as part of CM-13815 did not fix
handling of remote ips during ifquery --check and ifquery --running.
This patch fixes ifquery -c and ifquery running for external
vxlan controller cases.

Without this, ifquery --check always returns exit code of 1 for
external vxlan controller configs

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
addons/vxlan.py

index 328f20c9f403d6eb1e924b086172d592c85007ce..a0335bb264adc13d319672e17208e901deca93bc 100644 (file)
@@ -76,6 +76,16 @@ class vxlan(moduleBase):
             return True
         return False
 
+    def _get_purge_remotes(self, ifaceobj):
+        if not ifaceobj:
+            return self._purge_remotes
+        purge_remotes = ifaceobj.get_attr_value_first('vxlan-purge-remotes')
+        if purge_remotes:
+            purge_remotes = utils.get_boolean_from_string(purge_remotes)
+        else:
+            purge_remotes = self._purge_remotes
+        return purge_remotes
+
     def _vxlan_create(self, ifaceobj):
         vxlanid = ifaceobj.get_attr_value_first('vxlan-id')
         if vxlanid:
@@ -84,11 +94,7 @@ class vxlan(moduleBase):
             local = ifaceobj.get_attr_value_first('vxlan-local-tunnelip')
             ageing = ifaceobj.get_attr_value_first('vxlan-ageing')
             learning = utils.get_onoff_bool(ifaceobj.get_attr_value_first('vxlan-learning'))
-            purge_remotes = ifaceobj.get_attr_value_first('vxlan-purge-remotes')
-            if purge_remotes:
-                purge_remotes = utils.get_boolean_from_string(purge_remotes)
-            else:
-                purge_remotes = self._purge_remotes
+            purge_remotes = self._get_purge_remotes(ifaceobj)
             
             if self.ipcmd.link_exists(ifaceobj.name):
                 vxlanattrs = self.ipcmd.get_vxlandev_attrs(ifaceobj.name)
@@ -195,8 +201,12 @@ class vxlan(moduleBase):
                        ifaceobj.get_attr_value_first('vxlan-svcnodeip'),
                        vxlanattrs.get('svcnode'))
 
-        if not systemUtils.is_service_running(None, '/var/run/vxrd.pid'):
-            # vxlan-remoteip config is allowed only if vxrd is not running
+        purge_remotes = self._get_purge_remotes(ifaceobj)
+        if purge_remotes or ifaceobj.get_attr_value('vxlan-remoteip'):
+            # If purge remotes or if vxlan-remoteip's are set
+            # in the config file, we are owners of the installed
+            # remote-ip's, lets check and report any remote ips we don't
+            # understand
             self._query_check_n_update_addresses(ifaceobjcurr, 'vxlan-remoteip',
                            ifaceobj.get_attr_value('vxlan-remoteip'),
                            vxlanattrs.get('remote', []))
@@ -239,8 +249,10 @@ class vxlan(moduleBase):
         attrval = vxlanattrs.get('svcnode')
         if attrval:
             ifaceobjrunning.update_config('vxlan-svcnode', attrval)
-        if not systemUtils.is_service_running(None, '/var/run/vxrd.pid'):
-            # vxlan-remoteip config is allowed only if vxrd is not running
+        purge_remotes = self._get_purge_remotes(None)
+        if purge_remotes:
+            # if purge_remotes is on, it means we own the
+            # remote ips. Query them and add it to the running config
             attrval = vxlanattrs.get('remote')
             if attrval:
                 [ifaceobjrunning.update_config('vxlan-remoteip', a)