X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2FTestBox.py;h=7622d9e0fd1970339e35bdcda121828fa8d80087;hb=4b800cb86c9f9e88044f53e18af601d410439b33;hp=7b6fa6bcbbdf282a4b9b178304fa57d727f1b7a5;hpb=df8006feda3e410f0ce2757ceb5e41ed8c5d8d63;p=tests.git diff --git a/system/TestBox.py b/system/TestBox.py index 7b6fa6b..7622d9e 100644 --- a/system/TestBox.py +++ b/system/TestBox.py @@ -1,54 +1,49 @@ -# $Id$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # 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,buildname,key=None): self.hostname_value=hostname self.buildname=buildname self.key=key - + self.test_ssh=TestSsh(self.hostname_value,self.buildname,self.key) + def hostname (self): return self.hostname_value def is_local(self): - return utils.is_local (self.hostname()) - - def run_in_buildname (self,command): - if self.is_local(): - return utils.system(command) - ssh_comand="ssh " - if self.key: - ssh_comand += "-i %s.rsa "%(self.key) - ssh_command += "%s/%s"%(self.buildname,utils.backslash_shell_specials(command)) - return utils.system(ssh_command) - - # should use rsync instead + return self.test_ssh.is_local() + + def run_in_buildname (self,command,background=False): + message="On %s: running %s"%(self.hostname(),command) + if background: message += " &" + utils.header(message) + return self.test_ssh.run_in_buildname (command,background) + + # xxx could/should use rsync instead def copy (self,local_file,recursive=False): - if self.is_local(): - return 0 - command="scp " - if recursive: command += "-r " - if self.key: - command += "-i %s.rsa " - command +="%s %s:%s/%s"%(local_file,self.hostname(),self.buildname, - os.path.basename(local_file) or ".") - return utils.system(command) - - def clean_dir (self): - if self.is_local(): - return 0 - return utils.system("rm -rf %s"%self.buildname) - - def mkdir (self): - if self.is_local(): - return 0 - return utils.system("mkdir %s"%self.buildname) - - def kill_all_qemus(self): - self.run_in_buildname("killall qemu") + 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) + + # we need at least one nodename, as template-qemu is not synced on remote testboxes + def qemu_kill_all(self,nodedir): + self.run_in_buildname("%s/qemu-kill-node"%nodedir) + return True + + def qemu_list_all(self): + self.run_in_buildname("template-qemu/qemu-kill-node -l") + return True