Revision 23cb5697
b/lib/hypervisor/hv_base.py | ||
---|---|---|
447 | 447 |
raise NotImplementedError |
448 | 448 |
|
449 | 449 |
@staticmethod |
450 |
def GetLinuxNodeInfo(): |
|
450 |
def GetLinuxNodeInfo(meminfo="/proc/meminfo", cpuinfo="/proc/cpuinfo"):
|
|
451 | 451 |
"""For linux systems, return actual OS information. |
452 | 452 |
|
453 | 453 |
This is an abstraction for all non-hypervisor-based classes, where |
... | ... | |
456 | 456 |
xen, where you only see the hardware resources via xen-specific |
457 | 457 |
tools. |
458 | 458 |
|
459 |
@param meminfo: name of the file containing meminfo |
|
460 |
@type meminfo: string |
|
461 |
@param cpuinfo: name of the file containing cpuinfo |
|
462 |
@type cpuinfo: string |
|
459 | 463 |
@return: a dict with the following keys (values in MiB): |
460 | 464 |
- memory_total: the total memory size on the node |
461 | 465 |
- memory_free: the available memory on the node for instances |
... | ... | |
463 | 467 |
|
464 | 468 |
""" |
465 | 469 |
try: |
466 |
data = utils.ReadFile("/proc/meminfo").splitlines()
|
|
470 |
data = utils.ReadFile(meminfo).splitlines()
|
|
467 | 471 |
except EnvironmentError, err: |
468 | 472 |
raise errors.HypervisorError("Failed to list node info: %s" % (err,)) |
469 | 473 |
|
... | ... | |
489 | 493 |
|
490 | 494 |
cpu_total = 0 |
491 | 495 |
try: |
492 |
fh = open("/proc/cpuinfo")
|
|
496 |
fh = open(cpuinfo)
|
|
493 | 497 |
try: |
494 | 498 |
cpu_total = len(re.findall("(?m)^processor\s*:\s*[0-9]+\s*$", |
495 | 499 |
fh.read())) |
Also available in: Unified diff