Revision e71b9ef4 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
232 | 232 |
#: a required node name (for single-node LUs) |
233 | 233 |
_PNodeName = ("node_name", _NoDefault, _TNonEmptyString) |
234 | 234 |
|
235 |
#: the migration type (live/non-live) |
|
236 |
_PMigrationLive = ("live", None, _TOr(_TNone, |
|
237 |
_TElemOf(constants.HT_MIGRATION_TYPES))) |
|
238 |
|
|
235 | 239 |
|
236 | 240 |
# End types |
237 | 241 |
class LogicalUnit(object): |
... | ... | |
5486 | 5490 |
HTYPE = constants.HTYPE_INSTANCE |
5487 | 5491 |
_OP_PARAMS = [ |
5488 | 5492 |
_PInstanceName, |
5489 |
("live", True, _TBool),
|
|
5493 |
_PMigrationLive,
|
|
5490 | 5494 |
("cleanup", False, _TBool), |
5491 | 5495 |
] |
5492 | 5496 |
|
... | ... | |
5499 | 5503 |
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE |
5500 | 5504 |
|
5501 | 5505 |
self._migrater = TLMigrateInstance(self, self.op.instance_name, |
5502 |
self.op.live, self.op.cleanup)
|
|
5506 |
self.op.cleanup) |
|
5503 | 5507 |
self.tasklets = [self._migrater] |
5504 | 5508 |
|
5505 | 5509 |
def DeclareLocks(self, level): |
... | ... | |
5717 | 5721 |
HTYPE = constants.HTYPE_NODE |
5718 | 5722 |
_OP_PARAMS = [ |
5719 | 5723 |
_PNodeName, |
5720 |
("live", False, _TBool),
|
|
5724 |
_PMigrationLive,
|
|
5721 | 5725 |
] |
5722 | 5726 |
REQ_BGL = False |
5723 | 5727 |
|
... | ... | |
5738 | 5742 |
logging.debug("Migrating instance %s", inst.name) |
5739 | 5743 |
names.append(inst.name) |
5740 | 5744 |
|
5741 |
tasklets.append(TLMigrateInstance(self, inst.name, self.op.live, False))
|
|
5745 |
tasklets.append(TLMigrateInstance(self, inst.name, False)) |
|
5742 | 5746 |
|
5743 | 5747 |
self.tasklets = tasklets |
5744 | 5748 |
|
... | ... | |
5765 | 5769 |
|
5766 | 5770 |
|
5767 | 5771 |
class TLMigrateInstance(Tasklet): |
5768 |
def __init__(self, lu, instance_name, live, cleanup):
|
|
5772 |
def __init__(self, lu, instance_name, cleanup): |
|
5769 | 5773 |
"""Initializes this class. |
5770 | 5774 |
|
5771 | 5775 |
""" |
... | ... | |
5773 | 5777 |
|
5774 | 5778 |
# Parameters |
5775 | 5779 |
self.instance_name = instance_name |
5776 |
self.live = live |
|
5777 | 5780 |
self.cleanup = cleanup |
5781 |
self.live = False # will be overridden later |
|
5778 | 5782 |
|
5779 | 5783 |
def CheckPrereq(self): |
5780 | 5784 |
"""Check prerequisites. |
... | ... | |
5815 | 5819 |
|
5816 | 5820 |
self.instance = instance |
5817 | 5821 |
|
5822 |
if self.lu.op.live is None: |
|
5823 |
# read the default value from the hypervisor |
|
5824 |
i_hv = self.cfg.GetClusterInfo().FillHV(instance, skip_globals=False) |
|
5825 |
self.lu.op.live = i_hv[constants.HV_MIGRATION_TYPE] |
|
5826 |
|
|
5827 |
self.live = self.lu.op.live == constants.HT_MIGRATION_LIVE |
|
5828 |
|
|
5818 | 5829 |
def _WaitUntilSync(self): |
5819 | 5830 |
"""Poll with custom rpc for disk sync. |
5820 | 5831 |
|
Also available in: Unified diff