Revision fac83f8a lib/backend.py
b/lib/backend.py | ||
---|---|---|
1112 | 1112 |
_Fail("Missing bridges %s", utils.CommaJoin(missing)) |
1113 | 1113 |
|
1114 | 1114 |
|
1115 |
def GetInstanceList(hypervisor_list): |
|
1115 |
def GetInstanceList(hypervisor_list, all_hvparams=None, |
|
1116 |
get_hv_fn=hypervisor.GetHypervisor): |
|
1116 | 1117 |
"""Provides a list of instances. |
1117 | 1118 |
|
1118 | 1119 |
@type hypervisor_list: list |
1119 | 1120 |
@param hypervisor_list: the list of hypervisors to query information |
1121 |
@type all_hvparams: dict of dict of strings |
|
1122 |
@param all_hvparams: a dictionary mapping hypervisor types to respective |
|
1123 |
cluster-wide hypervisor parameters |
|
1124 |
@type get_hv_fn: function |
|
1125 |
@param get_hv_fn: function that returns a hypervisor for the given hypervisor |
|
1126 |
name; optional parameter to increase testability |
|
1120 | 1127 |
|
1121 | 1128 |
@rtype: list |
1122 | 1129 |
@return: a list of all running instances on the current node |
... | ... | |
1127 | 1134 |
results = [] |
1128 | 1135 |
for hname in hypervisor_list: |
1129 | 1136 |
try: |
1130 |
names = hypervisor.GetHypervisor(hname).ListInstances() |
|
1137 |
hvparams = None |
|
1138 |
if all_hvparams is not None: |
|
1139 |
hvparams = all_hvparams[hname] |
|
1140 |
hv = get_hv_fn(hname) |
|
1141 |
names = hv.ListInstances(hvparams) |
|
1131 | 1142 |
results.extend(names) |
1132 | 1143 |
except errors.HypervisorError, err: |
1133 | 1144 |
_Fail("Error enumerating instances (hypervisor %s): %s", |
Also available in: Unified diff