Revision 6657590e lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
4519 | 4519 |
HPATH = "instance-export" |
4520 | 4520 |
HTYPE = constants.HTYPE_INSTANCE |
4521 | 4521 |
_OP_REQP = ["instance_name", "target_node", "shutdown"] |
4522 |
REQ_BGL = False |
|
4523 |
|
|
4524 |
def ExpandNames(self): |
|
4525 |
self._ExpandAndLockInstance() |
|
4526 |
# FIXME: lock only instance primary and destination node |
|
4527 |
# |
|
4528 |
# Sad but true, for now we have do lock all nodes, as we don't know where |
|
4529 |
# the previous export might be, and and in this LU we search for it and |
|
4530 |
# remove it from its current node. In the future we could fix this by: |
|
4531 |
# - making a tasklet to search (share-lock all), then create the new one, |
|
4532 |
# then one to remove, after |
|
4533 |
# - removing the removal operation altoghether |
|
4534 |
self.needed_locks[locking.LEVEL_NODE] = locking.ALL_SET |
|
4535 |
|
|
4536 |
def DeclareLocks(self, level): |
|
4537 |
"""Last minute lock declaration.""" |
|
4538 |
# All nodes are locked anyway, so nothing to do here. |
|
4522 | 4539 |
|
4523 | 4540 |
def BuildHooksEnv(self): |
4524 | 4541 |
"""Build hooks env. |
... | ... | |
4541 | 4558 |
This checks that the instance and node names are valid. |
4542 | 4559 |
|
4543 | 4560 |
""" |
4544 |
instance_name = self.cfg.ExpandInstanceName(self.op.instance_name)
|
|
4561 |
instance_name = self.op.instance_name
|
|
4545 | 4562 |
self.instance = self.cfg.GetInstanceInfo(instance_name) |
4546 |
if self.instance is None: |
|
4547 |
raise errors.OpPrereqError("Instance '%s' not found" % |
|
4548 |
self.op.instance_name) |
|
4563 |
assert self.instance is not None, \ |
|
4564 |
"Cannot retrieve locked instance %s" % self.op.instance_name |
|
4549 | 4565 |
|
4550 |
# node verification |
|
4551 |
dst_node_short = self.cfg.ExpandNodeName(self.op.target_node) |
|
4552 |
self.dst_node = self.cfg.GetNodeInfo(dst_node_short) |
|
4566 |
self.dst_node = self.cfg.GetNodeInfo( |
|
4567 |
self.cfg.ExpandNodeName(self.op.target_node)) |
|
4553 | 4568 |
|
4554 |
if self.dst_node is None: |
|
4555 |
raise errors.OpPrereqError("Destination node '%s' is unknown." % |
|
4556 |
self.op.target_node) |
|
4557 |
self.op.target_node = self.dst_node.name |
|
4569 |
assert self.dst_node is not None, \ |
|
4570 |
"Cannot retrieve locked node %s" % self.op.target_node |
|
4558 | 4571 |
|
4559 | 4572 |
# instance disk type verification |
4560 | 4573 |
for disk in self.instance.disks: |
Also available in: Unified diff