Revision ff19ac20
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
82 | 82 |
return "cpus = [ %s ]" % ", ".join(map(_GetCPUMap, cpu_list)) |
83 | 83 |
|
84 | 84 |
|
85 |
def _RunXmList(fn, xmllist_errors): |
|
86 |
"""Helper function for L{_GetInstanceList} to run "xm list". |
|
85 |
def _RunInstanceList(fn, instance_list_errors): |
|
86 |
"""Helper function for L{_GetInstanceList} to retrieve the list of instances |
|
87 |
from xen. |
|
87 | 88 |
|
88 | 89 |
@type fn: callable |
89 |
@param fn: Function returning result of running C{xm list}
|
|
90 |
@type xmllist_errors: list
|
|
91 |
@param xmllist_errors: Error list
|
|
90 |
@param fn: Function to query xen for the list of instances
|
|
91 |
@type instance_list_errors: list
|
|
92 |
@param instance_list_errors: Error list
|
|
92 | 93 |
@rtype: list |
93 | 94 |
|
94 | 95 |
""" |
95 | 96 |
result = fn() |
96 | 97 |
if result.failed: |
97 |
logging.error("xm list failed (%s): %s", result.fail_reason,
|
|
98 |
result.output) |
|
99 |
xmllist_errors.append(result)
|
|
98 |
logging.error("Retrieving the instance list from xen failed (%s): %s",
|
|
99 |
result.fail_reason, result.output)
|
|
100 |
instance_list_errors.append(result)
|
|
100 | 101 |
raise utils.RetryAgain() |
101 | 102 |
|
102 | 103 |
# skip over the heading |
... | ... | |
144 | 145 |
def _GetInstanceList(fn, include_node, _timeout=5): |
145 | 146 |
"""Return the list of running instances. |
146 | 147 |
|
147 |
See L{_RunXmList} and L{_ParseXmList} for parameter details.
|
|
148 |
See L{_RunInstanceList} and L{_ParseXmList} for parameter details.
|
|
148 | 149 |
|
149 | 150 |
""" |
150 |
xmllist_errors = []
|
|
151 |
instance_list_errors = []
|
|
151 | 152 |
try: |
152 |
lines = utils.Retry(_RunXmList, (0.3, 1.5, 1.0), _timeout,
|
|
153 |
args=(fn, xmllist_errors))
|
|
153 |
lines = utils.Retry(_RunInstanceList, (0.3, 1.5, 1.0), _timeout,
|
|
154 |
args=(fn, instance_list_errors))
|
|
154 | 155 |
except utils.RetryTimeout: |
155 |
if xmllist_errors:
|
|
156 |
xmlist_result = xmllist_errors.pop()
|
|
156 |
if instance_list_errors:
|
|
157 |
instance_list_result = instance_list_errors.pop()
|
|
157 | 158 |
|
158 |
errmsg = ("xm list failed, timeout exceeded (%s): %s" %
|
|
159 |
(xmlist_result.fail_reason, xmlist_result.output))
|
|
159 |
errmsg = ("listing instances failed, timeout exceeded (%s): %s" %
|
|
160 |
(instance_list_result.fail_reason, instance_list_result.output))
|
|
160 | 161 |
else: |
161 |
errmsg = "xm list failed"
|
|
162 |
errmsg = "listing instances failed"
|
|
162 | 163 |
|
163 | 164 |
raise errors.HypervisorError(errmsg) |
164 | 165 |
|
Also available in: Unified diff