Revision 2609da63 lib/hypervisor/hv_xen.py
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
104 | 104 |
return result.stdout.splitlines() |
105 | 105 |
|
106 | 106 |
|
107 |
def _ParseXmList(lines, include_node):
|
|
108 |
"""Parses the output of C{xm list}.
|
|
107 |
def _ParseInstanceList(lines, include_node):
|
|
108 |
"""Parses the output of listing instances by xen.
|
|
109 | 109 |
|
110 | 110 |
@type lines: list |
111 |
@param lines: Output lines of C{xm list}
|
|
111 |
@param lines: Result of retrieving the instance list from xen
|
|
112 | 112 |
@type include_node: boolean |
113 | 113 |
@param include_node: If True, return information for Dom0 |
114 | 114 |
@return: list of tuple containing (name, id, memory, vcpus, state, time |
... | ... | |
124 | 124 |
# Domain-0 0 3418 4 r----- 266.2 |
125 | 125 |
data = line.split() |
126 | 126 |
if len(data) != 6: |
127 |
raise errors.HypervisorError("Can't parse output of xm list,"
|
|
127 |
raise errors.HypervisorError("Can't parse instance list,"
|
|
128 | 128 |
" line: %s" % line) |
129 | 129 |
try: |
130 | 130 |
data[1] = int(data[1]) |
... | ... | |
132 | 132 |
data[3] = int(data[3]) |
133 | 133 |
data[5] = float(data[5]) |
134 | 134 |
except (TypeError, ValueError), err: |
135 |
raise errors.HypervisorError("Can't parse output of xm list,"
|
|
135 |
raise errors.HypervisorError("Can't parse instance list,"
|
|
136 | 136 |
" line: %s, error: %s" % (line, err)) |
137 | 137 |
|
138 | 138 |
# skip the Domain-0 (optional) |
... | ... | |
145 | 145 |
def _GetInstanceList(fn, include_node, _timeout=5): |
146 | 146 |
"""Return the list of running instances. |
147 | 147 |
|
148 |
See L{_RunInstanceList} and L{_ParseXmList} for parameter details.
|
|
148 |
See L{_RunInstanceList} and L{_ParseInstanceList} for parameter details.
|
|
149 | 149 |
|
150 | 150 |
""" |
151 | 151 |
instance_list_errors = [] |
... | ... | |
163 | 163 |
|
164 | 164 |
raise errors.HypervisorError(errmsg) |
165 | 165 |
|
166 |
return _ParseXmList(lines, include_node)
|
|
166 |
return _ParseInstanceList(lines, include_node)
|
|
167 | 167 |
|
168 | 168 |
|
169 | 169 |
def _ParseNodeInfo(info): |
... | ... | |
231 | 231 |
@type info: dict |
232 | 232 |
@param info: Result from L{_ParseNodeInfo} |
233 | 233 |
@type fn: callable |
234 |
@param fn: Function returning result of running C{xm list}
|
|
234 |
@param fn: Function retrieving the instance list
|
|
235 | 235 |
@rtype: dict |
236 | 236 |
|
237 | 237 |
""" |
... | ... | |
612 | 612 |
""" |
613 | 613 |
result = self._RunXen(["info"]) |
614 | 614 |
if result.failed: |
615 |
logging.error("Can't run 'xm info' (%s): %s", result.fail_reason,
|
|
616 |
result.output) |
|
615 |
logging.error("Can't retrieve xen hypervisor information (%s): %s",
|
|
616 |
result.fail_reason, result.output)
|
|
617 | 617 |
return None |
618 | 618 |
|
619 | 619 |
return _GetNodeInfo(result.stdout, self._GetInstanceList) |
Also available in: Unified diff