mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
skip adding filtered or blacklisted interfaces in the dependency graph
Ticket: Reviewed By: CCR-3043 Testing Done: This was resulting in lower interfaces not being brought up at boot when their upper-ifaces were not-marked auto. And this was because the dependency graph continued to have the non-auto upper interfaces and the whole tree was ignored by the scheduler. This fix eliminates filtered interfaces from the dependency graph to simplify the scheduler and also to avoid scheduler picking up non-auto (or non-class interfaces). testcase (Without this patch swp1 was skipped at boot) iface swp1.100 auto swp1 iface swp1
This commit is contained in:
@@ -286,6 +286,7 @@ class iface():
|
||||
# The below attribute is used to disambiguate between various
|
||||
# types of dependencies
|
||||
self.dependency_type = ifaceDependencyType.UNKNOWN
|
||||
self.blacklisted = False
|
||||
|
||||
def _set_attrs_from_dict(self, attrdict):
|
||||
self.auto = attrdict.get('auto', False)
|
||||
@@ -476,6 +477,7 @@ class iface():
|
||||
del odict['link_kind']
|
||||
del odict['role']
|
||||
del odict['dependency_type']
|
||||
del odict['blacklisted']
|
||||
return odict
|
||||
|
||||
def __setstate__(self, dict):
|
||||
@@ -497,6 +499,7 @@ class iface():
|
||||
self.link_type = ifaceLinkType.LINK_NA
|
||||
self.link_kind = ifaceLinkKind.UNKNOWN
|
||||
self.dependency_type = ifaceDependencyType.UNKNOWN
|
||||
self.blacklisted = False
|
||||
|
||||
def dump_raw(self, logger):
|
||||
indent = ' '
|
||||
|
@@ -497,6 +497,8 @@ class ifupdownMain(ifupdownBase):
|
||||
ifaceobj = self.get_ifaceobj_first(i)
|
||||
if not ifaceobj:
|
||||
continue
|
||||
if ifaceobj.blacklisted:
|
||||
continue
|
||||
dlist = ifaceobj.lowerifaces
|
||||
if not dlist:
|
||||
dlist = self.query_dependents(ifaceobj, ops, ifacenames)
|
||||
@@ -778,29 +780,45 @@ class ifupdownMain(ifupdownBase):
|
||||
interfaces are checked against the allow_classes and auto lists.
|
||||
|
||||
"""
|
||||
ret = True
|
||||
|
||||
# Check if interface matches the exclude patter
|
||||
if excludepats:
|
||||
for e in excludepats:
|
||||
if re.search(e, ifacename):
|
||||
return False
|
||||
ret = False
|
||||
ifaceobjs = self.get_ifaceobjs(ifacename)
|
||||
if not ifaceobjs:
|
||||
self.logger.debug('iface %s' %ifacename + ' not found')
|
||||
return False
|
||||
# We check classes first
|
||||
if ret:
|
||||
self.logger.debug('iface %s' %ifacename + ' not found')
|
||||
return ret
|
||||
# If matched exclude pattern, return false
|
||||
if not ret:
|
||||
for i in ifaceobjs:
|
||||
i.blacklisted = True
|
||||
return ret
|
||||
# Check if interface belongs to the class
|
||||
# the user is interested in, if not return false
|
||||
if allow_classes:
|
||||
for i in ifaceobjs:
|
||||
if i.classes:
|
||||
common = Set([allow_classes]).intersection(
|
||||
Set(i.classes))
|
||||
if common:
|
||||
return True
|
||||
return False
|
||||
ret = True
|
||||
else:
|
||||
i.blacklisted = True
|
||||
if not ret:
|
||||
return ret
|
||||
# If the user has requested auto class, check if the interface
|
||||
# is marked auto
|
||||
if auto:
|
||||
for i in ifaceobjs:
|
||||
if i.auto:
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
ret = True
|
||||
else:
|
||||
i.blacklisted = True
|
||||
return ret
|
||||
|
||||
def _compat_conv_op_to_mode(self, op):
|
||||
""" Returns old op name to work with existing scripts """
|
||||
|
Reference in New Issue
Block a user