blob: 42593b0fe86cbca1cc22fddfd2541f7d8861d3ce [file] [log] [blame]
mbligh7f86e0b2007-11-24 19:45:07 +00001def check_diskspace(host, path, gb):
mblighc9585ec2008-03-05 18:28:39 +00002 df = host.run('df -mP %s | tail -1' % path).stdout.split()
mbligh0ff7c222008-02-08 16:51:58 +00003 free_space_gb = int(df[3])/1000.0
mbligh7f86e0b2007-11-24 19:45:07 +00004 if free_space_gb < gb:
mbligh0ff7c222008-02-08 16:51:58 +00005 raise AutoservHostError('Not enough free space on ' +
6 '%s - %.3fGB free, want %.3fGB' %
7 (path, free_space_gb, gb))
mbligh7f86e0b2007-11-24 19:45:07 +00008
9
mblighed5a4102007-11-20 00:46:41 +000010# This needs more stuff in it. Check for diskspace, etc. But it's a start.
11def verify(machine):
mbligh6102a362007-12-19 15:50:50 +000012 print 'Initializing host ' + machine
jadmanski8d631c92008-08-18 21:12:40 +000013 host = hosts.create_host(machine, initialize=False)
mbligh6102a362007-12-19 15:50:50 +000014 print 'Pinging host ' + machine
15 sys.stdout.flush()
mblighed5a4102007-11-20 00:46:41 +000016 host.ssh_ping()
mbligh6102a362007-12-19 15:50:50 +000017 print 'Getting autodir for ' + machine
mbligh7f86e0b2007-11-24 19:45:07 +000018 autodir = None
19 try:
20 autodir = autotest._get_autodir(host)
mbligh6102a362007-12-19 15:50:50 +000021 if autodir:
mbligh0ff7c222008-02-08 16:51:58 +000022 print 'Checking diskspace for %s on %s' % (machine,
23 autodir)
mbligh52c0a172008-01-26 22:54:25 +000024 check_diskspace(host, autodir, 20)
mbligh6102a362007-12-19 15:50:50 +000025 except AutoservHostError:
26 raise # only want to raise if it's a space issue
mbligh7f86e0b2007-11-24 19:45:07 +000027 except:
mbligh6102a362007-12-19 15:50:50 +000028 pass # autotest dir may not exist, etc. ignore
mblighed5a4102007-11-20 00:46:41 +000029 if "site_verify" in globals():
mbligh7f86e0b2007-11-24 19:45:07 +000030 site_verify(host)
mblighed5a4102007-11-20 00:46:41 +000031
mbligh6437ff52008-04-17 15:24:38 +000032job.parallel_simple(verify, machines, log=False)