1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

some more ifquery support (for vxlan devices etc)

Ticket: CM-3784
Reviewed By:
Testing Done: Tested ifquery check/running and sanity
This commit is contained in:
Roopa Prabhu
2014-10-31 11:28:07 -07:00
parent 27f6acf555
commit 9e012f9e8a
5 changed files with 116 additions and 18 deletions

View File

@@ -4,6 +4,7 @@ from ifupdown.iface import *
from ifupdownaddons.modulebase import moduleBase
from ifupdownaddons.iproute2 import iproute2
import logging
from sets import Set
class vxlan(moduleBase):
_modinfo = {'mhelp' : 'vxlan module configures vxlan interfaces.',
@@ -50,16 +51,81 @@ class vxlan(moduleBase):
except Exception, e:
self.log_warn(str(e))
def _query_check_n_update(self, ifaceobjcurr, attrname, attrval,
running_attrval):
if running_attrval and attrval == running_attrval:
ifaceobjcurr.update_config_with_status(attrname, attrval, 0)
else:
ifaceobjcurr.update_config_with_status(attrname, running_attrval, 1)
def _query_check_n_update_addresses(self, ifaceobjcurr, attrname,
addresses, running_addresses):
if addresses:
for a in addresses:
if a in running_addresses:
ifaceobjcurr.update_config_with_status(attrname, a, 0)
else:
ifaceobjcurr.update_config_with_status(attrname, a, 1)
running_addresses = Set(running_addresses).difference(
Set(addresses))
[ifaceobjcurr.update_config_with_status(attrname, a, 1)
for a in running_addresses]
def _query_check(self, ifaceobj, ifaceobjcurr):
if not self.ipcmd.link_exists(ifaceobj.name):
ifaceobjcurr.status = ifaceStatus.NOTFOUND
return
# Update vxlan object
vxlanattrs = self.ipcmd.get_vxlandev_attrs(ifaceobj.name)
if not vxlanattrs:
ifaceobjcurr.check_n_update_config_with_status_many(
self.get_mod_attrs(), -1)
return
self._query_check_n_update(ifaceobjcurr, 'vxlan-id',
ifaceobj.get_attr_value_first('vxlan-id'),
vxlanattrs.get('vxlanid'))
self._query_check_n_update(ifaceobjcurr, 'vxlan-local-tunnelip',
ifaceobj.get_attr_value_first('vxlan-local-tunnelip'),
vxlanattrs.get('local'))
self._query_check_n_update_addresses(ifaceobjcurr, 'vxlan-svcnodeip',
ifaceobj.get_attr_value('vxlan-svcnodeip'),
vxlanattrs.get('svcnode', []))
self._query_check_n_update_addresses(ifaceobjcurr, 'vxlan-peernodeip',
ifaceobj.get_attr_value('vxlan-peernodeip'),
vxlanattrs.get('peernode', []))
learning = ifaceobj.get_attr_value_first('vxlan-learning')
running_learning = vxlanattrs.get('learning')
if learning == running_learning:
ifaceobjcurr.update_config_with_status('vxlan-learning',
running_learning, 0)
else:
ifaceobjcurr.update_config_with_status('vxlan-learning',
running_learning, 1)
def _query_running(self, ifaceobjrunning):
# Not implemented
return
vxlanattrs = self.ipcmd.get_vxlandev_attrs(ifaceobjrunning.name)
if not vxlanattrs:
return
ifaceobjrunning.update_config('vxlan-id', vxlanattrs.get('vxlanid'))
attrval = vxlanattrs.get('local')
if attrval:
ifaceobjrunning.update_config('vxlan-local-tunnelip', attrval)
attrval = vxlanattrs.get('svcnode')
if attrval:
[ifaceobjrunning.update_config('vxlan-svcnode', a)
for a in attrval]
attrval = vxlanattrs.get('peernode')
if attrval:
[ifaceobjrunning.update_config('vxlan-peernode', a)
for a in attrval]
attrval = vxlanattrs.get('learning')
if attrval and attrval == 'on':
ifaceobjrunning.update_config('vxlan-learning', 'on')
_run_ops = {'pre-up' : _up,
'post-down' : _down,