from ganeti import utils
from ganeti.masterd import iallocator
from ganeti.cmdlib.base import NoHooksLU
-from ganeti.cmdlib.common import ExpandInstanceName, GetWantedNodes, \
+from ganeti.cmdlib.common import ExpandInstanceUuidAndName, GetWantedNodes, \
GetWantedInstances
# _GetWantedNodes can be used here, but is not always appropriate to use
# this way in ExpandNames. Check LogicalUnit.ExpandNames docstring for
# more information.
- self.op.on_nodes = GetWantedNodes(self, self.op.on_nodes)
- self.needed_locks[locking.LEVEL_NODE].extend(self.op.on_nodes)
+ (self.op.on_node_uuids, self.op.on_nodes) = \
+ GetWantedNodes(self, self.op.on_nodes)
+ self.needed_locks[locking.LEVEL_NODE].extend(self.op.on_node_uuids)
if self.op.on_master:
# The node lock should be acquired for the master as well.
if self.op.on_master:
if not utils.TestDelay(self.op.duration):
raise errors.OpExecError("Error during master delay test")
- if self.op.on_nodes:
- result = self.rpc.call_test_delay(self.op.on_nodes, self.op.duration)
- for node, node_result in result.items():
- node_result.Raise("Failure during rpc call to node %s" % node)
+ if self.op.on_node_uuids:
+ result = self.rpc.call_test_delay(self.op.on_node_uuids, self.op.duration)
+ for node_uuid, node_result in result.items():
+ node_result.Raise("Failure during rpc call to node %s" %
+ self.cfg.GetNodeName(node_uuid))
def Exec(self, feedback_fn):
"""Execute the test delay opcode, with the wanted repetitions.
if not hasattr(self.op, attr):
raise errors.OpPrereqError("Missing attribute '%s' on opcode input" %
attr, errors.ECODE_INVAL)
- iname = self.cfg.ExpandInstanceName(self.op.name)
+ (self.inst_uuid, iname) = self.cfg.ExpandInstanceName(self.op.name)
if iname is not None:
raise errors.OpPrereqError("Instance '%s' already in the cluster" %
iname, errors.ECODE_EXISTS)
if self.op.hypervisor is None:
self.op.hypervisor = self.cfg.GetHypervisorType()
elif self.op.mode == constants.IALLOCATOR_MODE_RELOC:
- fname = ExpandInstanceName(self.cfg, self.op.name)
+ (fuuid, fname) = ExpandInstanceUuidAndName(self.cfg, None, self.op.name)
self.op.name = fname
- self.relocate_from = \
- list(self.cfg.GetInstanceInfo(fname).secondary_nodes)
+ self.relocate_from_node_uuids = \
+ list(self.cfg.GetInstanceInfo(fuuid).secondary_nodes)
elif self.op.mode in (constants.IALLOCATOR_MODE_CHG_GROUP,
constants.IALLOCATOR_MODE_NODE_EVAC):
if not self.op.instances:
raise errors.OpPrereqError("Missing instances", errors.ECODE_INVAL)
- self.op.instances = GetWantedInstances(self, self.op.instances)
+ (_, self.op.instances) = GetWantedInstances(self, self.op.instances)
else:
raise errors.OpPrereqError("Invalid test allocator mode '%s'" %
self.op.mode, errors.ECODE_INVAL)
hypervisor=self.op.hypervisor,
node_whitelist=None)
elif self.op.mode == constants.IALLOCATOR_MODE_RELOC:
- req = iallocator.IAReqRelocate(name=self.op.name,
- relocate_from=list(self.relocate_from))
+ req = iallocator.IAReqRelocate(
+ inst_uuid=self.inst_uuid,
+ relocate_from_node_uuids=list(self.relocate_from_node_uuids))
elif self.op.mode == constants.IALLOCATOR_MODE_CHG_GROUP:
req = iallocator.IAReqGroupChange(instances=self.op.instances,
target_groups=self.op.target_groups)