def ExecOpCode(self, op, cbs, timeout=None):
    if not isinstance(op, opcodes.OpCode):
      raise errors.ProgrammerError("Non-opcode instance passed"
                                   " to ExecOpcode (%s)" % type(op))

    lu_class = self.DISPATCH_TABLE.get(op.__class__, None)
    if lu_class is None:
      raise errors.OpCodeUnknown("Unknown opcode")

    if timeout is None:
      calc_timeout = lambda: None
    else:
      calc_timeout = utils.RunningTimeout(timeout, False).Remaining

    self._cbs = cbs
    try:
      result = self._PrepareLockListsAndExecLU(op, lu_class, calc_timeout)

      # The post hooks below are always executed with a SUCCESS status because
      # all the possible errors during pre hooks and LU execution cause
      # exception and therefore the statement below will be skipped.
      if self._hm is not None:
        self._hm.RunPhase(constants.HOOKS_PHASE_POST, is_global=True,
                          post_status=constants.POST_HOOKS_STATUS_SUCCESS)
    except:
      # execute global post hooks with the failed status on any exception
      hooksmaster.ExecGlobalPostHooks(op.OP_ID, self.cfg.GetMasterNodeName(),
                                      self.rpc.call_hooks_runner,
                                      logging.warning,
                                      self.cfg.GetClusterName(),
                                      self.cfg.GetMasterNode(), self.GetECId(),
                                      constants.POST_HOOKS_STATUS_ERROR)
      raise

    self._CheckLUResult(op, result)
    return result
Call a switch method.
dataset/ETHPy150Open ganeti/ganeti/lib/mcpu.py/Processor.ExecOpCode--crossover with--dataset/ETHPy150Open DerMitch/fritzbox-smarthome/fritzhome/fritz.py/FritzBox.homeautoswitch