diff --git a/ifupdown/ifupdownmain.py b/ifupdown/ifupdownmain.py index 416cfdb..3d01704 100644 --- a/ifupdown/ifupdownmain.py +++ b/ifupdown/ifupdownmain.py @@ -236,6 +236,21 @@ class ifupdownMain(ifupdownBase): else: self._link_master_slave = False + def link_master_slave_ignore_error(self, errorstr): + # If link master slave flag is set, + # there may be cases where the lowerdev may not be + # up resulting in 'Network is down' error + # This can happen if the lowerdev is a LINK_SLAVE + # of another interface which is not up yet + # example of such a case: + # bringing up a vlan on a bond interface and the bond + # is a LINK_SLAVE of a bridge (in other words the bond is + # part of a bridge) which is not up yet + if self._link_master_slave: + if 'Network is down': + return True + return False + def get_ifaceobjs(self, ifacename): return self.ifaceobjdict.get(ifacename) diff --git a/ifupdown/scheduler.py b/ifupdown/scheduler.py index 794c552..4b4bb57 100644 --- a/ifupdown/scheduler.py +++ b/ifupdown/scheduler.py @@ -136,8 +136,9 @@ class ifaceScheduler(): try: handler(ifupdownobj, ifaceobjs[0]) except Exception, e: - ifupdownobj.logger.warn('%s: %s' - %(ifaceobjs[0].name, str(e))) + if not ifupdownobj.link_master_slave_ignore_error(str(e)): + ifupdownobj.logger.warn('%s: %s' + %(ifaceobjs[0].name, str(e))) pass for ifaceobj in ifaceobjs: cls.run_iface_op(ifupdownobj, ifaceobj, op, diff --git a/ifupdownaddons/iproute2.py b/ifupdownaddons/iproute2.py index b2111a1..6d6f0db 100644 --- a/ifupdownaddons/iproute2.py +++ b/ifupdownaddons/iproute2.py @@ -368,7 +368,7 @@ class iproute2(utilsBase): def link_set_hwaddress(self, ifacename, hwaddress, force=False): if not force: if self._cache_check('link', [ifacename, 'hwaddress'], hwaddress): - return + return self.link_down(ifacename) cmd = 'link set dev %s address %s' %(ifacename, hwaddress) if self.ipbatch: