Revision 36bebc53 lib/hypervisor/hv_xen.py
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
83 | 83 |
|
84 | 84 |
|
85 | 85 |
def _RunXmList(fn, xmllist_errors): |
86 |
"""Helper function for L{_GetXmList} to run "xm list".
|
|
86 |
"""Helper function for L{_GetInstanceList} to run "xm list".
|
|
87 | 87 |
|
88 | 88 |
@type fn: callable |
89 | 89 |
@param fn: Function returning result of running C{xm list} |
... | ... | |
141 | 141 |
return result |
142 | 142 |
|
143 | 143 |
|
144 |
def _GetXmList(fn, include_node, _timeout=5):
|
|
144 |
def _GetInstanceList(fn, include_node, _timeout=5):
|
|
145 | 145 |
"""Return the list of running instances. |
146 | 146 |
|
147 | 147 |
See L{_RunXmList} and L{_ParseXmList} for parameter details. |
... | ... | |
432 | 432 |
utils.RenameFile(old_filename, new_filename) |
433 | 433 |
return new_filename |
434 | 434 |
|
435 |
def _GetXmList(self, include_node):
|
|
436 |
"""Wrapper around module level L{_GetXmList}.
|
|
435 |
def _GetInstanceList(self, include_node):
|
|
436 |
"""Wrapper around module level L{_GetInstanceList}.
|
|
437 | 437 |
|
438 | 438 |
""" |
439 |
return _GetXmList(lambda: self._RunXen(["list"]), include_node)
|
|
439 |
return _GetInstanceList(lambda: self._RunXen(["list"]), include_node)
|
|
440 | 440 |
|
441 | 441 |
def ListInstances(self): |
442 | 442 |
"""Get the list of running instances. |
443 | 443 |
|
444 | 444 |
""" |
445 |
xm_list = self._GetXmList(False)
|
|
446 |
names = [info[0] for info in xm_list]
|
|
445 |
instance_list = self._GetInstanceList(False)
|
|
446 |
names = [info[0] for info in instance_list]
|
|
447 | 447 |
return names |
448 | 448 |
|
449 | 449 |
def GetInstanceInfo(self, instance_name): |
... | ... | |
454 | 454 |
@return: tuple (name, id, memory, vcpus, stat, times) |
455 | 455 |
|
456 | 456 |
""" |
457 |
xm_list = self._GetXmList(instance_name == _DOM0_NAME)
|
|
457 |
instance_list = self._GetInstanceList(instance_name == _DOM0_NAME)
|
|
458 | 458 |
result = None |
459 |
for data in xm_list:
|
|
459 |
for data in instance_list:
|
|
460 | 460 |
if data[0] == instance_name: |
461 | 461 |
result = data |
462 | 462 |
break |
... | ... | |
468 | 468 |
@return: list of tuples (name, id, memory, vcpus, stat, times) |
469 | 469 |
|
470 | 470 |
""" |
471 |
xm_list = self._GetXmList(False) |
|
472 |
return xm_list |
|
471 |
return self._GetInstanceList(False) |
|
473 | 472 |
|
474 | 473 |
def _MakeConfigFile(self, instance, startup_memory, block_devices): |
475 | 474 |
"""Gather configuration details and write to disk. |
... | ... | |
605 | 604 |
result.output) |
606 | 605 |
return None |
607 | 606 |
|
608 |
return _GetNodeInfo(result.stdout, self._GetXmList)
|
|
607 |
return _GetNodeInfo(result.stdout, self._GetInstanceList)
|
|
609 | 608 |
|
610 | 609 |
@classmethod |
611 | 610 |
def GetInstanceConsole(cls, instance, hvparams, beparams): |
Also available in: Unified diff