LGTM, thanks
On Thu, Aug 22, 2013 at 10:55 AM, Michele Tartara <[email protected]>wrote: > The names of the input files are not hardcoded anymore, but they are now > default > parameters. > > No changes for the callers, but it's now possible to test the function more > easily. > > Signed-off-by: Michele Tartara <[email protected]> > --- > lib/hypervisor/hv_base.py | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/lib/hypervisor/hv_base.py b/lib/hypervisor/hv_base.py > index c723a4d..3f620f2 100644 > --- a/lib/hypervisor/hv_base.py > +++ b/lib/hypervisor/hv_base.py > @@ -447,7 +447,7 @@ class BaseHypervisor(object): > 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 > @@ -456,6 +456,10 @@ class BaseHypervisor(object): > 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 > @@ -463,7 +467,7 @@ class BaseHypervisor(object): > > """ > 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,)) > > @@ -489,7 +493,7 @@ class BaseHypervisor(object): > > 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())) > -- > 1.7.10.4 > >
