mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Fix upperiface check to not barf when --force is used
Ticket: CM-2366 Reviewed By: trivial Testing Done: Tested ifup/ifdown with bonds and bridges Also refactored some code.
This commit is contained in:
@@ -386,7 +386,6 @@ class iface():
|
|||||||
del odict['config_status']
|
del odict['config_status']
|
||||||
del odict['flags']
|
del odict['flags']
|
||||||
del odict['priv_flags']
|
del odict['priv_flags']
|
||||||
del odict['upperifaces']
|
|
||||||
del odict['raw_lines']
|
del odict['raw_lines']
|
||||||
del odict['linkstate']
|
del odict['linkstate']
|
||||||
del odict['env']
|
del odict['env']
|
||||||
@@ -400,7 +399,6 @@ class iface():
|
|||||||
self.refcnt = 0
|
self.refcnt = 0
|
||||||
self.flags = 0
|
self.flags = 0
|
||||||
self.lowerifaces = None
|
self.lowerifaces = None
|
||||||
self.upperifaces = None
|
|
||||||
self.linkstate = None
|
self.linkstate = None
|
||||||
self.env = None
|
self.env = None
|
||||||
self.priv_flags = 0
|
self.priv_flags = 0
|
||||||
|
|||||||
@@ -109,36 +109,33 @@ class ifaceScheduler():
|
|||||||
if posthookfunc:
|
if posthookfunc:
|
||||||
posthookfunc(ifupdownobj, ifaceobj)
|
posthookfunc(ifupdownobj, ifaceobj)
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_iface_graph(cls, ifupdownobj, ifacename, ops, parent=None,
|
def _check_upperifaces(cls, ifupdownobj, ifaceobj, ops, parent):
|
||||||
order=ifaceSchedulerFlags.POSTORDER,
|
""" Check if conflicting upper ifaces are around and warn if required
|
||||||
followdependents=True):
|
|
||||||
""" runs interface by traversing all nodes rooted at itself """
|
|
||||||
|
|
||||||
|
Returns False if this interface needs to be skipped, else return True """
|
||||||
|
|
||||||
# Each ifacename can have a list of iface objects
|
ifacename = ifaceobj.get_name()
|
||||||
ifaceobjs = ifupdownobj.get_ifaceobjs(ifacename)
|
|
||||||
if not ifaceobjs:
|
|
||||||
raise Exception('%s: not found' %ifacename)
|
|
||||||
|
|
||||||
for ifaceobj in ifaceobjs:
|
|
||||||
# Deal with upperdevs first
|
# Deal with upperdevs first
|
||||||
ulist = ifaceobj.get_upperifaces()
|
ulist = ifaceobj.get_upperifaces()
|
||||||
if ulist:
|
if ulist:
|
||||||
tmpulist = ([u for u in ulist if u != parent] if parent
|
tmpulist = ([u for u in ulist if u != parent] if parent
|
||||||
else ulist)
|
else ulist)
|
||||||
if tmpulist:
|
if not tmpulist:
|
||||||
|
ifupdownobj.logger.info('Roopa: tmpulist = %s' %str(tmpulist))
|
||||||
|
return True
|
||||||
if 'down' in ops[0]:
|
if 'down' in ops[0]:
|
||||||
# XXX: This is expensive. Find a cheaper way to do this
|
# XXX: This is expensive. Find a cheaper way to do this
|
||||||
# if any of the upperdevs are present,
|
# if any of the upperdevs are present,
|
||||||
# dont down this interface
|
# dont down this interface
|
||||||
for u in tmpulist:
|
for u in tmpulist:
|
||||||
if ifupdownobj.link_exists(u):
|
if ifupdownobj.link_exists(u):
|
||||||
if not ifupdownobj.ALL:
|
if not ifupdownobj.FORCE and not ifupdownobj.ALL:
|
||||||
ifupdownobj.logger.warn('%s: ' %ifacename +
|
ifupdownobj.logger.warn('%s: ' %ifacename +
|
||||||
' skip interface down,' +
|
' skip interface down,' +
|
||||||
' upperiface %s still around' %u)
|
' upperiface %s still around' %u)
|
||||||
return
|
return False
|
||||||
elif 'up' in ops[0] and not ifupdownobj.ALL:
|
elif 'up' in ops[0] and not ifupdownobj.ALL:
|
||||||
# For 'up', just warn that there is an upperdev which is
|
# For 'up', just warn that there is an upperdev which is
|
||||||
# probably not up
|
# probably not up
|
||||||
@@ -146,7 +143,22 @@ class ifaceScheduler():
|
|||||||
if not ifupdownobj.link_exists(u):
|
if not ifupdownobj.link_exists(u):
|
||||||
ifupdownobj.logger.warn('%s: upper iface %s '
|
ifupdownobj.logger.warn('%s: upper iface %s '
|
||||||
%(ifacename, u) + 'does not exist')
|
%(ifacename, u) + 'does not exist')
|
||||||
|
return True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def run_iface_graph(cls, ifupdownobj, ifacename, ops, parent=None,
|
||||||
|
order=ifaceSchedulerFlags.POSTORDER,
|
||||||
|
followdependents=True):
|
||||||
|
""" runs interface by traversing all nodes rooted at itself """
|
||||||
|
|
||||||
|
# Each ifacename can have a list of iface objects
|
||||||
|
ifaceobjs = ifupdownobj.get_ifaceobjs(ifacename)
|
||||||
|
if not ifaceobjs:
|
||||||
|
raise Exception('%s: not found' %ifacename)
|
||||||
|
|
||||||
|
for ifaceobj in ifaceobjs:
|
||||||
|
if not cls._check_upperifaces(ifupdownobj, ifaceobj, ops, parent):
|
||||||
|
return
|
||||||
if order == ifaceSchedulerFlags.INORDER:
|
if order == ifaceSchedulerFlags.INORDER:
|
||||||
# If inorder, run the iface first and then its dependents
|
# If inorder, run the iface first and then its dependents
|
||||||
cls.run_iface_ops(ifupdownobj, ifaceobj, ops)
|
cls.run_iface_ops(ifupdownobj, ifaceobj, ops)
|
||||||
|
|||||||
Reference in New Issue
Block a user