Revision e8a4c138 lib/hypervisor/FakeHypervisor.py
b/lib/hypervisor/FakeHypervisor.py | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import os |
27 | 27 |
import os.path |
28 |
import re |
|
28 | 29 |
|
29 | 30 |
from ganeti import utils |
30 | 31 |
from ganeti import constants |
... | ... | |
186 | 187 |
sum_free += int(val.split()[0])/1024 |
187 | 188 |
elif key == 'Active': |
188 | 189 |
result['memory_dom0'] = int(val.split()[0])/1024 |
189 |
|
|
190 | 190 |
result['memory_free'] = sum_free |
191 |
|
|
192 |
cpu_total = 0 |
|
193 |
try: |
|
194 |
fh = open("/proc/cpuinfo") |
|
195 |
try: |
|
196 |
cpu_total = len(re.findall("(?m)^processor\s*:\s*[0-9]+\s*$", |
|
197 |
fh.read())) |
|
198 |
finally: |
|
199 |
fh.close() |
|
200 |
except EnvironmentError, err: |
|
201 |
raise HypervisorError("Failed to list node info: %s" % err) |
|
202 |
result['cpu_total'] = cpu_total |
|
203 |
|
|
191 | 204 |
return result |
192 | 205 |
|
193 | 206 |
@staticmethod |
Also available in: Unified diff