X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=system%2FTestBox.py;h=978344c3f504aab45829bc0f85c25ae92e985ada;hb=560938db174121e93854fd39b66d29be86769864;hp=088922a28de667e6004ef1bd322f3b1a5ea321f2;hpb=a9667f299fa2d90fa59458d8b5368a10cf70f628;p=tests.git diff --git a/system/TestBox.py b/system/TestBox.py index 088922a..978344c 100644 --- a/system/TestBox.py +++ b/system/TestBox.py @@ -1,23 +1,44 @@ # $Id$ # this models a box that hosts qemu nodes # could probably also be used for boxes that host plc instances +import os.path import utils +from TestSsh import TestSsh +# xxx this should probably inherit TestSsh class TestBox: - def __init__(self,hostname,key=None): - self.hostname=hostname + def __init__(self,hostname,buildname,key=None): + self.hostname_value=hostname + self.buildname=buildname self.key=key - - def run (self,command): - if self.hostname == "localhost": - return utils.system(command) - else: - if self.key: - to_run="ssh -i %s.rsa %s %s"%(self.key,self.hostname,command) - else: - to_run="ssh %s %s"%(self.hostname,command) - return utils.system(to_run) + self.test_ssh=TestSsh(self.hostname_value,self.buildname,self.key) + def hostname (self): + return self.hostname_value + + def is_local(self): + return self.test_ssh.is_local() + + def run_in_buildname (self,command,background=False): + utils.header("Running command %s on testbox %s"%(command,self.hostname())) + return self.test_ssh.run_in_buildname (command,background) + + # xxx could/should use rsync instead + def copy (self,local_file,recursive=False): + return self.test_ssh.copy (local_file,recursive) + + def clean_dir (self,dirname): + return self.test_ssh.clean_dir(dirname) + + def mkdir (self,dirname): + return self.test_ssh.mkdir(dirname) + def kill_all_qemus(self): - self.run("killall qemu") + self.run_in_buildname("template-qemu/qemu-kill-node") + return True + + def list_all_qemus(self): + self.run_in_buildname("template-qemu/qemu-kill-node -l") + return True +