Revision b9e12624 lib/backend.py
b/lib/backend.py | ||
---|---|---|
1440 | 1440 |
|
1441 | 1441 |
""" |
1442 | 1442 |
output = {} |
1443 |
|
|
1444 | 1443 |
for hname in hypervisor_list: |
1445 | 1444 |
hvparams = all_hvparams[hname] |
1446 | 1445 |
iinfo = hypervisor.GetHypervisor(hname).GetAllInstancesInfo(hvparams) |
... | ... | |
1465 | 1464 |
return output |
1466 | 1465 |
|
1467 | 1466 |
|
1467 |
def GetInstanceConsoleInfo(instance_param_dict, |
|
1468 |
get_hv_fn=hypervisor.GetHypervisor): |
|
1469 |
"""Gather data about the console access of a set of instances of this node. |
|
1470 |
|
|
1471 |
This function assumes that the caller already knows which instances are on |
|
1472 |
this node, by calling a function such as L{GetAllInstancesInfo} or |
|
1473 |
L{GetInstanceList}. |
|
1474 |
|
|
1475 |
For every instance, a large amount of configuration data needs to be |
|
1476 |
provided to the hypervisor interface in order to receive the console |
|
1477 |
information. Whether this could or should be cut down can be discussed. |
|
1478 |
The information is provided in a dictionary indexed by instance name, |
|
1479 |
allowing any number of instance queries to be done. |
|
1480 |
|
|
1481 |
@type instance_param_dict: dict of string to tuple of dictionaries, where the |
|
1482 |
dictionaries represent: L{objects.Instance}, L{objects.Node}, HvParams, |
|
1483 |
BeParams |
|
1484 |
@param instance_param_dict: mapping of instance name to parameters necessary |
|
1485 |
for console information retrieval |
|
1486 |
|
|
1487 |
@rtype: dict |
|
1488 |
@return: dictionary of instance: data, with data having the following keys: |
|
1489 |
- instance: instance name |
|
1490 |
- kind: console kind |
|
1491 |
- message: used with kind == CONS_MESSAGE, indicates console to be |
|
1492 |
unavailable, supplies error message |
|
1493 |
- host: host to connect to |
|
1494 |
- port: port to use |
|
1495 |
- user: user for login |
|
1496 |
- command: the command, broken into parts as an array |
|
1497 |
- display: unknown, potentially unused? |
|
1498 |
|
|
1499 |
""" |
|
1500 |
|
|
1501 |
output = {} |
|
1502 |
for inst_name in instance_param_dict: |
|
1503 |
instance = instance_param_dict[inst_name]["instance"] |
|
1504 |
pnode = instance_param_dict[inst_name]["node"] |
|
1505 |
hvparams = instance_param_dict[inst_name]["hvParams"] |
|
1506 |
beparams = instance_param_dict[inst_name]["beParams"] |
|
1507 |
|
|
1508 |
instance = objects.Instance.FromDict(instance) |
|
1509 |
pnode = objects.Node.FromDict(pnode) |
|
1510 |
|
|
1511 |
h = get_hv_fn(instance.hypervisor) |
|
1512 |
output[inst_name] = h.GetInstanceConsole(instance, pnode, hvparams, |
|
1513 |
beparams).ToDict() |
|
1514 |
|
|
1515 |
return output |
|
1516 |
|
|
1517 |
|
|
1468 | 1518 |
def _InstanceLogName(kind, os_name, instance, component): |
1469 | 1519 |
"""Compute the OS log filename for a given instance and operation. |
1470 | 1520 |
|
Also available in: Unified diff