raise NotImplementedError
@staticmethod
- def GetLinuxNodeInfo():
+ def GetLinuxNodeInfo(meminfo="/proc/meminfo", cpuinfo="/proc/cpuinfo"):
"""For linux systems, return actual OS information.
This is an abstraction for all non-hypervisor-based classes, where
xen, where you only see the hardware resources via xen-specific
tools.
+ @param meminfo: name of the file containing meminfo
+ @type meminfo: string
+ @param cpuinfo: name of the file containing cpuinfo
+ @type cpuinfo: string
@return: a dict with the following keys (values in MiB):
- memory_total: the total memory size on the node
- memory_free: the available memory on the node for instances
"""
try:
- data = utils.ReadFile("/proc/meminfo").splitlines()
+ data = utils.ReadFile(meminfo).splitlines()
except EnvironmentError, err:
raise errors.HypervisorError("Failed to list node info: %s" % (err,))
cpu_total = 0
try:
- fh = open("/proc/cpuinfo")
+ fh = open(cpuinfo)
try:
cpu_total = len(re.findall("(?m)^processor\s*:\s*[0-9]+\s*$",
fh.read()))