diff --git a/pkg/iface.py b/pkg/iface.py index 14eccd3..4917fc9 100644 --- a/pkg/iface.py +++ b/pkg/iface.py @@ -291,17 +291,21 @@ class iface(): else: return _tickmark - def is_different(self, dstiface): - if self.name != dstiface.name: return True - if self.addr_family != dstiface.addr_family: return True - if self.addr_method != dstiface.addr_method: return True - if self.auto != dstiface.auto: return True - if self.classes != dstiface.classes: return True + def compare(self, dstiface): + """ Compares two objects + + Returns True if object self is same as dstiface and False otherwise """ + + if self.name != dstiface.name: return False + if self.addr_family != dstiface.addr_family: return False + if self.addr_method != dstiface.addr_method: return False + if self.auto != dstiface.auto: return False + if self.classes != dstiface.classes: return False if any(True for k in self.config if k not in dstiface.config): - return True + return False if any(True for k,v in self.config.items() - if v != dstiface.config.get(k)): return True - return False + if v != dstiface.config.get(k)): return False + return True def __getstate__(self): odict = self.__dict__.copy() diff --git a/pkg/ifupdownmain.py b/pkg/ifupdownmain.py index eb702af..ddc4e17 100644 --- a/pkg/ifupdownmain.py +++ b/pkg/ifupdownmain.py @@ -803,7 +803,7 @@ class ifupdownMain(ifupdownBase): for objidx in range(0, len(lastifaceobjlist)): oldobj = lastifaceobjlist[objidx] newobj = newifaceobjlist[objidx] - if newobj.is_different(oldobj): + if not newobj.compare(oldobj): ifacedownlist.append(ifname) continue diff --git a/pkg/scheduler.py b/pkg/scheduler.py index 264a840..0767435 100644 --- a/pkg/scheduler.py +++ b/pkg/scheduler.py @@ -118,7 +118,12 @@ class ifaceScheduler(): followdependents=False): """ Check if conflicting upper ifaces are around and warn if required - Returns False if this interface needs to be skipped, else return True """ + Returns False if this interface needs to be skipped, + else return True """ + + # XXX: simply return for now, the warnings this function prints + # are very confusing. Get rid of this function soon + return True if 'up' in ops[0] and followdependents: return True @@ -161,8 +166,8 @@ class ifaceScheduler(): raise Exception('%s: not found' %ifacename) for ifaceobj in ifaceobjs: - if not cls._check_upperifaces(ifupdownobj, ifaceobj, ops, parent, - followdependents): + if not cls._check_upperifaces(ifupdownobj, ifaceobj, + ops, parent, followdependents): return if order == ifaceSchedulerFlags.INORDER: # If inorder, run the iface first and then its dependents @@ -300,10 +305,17 @@ class ifaceScheduler(): """ if not ifupdownobj.ALL or not followdependents or len(ifacenames) == 1: + # If there is any interface that does exist, maybe it is a + # logical interface and we have to followupperifaces + followupperifaces = (True if + [i for i in ifacenames + if not ifupdownobj.link_exists(i)] + else False) cls.run_iface_list(ifupdownobj, ifacenames, ops, parent=None,order=order, followdependents=followdependents) - if not ifupdownobj.ALL and followdependents and 'up' in ops[0]: + if (not ifupdownobj.ALL and + (followdependents or followupperifaces) and 'up' in ops[0]): # If user had given a set of interfaces to bring up # try and execute 'up' on the upperifaces ifupdownobj.logger.info('running upperifaces if available') diff --git a/pkg/statemanager.py b/pkg/statemanager.py index 6a08d6f..46747c5 100644 --- a/pkg/statemanager.py +++ b/pkg/statemanager.py @@ -75,6 +75,13 @@ class stateManager(): if not old_ifaceobjs: self.ifaceobjdict[ifaceobj.name] = [ifaceobj] else: + # If it matches any of the object, return + if any(o.compare(ifaceobj) for o in old_ifaceobjs): + return + # If it does not match any of the objects, and if + # all objs in the list came from the pickled file, + # then reset the list and add this object as a fresh one, + # else append to the list if old_ifaceobjs[0].flags & iface._PICKLED: del self.ifaceobjdict[ifaceobj.name] self.ifaceobjdict[ifaceobj.name] = [ifaceobj]