6374 |
6374 |
"version": 1,
|
6375 |
6375 |
"cluster_name": cfg.GetClusterName(),
|
6376 |
6376 |
"cluster_tags": list(cluster_info.GetTags()),
|
6377 |
|
"enable_hypervisors": list(cluster_info.enabled_hypervisors),
|
|
6377 |
"enabled_hypervisors": list(cluster_info.enabled_hypervisors),
|
6378 |
6378 |
# we don't have job IDs
|
6379 |
6379 |
}
|
6380 |
6380 |
iinfo = cfg.GetAllInstancesInfo().values()
|
... | ... | |
6393 |
6393 |
hypervisor_name)
|
6394 |
6394 |
node_iinfo = self.lu.rpc.call_all_instances_info(node_list,
|
6395 |
6395 |
cluster_info.enabled_hypervisors)
|
6396 |
|
for nname in node_list:
|
|
6396 |
for nname, nresult in node_data.items():
|
|
6397 |
# first fill in static (config-based) values
|
6397 |
6398 |
ninfo = cfg.GetNodeInfo(nname)
|
6398 |
|
node_data[nname].Raise()
|
6399 |
|
if not isinstance(node_data[nname].data, dict):
|
6400 |
|
raise errors.OpExecError("Can't get data for node %s" % nname)
|
6401 |
|
remote_info = node_data[nname].data
|
6402 |
|
for attr in ['memory_total', 'memory_free', 'memory_dom0',
|
6403 |
|
'vg_size', 'vg_free', 'cpu_total']:
|
6404 |
|
if attr not in remote_info:
|
6405 |
|
raise errors.OpExecError("Node '%s' didn't return attribute '%s'" %
|
6406 |
|
(nname, attr))
|
6407 |
|
try:
|
6408 |
|
remote_info[attr] = int(remote_info[attr])
|
6409 |
|
except ValueError, err:
|
6410 |
|
raise errors.OpExecError("Node '%s' returned invalid value for '%s':"
|
6411 |
|
" %s" % (nname, attr, str(err)))
|
6412 |
|
# compute memory used by primary instances
|
6413 |
|
i_p_mem = i_p_up_mem = 0
|
6414 |
|
for iinfo, beinfo in i_list:
|
6415 |
|
if iinfo.primary_node == nname:
|
6416 |
|
i_p_mem += beinfo[constants.BE_MEMORY]
|
6417 |
|
if iinfo.name not in node_iinfo[nname]:
|
6418 |
|
i_used_mem = 0
|
6419 |
|
else:
|
6420 |
|
i_used_mem = int(node_iinfo[nname][iinfo.name]['memory'])
|
6421 |
|
i_mem_diff = beinfo[constants.BE_MEMORY] - i_used_mem
|
6422 |
|
remote_info['memory_free'] -= max(0, i_mem_diff)
|
6423 |
|
|
6424 |
|
if iinfo.admin_up:
|
6425 |
|
i_p_up_mem += beinfo[constants.BE_MEMORY]
|
6426 |
|
|
6427 |
|
# compute memory used by instances
|
6428 |
6399 |
pnr = {
|
6429 |
6400 |
"tags": list(ninfo.GetTags()),
|
6430 |
|
"total_memory": remote_info['memory_total'],
|
6431 |
|
"reserved_memory": remote_info['memory_dom0'],
|
6432 |
|
"free_memory": remote_info['memory_free'],
|
6433 |
|
"i_pri_memory": i_p_mem,
|
6434 |
|
"i_pri_up_memory": i_p_up_mem,
|
6435 |
|
"total_disk": remote_info['vg_size'],
|
6436 |
|
"free_disk": remote_info['vg_free'],
|
6437 |
6401 |
"primary_ip": ninfo.primary_ip,
|
6438 |
6402 |
"secondary_ip": ninfo.secondary_ip,
|
6439 |
|
"total_cpus": remote_info['cpu_total'],
|
6440 |
6403 |
"offline": ninfo.offline,
|
|
6404 |
"master_candidate": ninfo.master_candidate,
|
6441 |
6405 |
}
|
|
6406 |
|
|
6407 |
if not ninfo.offline:
|
|
6408 |
nresult.Raise()
|
|
6409 |
if not isinstance(nresult.data, dict):
|
|
6410 |
raise errors.OpExecError("Can't get data for node %s" % nname)
|
|
6411 |
remote_info = nresult.data
|
|
6412 |
for attr in ['memory_total', 'memory_free', 'memory_dom0',
|
|
6413 |
'vg_size', 'vg_free', 'cpu_total']:
|
|
6414 |
if attr not in remote_info:
|
|
6415 |
raise errors.OpExecError("Node '%s' didn't return attribute"
|
|
6416 |
" '%s'" % (nname, attr))
|
|
6417 |
try:
|
|
6418 |
remote_info[attr] = int(remote_info[attr])
|
|
6419 |
except ValueError, err:
|
|
6420 |
raise errors.OpExecError("Node '%s' returned invalid value"
|
|
6421 |
" for '%s': %s" % (nname, attr, err))
|
|
6422 |
# compute memory used by primary instances
|
|
6423 |
i_p_mem = i_p_up_mem = 0
|
|
6424 |
for iinfo, beinfo in i_list:
|
|
6425 |
if iinfo.primary_node == nname:
|
|
6426 |
i_p_mem += beinfo[constants.BE_MEMORY]
|
|
6427 |
if iinfo.name not in node_iinfo[nname].data:
|
|
6428 |
i_used_mem = 0
|
|
6429 |
else:
|
|
6430 |
i_used_mem = int(node_iinfo[nname].data[iinfo.name]['memory'])
|
|
6431 |
i_mem_diff = beinfo[constants.BE_MEMORY] - i_used_mem
|
|
6432 |
remote_info['memory_free'] -= max(0, i_mem_diff)
|
|
6433 |
|
|
6434 |
if iinfo.admin_up:
|
|
6435 |
i_p_up_mem += beinfo[constants.BE_MEMORY]
|
|
6436 |
|
|
6437 |
# compute memory used by instances
|
|
6438 |
pnr_dyn = {
|
|
6439 |
"total_memory": remote_info['memory_total'],
|
|
6440 |
"reserved_memory": remote_info['memory_dom0'],
|
|
6441 |
"free_memory": remote_info['memory_free'],
|
|
6442 |
"total_disk": remote_info['vg_size'],
|
|
6443 |
"free_disk": remote_info['vg_free'],
|
|
6444 |
"total_cpus": remote_info['cpu_total'],
|
|
6445 |
"i_pri_memory": i_p_mem,
|
|
6446 |
"i_pri_up_memory": i_p_up_mem,
|
|
6447 |
}
|
|
6448 |
pnr.update(pnr_dyn)
|
|
6449 |
|
6442 |
6450 |
node_results[nname] = pnr
|
6443 |
6451 |
data["nodes"] = node_results
|
6444 |
6452 |
|
... | ... | |
6449 |
6457 |
for n in iinfo.nics]
|
6450 |
6458 |
pir = {
|
6451 |
6459 |
"tags": list(iinfo.GetTags()),
|
6452 |
|
"should_run": iinfo.admin_up,
|
|
6460 |
"admin_up": iinfo.admin_up,
|
6453 |
6461 |
"vcpus": beinfo[constants.BE_VCPUS],
|
6454 |
6462 |
"memory": beinfo[constants.BE_MEMORY],
|
6455 |
6463 |
"os": iinfo.os,
|
6456 |
|
"nodes": list(iinfo.all_nodes),
|
|
6464 |
"nodes": [iinfo.primary_node] + list(iinfo.secondary_nodes),
|
6457 |
6465 |
"nics": nic_data,
|
6458 |
|
"disks": [{"size": dsk.size, "mode": "w"} for dsk in iinfo.disks],
|
|
6466 |
"disks": [{"size": dsk.size, "mode": dsk.mode} for dsk in iinfo.disks],
|
6459 |
6467 |
"disk_template": iinfo.disk_template,
|
6460 |
6468 |
"hypervisor": iinfo.hypervisor,
|
6461 |
6469 |
}
|