Commit 0fcc5db3 authored by Guido Trotter's avatar Guido Trotter
Browse files

LURebootInstance: move arg check in ExpandNames

The check for the reboot type can be done without any locks held, so
we'll move it to ExpandNames. Plus, we note in a FIXME that if the
reboot type is not full, we can probably just lock the primary node, and
leave the secondary unlocked.

Reviewed-by: imsnah
parent 8c4a9a74
......@@ -2070,12 +2070,20 @@ class LURebootInstance(LogicalUnit):
REQ_BGL = False
def ExpandNames(self):
if self.op.reboot_type not in [constants.INSTANCE_REBOOT_SOFT,
constants.INSTANCE_REBOOT_HARD,
constants.INSTANCE_REBOOT_FULL]:
raise errors.ParameterError("reboot type not in [%s, %s, %s]" %
(constants.INSTANCE_REBOOT_SOFT,
constants.INSTANCE_REBOOT_HARD,
constants.INSTANCE_REBOOT_FULL))
self._ExpandAndLockInstance()
self.needed_locks[locking.LEVEL_NODE] = []
self.recalculate_locks[locking.LEVEL_NODE] = 'replace'
def DeclareLocks(self, level):
if level == locking.LEVEL_NODE:
# FIXME: lock only primary on (not constants.INSTANCE_REBOOT_FULL)
self._LockInstancesNodes()
def BuildHooksEnv(self):
......@@ -2116,14 +2124,6 @@ class LURebootInstance(LogicalUnit):
node_current = instance.primary_node
if reboot_type not in [constants.INSTANCE_REBOOT_SOFT,
constants.INSTANCE_REBOOT_HARD,
constants.INSTANCE_REBOOT_FULL]:
raise errors.ParameterError("reboot type not in [%s, %s, %s]" %
(constants.INSTANCE_REBOOT_SOFT,
constants.INSTANCE_REBOOT_HARD,
constants.INSTANCE_REBOOT_FULL))
if reboot_type in [constants.INSTANCE_REBOOT_SOFT,
constants.INSTANCE_REBOOT_HARD]:
if not rpc.call_instance_reboot(node_current, instance,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment