mbligh | 7f86e0b | 2007-11-24 19:45:07 +0000 | [diff] [blame] | 1 | def check_diskspace(host, path, gb): |
| 2 | df = host.run('df -m %s | tail -1' % path).stdout.split() |
| 3 | free_space_gb = int(df[3])/1000 |
| 4 | if free_space_gb < gb: |
mbligh | 03f4fc7 | 2007-11-29 20:56:14 +0000 | [diff] [blame] | 5 | raise AutoservHostError('Not enough free space on %s - %dGB free, want %dGB' % (path, free_space_gb, gb)) |
mbligh | 7f86e0b | 2007-11-24 19:45:07 +0000 | [diff] [blame] | 6 | |
| 7 | |
mbligh | ed5a410 | 2007-11-20 00:46:41 +0000 | [diff] [blame] | 8 | # This needs more stuff in it. Check for diskspace, etc. But it's a start. |
| 9 | def verify(machine): |
mbligh | 6102a36 | 2007-12-19 15:50:50 +0000 | [diff] [blame^] | 10 | print 'Initializing host ' + machine |
mbligh | ed5a410 | 2007-11-20 00:46:41 +0000 | [diff] [blame] | 11 | host = hosts.SSHHost(machine, initialize=False) |
mbligh | 6102a36 | 2007-12-19 15:50:50 +0000 | [diff] [blame^] | 12 | print 'Pinging host ' + machine |
| 13 | sys.stdout.flush() |
mbligh | ed5a410 | 2007-11-20 00:46:41 +0000 | [diff] [blame] | 14 | host.ssh_ping() |
mbligh | 6102a36 | 2007-12-19 15:50:50 +0000 | [diff] [blame^] | 15 | print 'Getting autodir for ' + machine |
mbligh | 7f86e0b | 2007-11-24 19:45:07 +0000 | [diff] [blame] | 16 | autodir = None |
| 17 | try: |
| 18 | autodir = autotest._get_autodir(host) |
mbligh | 6102a36 | 2007-12-19 15:50:50 +0000 | [diff] [blame^] | 19 | if autodir: |
| 20 | print 'Checking diskspace for %s on %s' % (machine, autodir) |
| 21 | check_diskspace(host, autodir, 100) |
| 22 | except AutoservHostError: |
| 23 | raise # only want to raise if it's a space issue |
mbligh | 7f86e0b | 2007-11-24 19:45:07 +0000 | [diff] [blame] | 24 | except: |
mbligh | 6102a36 | 2007-12-19 15:50:50 +0000 | [diff] [blame^] | 25 | pass # autotest dir may not exist, etc. ignore |
mbligh | ed5a410 | 2007-11-20 00:46:41 +0000 | [diff] [blame] | 26 | if "site_verify" in globals(): |
mbligh | 7f86e0b | 2007-11-24 19:45:07 +0000 | [diff] [blame] | 27 | site_verify(host) |
mbligh | ed5a410 | 2007-11-20 00:46:41 +0000 | [diff] [blame] | 28 | |
mbligh | 7f86e0b | 2007-11-24 19:45:07 +0000 | [diff] [blame] | 29 | if len(machines) > 1: |
| 30 | parallel_simple(verify, machines, log=False) |
| 31 | else: |
| 32 | verify(machines[0]) |