Revision a295eb80 lib/cmdlib/instance.py
b/lib/cmdlib/instance.py | ||
---|---|---|
1158 | 1158 |
# memory check on primary node |
1159 | 1159 |
#TODO(dynmem): use MINMEM for checking |
1160 | 1160 |
if self.op.start: |
1161 |
hvfull = objects.FillDict(cluster.hvparams.get(self.op.hypervisor, {}), |
|
1162 |
self.op.hvparams) |
|
1161 | 1163 |
CheckNodeFreeMemory(self, self.pnode.name, |
1162 | 1164 |
"creating instance %s" % self.op.instance_name, |
1163 | 1165 |
self.be_full[constants.BE_MAXMEM], |
1164 |
self.op.hypervisor) |
|
1166 |
self.op.hypervisor, hvfull)
|
|
1165 | 1167 |
|
1166 | 1168 |
self.dry_run_result = list(nodenames) |
1167 | 1169 |
|
... | ... | |
1692 | 1694 |
|
1693 | 1695 |
if instance.admin_state == constants.ADMINST_UP: |
1694 | 1696 |
# check memory requirements on the secondary node |
1695 |
CheckNodeFreeMemory(self, target_node,
|
|
1696 |
"failing over instance %s" %
|
|
1697 |
instance.name, bep[constants.BE_MAXMEM],
|
|
1698 |
instance.hypervisor)
|
|
1697 |
CheckNodeFreeMemory( |
|
1698 |
self, target_node, "failing over instance %s" %
|
|
1699 |
instance.name, bep[constants.BE_MAXMEM], instance.hypervisor,
|
|
1700 |
self.cfg.GetClusterInfo().hvparams[instance.hypervisor])
|
|
1699 | 1701 |
else: |
1700 | 1702 |
self.LogInfo("Not checking memory on the secondary node as" |
1701 | 1703 |
" instance will not be started") |
... | ... | |
1980 | 1982 |
return [(op, idx, params, fn()) for (op, idx, params) in mods] |
1981 | 1983 |
|
1982 | 1984 |
|
1983 |
def _CheckNodesPhysicalCPUs(lu, nodenames, requested, hypervisor_name):
|
|
1985 |
def _CheckNodesPhysicalCPUs(lu, nodenames, requested, hypervisor_specs):
|
|
1984 | 1986 |
"""Checks if nodes have enough physical CPUs |
1985 | 1987 |
|
1986 | 1988 |
This function checks if all given nodes have the needed number of |
... | ... | |
1994 | 1996 |
@param nodenames: the list of node names to check |
1995 | 1997 |
@type requested: C{int} |
1996 | 1998 |
@param requested: the minimum acceptable number of physical CPUs |
1999 |
@type hypervisor_specs: list of pairs (string, dict of strings) |
|
2000 |
@param hypervisor_specs: list of hypervisor specifications in |
|
2001 |
pairs (hypervisor_name, hvparams) |
|
1997 | 2002 |
@raise errors.OpPrereqError: if the node doesn't have enough CPUs, |
1998 | 2003 |
or we cannot check the node |
1999 | 2004 |
|
2000 | 2005 |
""" |
2001 |
nodeinfo = lu.rpc.call_node_info(nodenames, None, [hypervisor_name], None)
|
|
2006 |
nodeinfo = lu.rpc.call_node_info(nodenames, None, hypervisor_specs, None)
|
|
2002 | 2007 |
for node in nodenames: |
2003 | 2008 |
info = nodeinfo[node] |
2004 | 2009 |
info.Raise("Cannot get current information from node %s" % node, |
... | ... | |
2793 | 2798 |
max_requested_cpu = max(map(max, cpu_list)) |
2794 | 2799 |
# Check that all of the instance's nodes have enough physical CPUs to |
2795 | 2800 |
# satisfy the requested CPU mask |
2801 |
hvspecs = [(instance.hypervisor, |
|
2802 |
self.cfg.GetClusterInfo().hvparams[instance.hypervisor])] |
|
2796 | 2803 |
_CheckNodesPhysicalCPUs(self, instance.all_nodes, |
2797 |
max_requested_cpu + 1, instance.hypervisor) |
|
2804 |
max_requested_cpu + 1, |
|
2805 |
hvspecs) |
|
2798 | 2806 |
|
2799 | 2807 |
# osparams processing |
2800 | 2808 |
if self.op.osparams: |
... | ... | |
2811 | 2819 |
if be_new[constants.BE_AUTO_BALANCE]: |
2812 | 2820 |
# either we changed auto_balance to yes or it was from before |
2813 | 2821 |
mem_check_list.extend(instance.secondary_nodes) |
2814 |
instance_info = self.rpc.call_instance_info(pnode, instance.name, |
|
2815 |
instance.hypervisor) |
|
2822 |
instance_info = self.rpc.call_instance_info( |
|
2823 |
pnode, instance.name, instance.hypervisor, |
|
2824 |
cluster.hvparams[instance.hypervisor]) |
|
2825 |
hvspecs = [(instance.hypervisor, cluster.hvparams[instance.hypervisor])] |
|
2816 | 2826 |
nodeinfo = self.rpc.call_node_info(mem_check_list, None, |
2817 |
[instance.hypervisor], False)
|
|
2827 |
hvspecs, False)
|
|
2818 | 2828 |
pninfo = nodeinfo[pnode] |
2819 | 2829 |
msg = pninfo.fail_msg |
2820 | 2830 |
if msg: |
... | ... | |
2888 | 2898 |
|
2889 | 2899 |
delta = self.op.runtime_mem - current_memory |
2890 | 2900 |
if delta > 0: |
2891 |
CheckNodeFreeMemory(self, instance.primary_node, |
|
2892 |
"ballooning memory for instance %s" % |
|
2893 |
instance.name, delta, instance.hypervisor) |
|
2901 |
CheckNodeFreeMemory( |
|
2902 |
self, instance.primary_node, "ballooning memory for instance %s" % |
|
2903 |
instance.name, delta, instance.hypervisor, |
|
2904 |
self.cfg.GetClusterInfo().hvparams[instance.hypervisor]) |
|
2894 | 2905 |
|
2895 | 2906 |
def _PrepareNicCreate(_, params, private): |
2896 | 2907 |
self._PrepareNicModification(params, private, None, None, |
Also available in: Unified diff