from ganeti import errors
from ganeti import rpc
from ganeti import cmdlib
-from ganeti import config
from ganeti import ssconf
from ganeti import logger
from ganeti import locking
given LU and its opcodes.
"""
- if level in lu.needed_locks:
+ if level not in locking.LEVELS:
+ result = self._ExecLU(lu)
+ elif level in lu.needed_locks:
# This gives a chance to LUs to make last-minute changes after acquiring
# locks at any preceding level.
lu.DeclareLocks(level)
share = lu.share_locks[level]
# This is always safe to do, as we can't acquire more/less locks than
# what was requested.
- lu.needed_locks[level] = self.context.glm.acquire(level,
- needed_locks,
- shared=share)
+ lu.acquired_locks[level] = self.context.glm.acquire(level,
+ needed_locks,
+ shared=share)
try:
result = self._LockAndExecLU(lu, level + 1)
finally:
- if lu.needed_locks[level]:
+ # We need to release the current level if we acquired any lock, or if
+ # we acquired the set-lock (needed_locks is None)
+ if lu.needed_locks[level] is None or lu.acquired_locks[level]:
self.context.glm.release(level)
else:
- result = self._ExecLU(lu)
+ result = self._LockAndExecLU(lu, level + 1)
return result
return result
- def ChainOpCode(self, op):
- """Chain and execute an opcode.
-
- This is used by LUs when they need to execute a child LU.
-
- Args:
- - opcode: the opcode to be executed
-
- """
- if not isinstance(op, opcodes.OpCode):
- raise errors.ProgrammerError("Non-opcode instance passed"
- " to ExecOpcode")
-
- lu_class = self.DISPATCH_TABLE.get(op.__class__, None)
- if lu_class is None:
- raise errors.OpCodeUnknown("Unknown opcode")
-
- if lu_class.REQ_BGL and not self.exclusive_BGL:
- raise errors.ProgrammerError("LUs which require the BGL cannot"
- " be chained to granular ones.")
-
- if lu_class.REQ_WSSTORE:
- sstore = ssconf.WritableSimpleStore()
- else:
- sstore = ssconf.SimpleStore()
-
- #do_hooks = lu_class.HPATH is not None
- lu = lu_class(self, op, self.context, sstore)
- lu.CheckPrereq()
- #if do_hooks:
- # hm = HooksMaster(rpc.call_hooks_runner, self, lu)
- # h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE)
- # lu.HooksCallBack(constants.HOOKS_PHASE_PRE,
- # h_results, self._feedback_fn, None)
- result = lu.Exec(self._feedback_fn)
- #if do_hooks:
- # h_results = hm.RunPhase(constants.HOOKS_PHASE_POST)
- # result = lu.HooksCallBack(constants.HOOKS_PHASE_POST,
- # h_results, self._feedback_fn, result)
- return result
-
def LogStep(self, current, total, message):
"""Log a change in LU execution progress.