attempt to avoid remote qemus from hanging
[tests.git] / system / TestBox.py
1 # $Id$
2 # this models a box that hosts qemu nodes
3 # could probably also be used for boxes that host plc instances
4 import os.path
5 import utils
6 from TestSsh import TestSsh
7
8 # xxx this should probably inherit TestSsh
9 class TestBox:
10
11     def __init__(self,hostname,buildname,key=None):
12         self.hostname_value=hostname
13         self.buildname=buildname
14         self.key=key
15         self.test_ssh=TestSsh(self.hostname_value,self.buildname,self.key)
16         
17     def hostname (self):
18         return self.hostname_value
19
20     def is_local(self):
21         return self.test_ssh.is_local()
22     
23     def tar_logs(self):
24         if os.path.isdir("nodeslogs"):
25             tar_command="tar cvf nodeslogs.tar nodeslogs/"
26             self.run_in_buildname (tar_command)
27             return True
28         return False
29     
30     def run_in_buildname (self,command,background=False):
31         utils.header("Running command %s on testbox %s"%(command,self.hostname()))
32         return self.test_ssh.run_in_buildname (command,background)
33
34     # should use rsync instead
35     def copy (self,local_file,recursive=False):
36         return self.test_ssh.copy (local_file,recursive)
37
38     def clean_dir (self,dirname):
39         return self.test_ssh.clean_dir(dirname)
40
41     def mkdir (self,dirname):
42         return self.test_ssh.mkdir(dirname)
43
44     def kill_all_qemus(self):
45         self.run_in_buildname("template-qemu/kill-qemu-node")
46         return True
47
48     def list_all_qemus(self):
49         self.run_in_buildname("template-qemu/kill-qemu-node -l")
50         return True
51