From 1104a8609efe3a30c3303c921669725d66fd6b3f Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Wed, 2 Jul 2014 10:03:02 -0700 Subject: [PATCH] exit with non-zero return code if any of the ifaces have errors Ticket: CM-2960 Reviewed By: Testing Done: ifupdown2 sanity + error cases + precommit uses a class variable to store return value --- pkg/scheduler.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/scheduler.py b/pkg/scheduler.py index 4ab7636..4f8e366 100644 --- a/pkg/scheduler.py +++ b/pkg/scheduler.py @@ -48,14 +48,15 @@ class ifaceScheduler(): _STATE_CHECK = True + _SCHED_RETVAL = True + @classmethod def run_iface_op(cls, ifupdownobj, ifaceobj, op, cenv=None): """ Runs sub operation on an interface """ ifacename = ifaceobj.name if (cls._STATE_CHECK and - (ifaceobj.state >= ifaceState.from_str(op)) and - (ifaceobj.status == ifaceStatus.SUCCESS)): + (ifaceobj.state >= ifaceState.from_str(op))): ifupdownobj.logger.debug('%s: already in state %s' %(ifacename, op)) return if not ifupdownobj.ADDONS_ENABLE: return @@ -84,6 +85,8 @@ class ifaceScheduler(): if err: ifaceobj.set_state_n_status(ifaceState.from_str(op), ifaceStatus.ERROR) + if 'up' in op or 'down' in op: + cls._SCHED_RETVAL = False else: ifaceobj.set_state_n_status(ifaceState.from_str(op), ifaceStatus.SUCCESS) @@ -423,3 +426,6 @@ class ifaceScheduler(): cls.run_iface_list_upper(ifupdownobj, ifacenames, ops, skip_root=True) cls._STATE_CHECK = True + + if not cls._SCHED_RETVAL: + raise Exception()