Revision 070e998b lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
1999 | 1999 |
self.cfg.GetHypervisorType()) |
2000 | 2000 |
for name in nodenames: |
2001 | 2001 |
nodeinfo = node_data[name] |
2002 |
if not nodeinfo.failed and nodeinfo.data:
|
|
2003 |
nodeinfo = nodeinfo.data
|
|
2002 |
if not nodeinfo.RemoteFailMsg() and nodeinfo.payload:
|
|
2003 |
nodeinfo = nodeinfo.payload
|
|
2004 | 2004 |
fn = utils.TryConvert |
2005 | 2005 |
live_data[name] = { |
2006 | 2006 |
"mtotal": fn(int, nodeinfo.get('memory_total', None)), |
... | ... | |
2833 | 2833 |
|
2834 | 2834 |
""" |
2835 | 2835 |
nodeinfo = lu.rpc.call_node_info([node], lu.cfg.GetVGName(), hypervisor_name) |
2836 |
nodeinfo[node].Raise() |
|
2837 |
free_mem = nodeinfo[node].data.get('memory_free') |
|
2836 |
msg = nodeinfo[node].RemoteFailMsg() |
|
2837 |
if msg: |
|
2838 |
raise errors.OpPrereqError("Can't get data from node %s: %s" % (node, msg)) |
|
2839 |
free_mem = nodeinfo[node].payload.get('memory_free', None) |
|
2838 | 2840 |
if not isinstance(free_mem, int): |
2839 | 2841 |
raise errors.OpPrereqError("Can't compute free memory on node %s, result" |
2840 |
" was '%s'" % (node, free_mem)) |
|
2842 |
" was '%s'" % (node, free_mem))
|
|
2841 | 2843 |
if requested > free_mem: |
2842 | 2844 |
raise errors.OpPrereqError("Not enough memory on node %s for %s:" |
2843 |
" needed %s MiB, available %s MiB" % |
|
2844 |
(node, reason, requested, free_mem)) |
|
2845 |
" needed %s MiB, available %s MiB" %
|
|
2846 |
(node, reason, requested, free_mem))
|
|
2845 | 2847 |
|
2846 | 2848 |
|
2847 | 2849 |
class LUStartupInstance(LogicalUnit): |
... | ... | |
4813 | 4815 |
self.op.hypervisor) |
4814 | 4816 |
for node in nodenames: |
4815 | 4817 |
info = nodeinfo[node] |
4816 |
info.Raise() |
|
4817 |
info = info.data |
|
4818 |
if not info: |
|
4818 |
msg = info.RemoteFailMsg() |
|
4819 |
if msg: |
|
4819 | 4820 |
raise errors.OpPrereqError("Cannot get current information" |
4820 |
" from node '%s'" % node) |
|
4821 |
" from node %s: %s" % (node, msg)) |
|
4822 |
info = info.payload |
|
4821 | 4823 |
vg_free = info.get('vg_free', None) |
4822 | 4824 |
if not isinstance(vg_free, int): |
4823 | 4825 |
raise errors.OpPrereqError("Can't compute free disk space on" |
4824 | 4826 |
" node %s" % node) |
4825 |
if req_size > info['vg_free']:
|
|
4827 |
if req_size > vg_free:
|
|
4826 | 4828 |
raise errors.OpPrereqError("Not enough disk space on target node %s." |
4827 | 4829 |
" %d MB available, %d MB required" % |
4828 |
(node, info['vg_free'], req_size))
|
|
4830 |
(node, vg_free, req_size))
|
|
4829 | 4831 |
|
4830 | 4832 |
_CheckHVParams(self, nodenames, self.op.hypervisor, self.op.hvparams) |
4831 | 4833 |
|
... | ... | |
5673 | 5675 |
instance.hypervisor) |
5674 | 5676 |
for node in nodenames: |
5675 | 5677 |
info = nodeinfo[node] |
5676 |
if info.failed or not info.data: |
|
5678 |
msg = info.RemoteFailMsg() |
|
5679 |
if msg: |
|
5677 | 5680 |
raise errors.OpPrereqError("Cannot get current information" |
5678 |
" from node '%s'" % node)
|
|
5679 |
vg_free = info.data.get('vg_free', None)
|
|
5681 |
" from node %s:" % (node, msg))
|
|
5682 |
vg_free = info.payload.get('vg_free', None)
|
|
5680 | 5683 |
if not isinstance(vg_free, int): |
5681 | 5684 |
raise errors.OpPrereqError("Can't compute free disk space on" |
5682 | 5685 |
" node %s" % node) |
... | ... | |
6115 | 6118 |
instance.hypervisor) |
6116 | 6119 |
nodeinfo = self.rpc.call_node_info(mem_check_list, self.cfg.GetVGName(), |
6117 | 6120 |
instance.hypervisor) |
6118 |
if nodeinfo[pnode].failed or not isinstance(nodeinfo[pnode].data, dict): |
|
6121 |
pninfo = nodeinfo[pnode] |
|
6122 |
msg = pninfo.RemoteFailMsg() |
|
6123 |
if msg: |
|
6119 | 6124 |
# Assume the primary node is unreachable and go ahead |
6120 |
self.warn.append("Can't get info from primary node %s" % pnode) |
|
6125 |
self.warn.append("Can't get info from primary node %s: %s" % |
|
6126 |
(pnode, msg)) |
|
6127 |
elif not isinstance(pninfo.payload.get('memory_free', None), int): |
|
6128 |
self.warn.append("Node data from primary node %s doesn't contain" |
|
6129 |
" free memory information" % pnode) |
|
6121 | 6130 |
elif instance_info.RemoteFailMsg(): |
6122 | 6131 |
self.warn.append("Can't get instance runtime information: %s" % |
6123 | 6132 |
instance_info.RemoteFailMsg()) |
... | ... | |
6130 | 6139 |
# and we have no other way to check) |
6131 | 6140 |
current_mem = 0 |
6132 | 6141 |
miss_mem = (be_new[constants.BE_MEMORY] - current_mem - |
6133 |
nodeinfo[pnode].data['memory_free'])
|
|
6142 |
pninfo.payload['memory_free'])
|
|
6134 | 6143 |
if miss_mem > 0: |
6135 | 6144 |
raise errors.OpPrereqError("This change will prevent the instance" |
6136 | 6145 |
" from starting, due to %d MB of memory" |
6137 | 6146 |
" missing on its primary node" % miss_mem) |
6138 | 6147 |
|
6139 | 6148 |
if be_new[constants.BE_AUTO_BALANCE]: |
6140 |
for node, nres in nodeinfo.iteritems():
|
|
6149 |
for node, nres in nodeinfo.items(): |
|
6141 | 6150 |
if node not in instance.secondary_nodes: |
6142 | 6151 |
continue |
6143 |
if nres.failed or not isinstance(nres.data, dict): |
|
6144 |
self.warn.append("Can't get info from secondary node %s" % node) |
|
6145 |
elif be_new[constants.BE_MEMORY] > nres.data['memory_free']: |
|
6152 |
msg = nres.RemoteFailMsg() |
|
6153 |
if msg: |
|
6154 |
self.warn.append("Can't get info from secondary node %s: %s" % |
|
6155 |
(node, msg)) |
|
6156 |
elif not isinstance(nres.payload.get('memory_free', None), int): |
|
6157 |
self.warn.append("Secondary node %s didn't return free" |
|
6158 |
" memory information" % node) |
|
6159 |
elif be_new[constants.BE_MEMORY] > nres.payload['memory_free']: |
|
6146 | 6160 |
self.warn.append("Not enough memory to failover instance to" |
6147 | 6161 |
" secondary node %s" % node) |
6148 | 6162 |
|
... | ... | |
6920 | 6934 |
} |
6921 | 6935 |
|
6922 | 6936 |
if not ninfo.offline: |
6923 |
nresult.Raise() |
|
6924 |
if not isinstance(nresult.data, dict): |
|
6925 |
raise errors.OpExecError("Can't get data for node %s" % nname) |
|
6937 |
msg = nresult.RemoteFailMsg() |
|
6938 |
if msg: |
|
6939 |
raise errors.OpExecError("Can't get data for node %s: %s" % |
|
6940 |
(nname, msg)) |
|
6926 | 6941 |
msg = node_iinfo[nname].RemoteFailMsg() |
6927 | 6942 |
if msg: |
6928 | 6943 |
raise errors.OpExecError("Can't get node instance info" |
6929 | 6944 |
" from node %s: %s" % (nname, msg)) |
6930 |
remote_info = nresult.data
|
|
6945 |
remote_info = nresult.payload
|
|
6931 | 6946 |
for attr in ['memory_total', 'memory_free', 'memory_dom0', |
6932 | 6947 |
'vg_size', 'vg_free', 'cpu_total']: |
6933 | 6948 |
if attr not in remote_info: |
6934 | 6949 |
raise errors.OpExecError("Node '%s' didn't return attribute" |
6935 | 6950 |
" '%s'" % (nname, attr)) |
6936 |
try: |
|
6937 |
remote_info[attr] = int(remote_info[attr]) |
|
6938 |
except ValueError, err: |
|
6951 |
if not isinstance(remote_info[attr], int): |
|
6939 | 6952 |
raise errors.OpExecError("Node '%s' returned invalid value" |
6940 |
" for '%s': %s" % (nname, attr, err)) |
|
6953 |
" for '%s': %s" % |
|
6954 |
(nname, attr, remote_info[attr])) |
|
6941 | 6955 |
# compute memory used by primary instances |
6942 | 6956 |
i_p_mem = i_p_up_mem = 0 |
6943 | 6957 |
for iinfo, beinfo in i_list: |
Also available in: Unified diff