- add a server.hosts.base_classes.Host.verify() abstract method
 - add a server.hosts.base_classes.Host.check_diskspace(path, gb) helper method
 - implement verify() in server.hosts.ssh_host.SSHHost, from server.control_segments.verify.verify() function

The point is that the actual verify code is composed of a not so generic
action (check that available diskspace is >20GB) then, if any, run a
site_verify function. This is not as extensible and generic as subclassing
methods  and I was thinking that Host class (and its derivatives) is the
right place to implement machine verification.

The same for repair.

From: Jean Parpaillon <jean.parpaillon@kerlabs.com>




git-svn-id: http://test.kernel.org/svn/autotest/trunk@2211 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/control_segments/verify b/server/control_segments/verify
index 42593b0..ce64d39 100644
--- a/server/control_segments/verify
+++ b/server/control_segments/verify
@@ -1,32 +1,7 @@
-def check_diskspace(host, path, gb):
-	df = host.run('df -mP %s | tail -1' % path).stdout.split()
-	free_space_gb = int(df[3])/1000.0
-	if free_space_gb < gb:
-		raise AutoservHostError('Not enough free space on ' +
-					'%s - %.3fGB free, want %.3fGB' % 
-					(path, free_space_gb, gb))
-
-
-# This needs more stuff in it. Check for diskspace, etc. But it's a start.
 def verify(machine):
 	print 'Initializing host ' + machine
 	host = hosts.create_host(machine, initialize=False)
-	print 'Pinging host ' + machine
-	sys.stdout.flush()
-	host.ssh_ping()
-	print 'Getting autodir for ' + machine
-	autodir = None
-	try:
-		autodir = autotest._get_autodir(host)
-		if autodir:
-			print 'Checking diskspace for %s on %s' % (machine, 
-								   autodir)
-			check_diskspace(host, autodir, 20)
-	except AutoservHostError:
-		raise		# only want to raise if it's a space issue
-	except:
-		pass		# autotest dir may not exist, etc. ignore
-	if "site_verify" in globals():
-		site_verify(host)
+	host.verify()
+
 
 job.parallel_simple(verify, machines, log=False)