Commit 2fa74ef4 authored by Iustin Pop's avatar Iustin Pop
Browse files

Convert all_instances_info rpc to new result style


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 7ad1af4a
...@@ -695,11 +695,11 @@ def GetAllInstancesInfo(hypervisor_list): ...@@ -695,11 +695,11 @@ def GetAllInstancesInfo(hypervisor_list):
# invocations of the different hypervisors # invocations of the different hypervisors
for key in 'memory', 'vcpus': for key in 'memory', 'vcpus':
if value[key] != output[name][key]: if value[key] != output[name][key]:
raise errors.HypervisorError("Instance %s is running twice" _Fail("Instance %s is running twice"
" with different parameters" % name) " with different parameters", name)
output[name] = value output[name] = value
return output return True, output
def InstanceOsAdd(instance, reinstall): def InstanceOsAdd(instance, reinstall):
......
...@@ -3446,12 +3446,12 @@ class LUQueryInstances(NoHooksLU): ...@@ -3446,12 +3446,12 @@ class LUQueryInstances(NoHooksLU):
if result.offline: if result.offline:
# offline nodes will be in both lists # offline nodes will be in both lists
off_nodes.append(name) off_nodes.append(name)
if result.failed: if result.failed or result.RemoteFailMsg():
bad_nodes.append(name) bad_nodes.append(name)
else: else:
if result.data: if result.payload:
live_data.update(result.data) live_data.update(result.payload)
# else no instance is alive # else no instance is alive
else: else:
live_data = dict([(name, {}) for name in instance_names]) live_data = dict([(name, {}) for name in instance_names])
...@@ -6914,6 +6914,10 @@ class IAllocator(object): ...@@ -6914,6 +6914,10 @@ class IAllocator(object):
nresult.Raise() nresult.Raise()
if not isinstance(nresult.data, dict): if not isinstance(nresult.data, dict):
raise errors.OpExecError("Can't get data for node %s" % nname) raise errors.OpExecError("Can't get data for node %s" % nname)
msg = node_iinfo[nname].RemoteFailMsg()
if msg:
raise errors.OpExecError("Can't get node instance info"
" from node %s: %s" % (nname, msg))
remote_info = nresult.data remote_info = nresult.data
for attr in ['memory_total', 'memory_free', 'memory_dom0', for attr in ['memory_total', 'memory_free', 'memory_dom0',
'vg_size', 'vg_free', 'cpu_total']: 'vg_size', 'vg_free', 'cpu_total']:
...@@ -6930,10 +6934,10 @@ class IAllocator(object): ...@@ -6930,10 +6934,10 @@ class IAllocator(object):
for iinfo, beinfo in i_list: for iinfo, beinfo in i_list:
if iinfo.primary_node == nname: if iinfo.primary_node == nname:
i_p_mem += beinfo[constants.BE_MEMORY] i_p_mem += beinfo[constants.BE_MEMORY]
if iinfo.name not in node_iinfo[nname].data: if iinfo.name not in node_iinfo[nname].payload:
i_used_mem = 0 i_used_mem = 0
else: else:
i_used_mem = int(node_iinfo[nname].data[iinfo.name]['memory']) i_used_mem = int(node_iinfo[nname].payload[iinfo.name]['memory'])
i_mem_diff = beinfo[constants.BE_MEMORY] - i_used_mem i_mem_diff = beinfo[constants.BE_MEMORY] - i_used_mem
remote_info['memory_free'] -= max(0, i_mem_diff) remote_info['memory_free'] -= max(0, i_mem_diff)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment