force = self.op.force
extra_args = getattr(self.op, "extra_args", "")
+ self.cfg.MarkInstanceUp(instance.name)
+
node_current = instance.primary_node
_StartInstanceDisks(self.cfg, instance, force)
_ShutdownInstanceDisks(instance, self.cfg)
raise errors.OpExecError("Could not start instance")
- self.cfg.MarkInstanceUp(instance.name)
-
class LURebootInstance(LogicalUnit):
"""Reboot an instance.
"""
instance = self.instance
node_current = instance.primary_node
+ self.cfg.MarkInstanceDown(instance.name)
if not rpc.call_instance_shutdown(node_current, instance):
logger.Error("could not shutdown instance")
- self.cfg.MarkInstanceDown(instance.name)
_ShutdownInstanceDisks(instance, self.cfg)
lu.CheckPrereq()
hm = HooksMaster(rpc.call_hooks_runner, self, lu)
hm.RunPhase(constants.HOOKS_PHASE_PRE)
- result = lu.Exec(self._feedback_fn)
- hm.RunPhase(constants.HOOKS_PHASE_POST)
- if lu.cfg is not None:
- # we use lu.cfg and not self.cfg as for init cluster, self.cfg
- # is None but lu.cfg has been recently initialized in the
- # lu.Exec method
- if write_count != lu.cfg.write_count:
- hm.RunConfigUpdate()
+ try:
+ result = lu.Exec(self._feedback_fn)
+ hm.RunPhase(constants.HOOKS_PHASE_POST)
+ finally:
+ if lu.cfg is not None:
+ # we use lu.cfg and not self.cfg as for init cluster, self.cfg
+ # is None but lu.cfg has been recently initialized in the
+ # lu.Exec method
+ if write_count != lu.cfg.write_count:
+ hm.RunConfigUpdate()
return result