Revision b6aaf437 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
7244 | 7244 |
cleanup=False, |
7245 | 7245 |
failover=True, |
7246 | 7246 |
ignore_consistency=ignore_consistency, |
7247 |
shutdown_timeout=shutdown_timeout) |
|
7247 |
shutdown_timeout=shutdown_timeout, |
|
7248 |
ignore_ipolicy=self.op.ignore_ipolicy) |
|
7248 | 7249 |
self.tasklets = [self._migrater] |
7249 | 7250 |
|
7250 | 7251 |
def DeclareLocks(self, level): |
... | ... | |
7644 | 7645 |
and target node |
7645 | 7646 |
@type shutdown_timeout: int |
7646 | 7647 |
@ivar shutdown_timeout: In case of failover timeout of the shutdown |
7648 |
@type ignore_ipolicy: bool |
|
7649 |
@ivar ignore_ipolicy: If true, we can ignore instance policy when migrating |
|
7647 | 7650 |
|
7648 | 7651 |
""" |
7649 | 7652 |
|
... | ... | |
7654 | 7657 |
def __init__(self, lu, instance_name, cleanup=False, |
7655 | 7658 |
failover=False, fallback=False, |
7656 | 7659 |
ignore_consistency=False, |
7657 |
shutdown_timeout=constants.DEFAULT_SHUTDOWN_TIMEOUT): |
|
7660 |
shutdown_timeout=constants.DEFAULT_SHUTDOWN_TIMEOUT, |
|
7661 |
ignore_ipolicy=False): |
|
7658 | 7662 |
"""Initializes this class. |
7659 | 7663 |
|
7660 | 7664 |
""" |
... | ... | |
7668 | 7672 |
self.fallback = fallback |
7669 | 7673 |
self.ignore_consistency = ignore_consistency |
7670 | 7674 |
self.shutdown_timeout = shutdown_timeout |
7675 |
self.ignore_ipolicy = ignore_ipolicy |
|
7671 | 7676 |
|
7672 | 7677 |
def CheckPrereq(self): |
7673 | 7678 |
"""Check prerequisites. |
... | ... | |
7679 | 7684 |
instance = self.cfg.GetInstanceInfo(instance_name) |
7680 | 7685 |
assert instance is not None |
7681 | 7686 |
self.instance = instance |
7687 |
cluster = self.cfg.GetClusterInfo() |
|
7682 | 7688 |
|
7683 | 7689 |
if (not self.cleanup and |
7684 | 7690 |
not instance.admin_state == constants.ADMINST_UP and |
... | ... | |
7706 | 7712 |
# BuildHooksEnv |
7707 | 7713 |
self.target_node = self.lu.op.target_node |
7708 | 7714 |
|
7715 |
# Check that the target node is correct in terms of instance policy |
|
7716 |
nodeinfo = self.cfg.GetNodeInfo(self.target_node) |
|
7717 |
ipolicy = _CalculateGroupIPolicy(cluster, nodeinfo.group) |
|
7718 |
_CheckTargetNodeIPolicy(self.lu, ipolicy, instance, nodeinfo, |
|
7719 |
ignore=self.ignore_ipolicy) |
|
7720 |
|
|
7709 | 7721 |
# self.target_node is already populated, either directly or by the |
7710 | 7722 |
# iallocator run |
7711 | 7723 |
target_node = self.target_node |
... | ... | |
7739 | 7751 |
" node can be passed)" % |
7740 | 7752 |
(instance.disk_template, text), |
7741 | 7753 |
errors.ECODE_INVAL) |
7754 |
nodeinfo = self.cfg.GetNodeInfo(target_node) |
|
7755 |
ipolicy = _CalculateGroupIPolicy(cluster, nodeinfo.group) |
|
7756 |
_CheckTargetNodeIPolicy(self.lu, ipolicy, instance, nodeinfo, |
|
7757 |
ignore=self.ignore_ipolicy) |
|
7742 | 7758 |
|
7743 |
i_be = self.cfg.GetClusterInfo().FillBE(instance)
|
|
7759 |
i_be = cluster.FillBE(instance)
|
|
7744 | 7760 |
|
7745 | 7761 |
# check memory requirements on the secondary node |
7746 | 7762 |
if not self.failover or instance.admin_state == constants.ADMINST_UP: |
... | ... | |
7796 | 7812 |
self.lu.op.live = None |
7797 | 7813 |
elif self.lu.op.mode is None: |
7798 | 7814 |
# read the default value from the hypervisor |
7799 |
i_hv = self.cfg.GetClusterInfo().FillHV(self.instance, |
|
7800 |
skip_globals=False) |
|
7815 |
i_hv = cluster.FillHV(self.instance, skip_globals=False) |
|
7801 | 7816 |
self.lu.op.mode = i_hv[constants.HV_MIGRATION_MODE] |
7802 | 7817 |
|
7803 | 7818 |
self.live = self.lu.op.mode == constants.HT_MIGRATION_LIVE |
... | ... | |
7809 | 7824 |
"""Run the allocator based on input opcode. |
7810 | 7825 |
|
7811 | 7826 |
""" |
7827 |
# FIXME: add a self.ignore_ipolicy option |
|
7812 | 7828 |
ial = IAllocator(self.cfg, self.rpc, |
7813 | 7829 |
mode=constants.IALLOCATOR_MODE_RELOC, |
7814 | 7830 |
name=self.instance_name, |
Also available in: Unified diff