On Thu, Dec 30, 2010 at 7:32 AM, Lucas Meneghel Rodrigues <[email protected]>wrote:
> On Thu, 2010-12-30 at 11:16 -0200, Cleber Rosa wrote: > > Instead of running a 'df' external command, simply use python's builtin > > os.statvfs() for fetching the very same information. > > Hi Cleber, this command is implemented like this for a reason: We want > to know what is the free space on the client machine, self.run is > implemented on higher level classes as an SSH command. Although it would > be nice, it's not possible to get that data using python, unless we ran > a subcommand such as python "code snippet" there. So I'm going to reject > this particular patch. Thanks! > Yep. If you want to use os.statvfs() instead of requiring df (a good idea) from an autotest client you need to define an overridden check_diskspace() method somewhere in client/bin/hosts/. Anything in common_lib is base class code that needs to work on both client and server side hosts. If you wanted to use os.statvfs() even from a server host object to remove a need for df, you'd need to change this method to launch a python process on the remote machine to call os.statvfs and print out the result. there are a few places that issue remote commands that way via python -c or via python <<EOF but in general it is messy to try and do that. -gps > > Signed-off-by: Cleber Rosa <[email protected]> > > --- > > client/common_lib/hosts/base_classes.py | 4 ++-- > > 1 files changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/client/common_lib/hosts/base_classes.py > b/client/common_lib/hosts/base_classes.py > > index 0b6ce0c..86c1ea5 100644 > > --- a/client/common_lib/hosts/base_classes.py > > +++ b/client/common_lib/hosts/base_classes.py > > @@ -230,8 +230,8 @@ class Host(object): > > def check_diskspace(self, path, gb): > > logging.info('Checking for >= %s GB of space under %s on > machine %s', > > gb, path, self.hostname) > > - df = self.run('df -mP %s | tail -1' % path).stdout.split() > > - free_space_gb = int(df[3])/1000.0 > > + statvfs = os.statvfs(path) > > + free_spage_gb = int((statvfs.f_bavail * statvfs.f_bsize) / > 1000000000) > > if free_space_gb < gb: > > raise error.AutoservDiskFullHostError(path, gb, > free_space_gb) > > else: > > > _______________________________________________ > Autotest mailing list > [email protected] > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest >
_______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
