Bump version to 2.5.0~rc1
[ganeti-local] / lib / mcpu.py
index 7788959..89046c6 100644 (file)
@@ -122,7 +122,7 @@ class LockAttemptTimeoutStrategy(object):
     return timeout
 
 
-class OpExecCbBase: # pylint: disable-msg=W0232
+class OpExecCbBase: # pylint: disable=W0232
   """Base class for OpCode execution callbacks.
 
   """
@@ -348,7 +348,7 @@ class Processor(object):
     """
     if not isinstance(op, opcodes.OpCode):
       raise errors.ProgrammerError("Non-opcode instance passed"
-                                   " to ExecOpcode")
+                                   " to ExecOpcode (%s)" % type(op))
 
     lu_class = self.DISPATCH_TABLE.get(op.__class__, None)
     if lu_class is None:
@@ -373,8 +373,8 @@ class Processor(object):
         assert lu.needed_locks is not None, "needed_locks not set by LU"
 
         try:
-          return self._LockAndExecLU(lu, locking.LEVEL_INSTANCE, calc_timeout,
-                                     priority)
+          result = self._LockAndExecLU(lu, locking.LEVEL_INSTANCE, calc_timeout,
+                                       priority)
         finally:
           if self._ec_id:
             self.context.cfg.DropECReservations(self._ec_id)
@@ -383,6 +383,15 @@ class Processor(object):
     finally:
       self._cbs = None
 
+    resultcheck_fn = op.OP_RESULT
+    if not (resultcheck_fn is None or resultcheck_fn(result)):
+      logging.error("Expected opcode result matching %s, got %s",
+                    resultcheck_fn, result)
+      raise errors.OpResultError("Opcode result does not match %s" %
+                                 resultcheck_fn)
+
+    return result
+
   def Log(self, *args):
     """Forward call to feedback callback function.