462b152eef888e1716943afc4e2f9cd75e7edd79
[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 run_in_buildname (self,command,background=False):
24         message="On %s: running %s"%(self.hostname(),command)
25         if background: message += " &"
26         utils.header(message)
27         return self.test_ssh.run_in_buildname (command,background)
28
29     # xxx could/should use rsync instead
30     def copy (self,local_file,recursive=False):
31         return self.test_ssh.copy (local_file,recursive)
32
33     def clean_dir (self,dirname):
34         return self.test_ssh.clean_dir(dirname)
35
36     def mkdir (self,dirname):
37         return self.test_ssh.mkdir(dirname)
38
39     # we need at least one nodename, as template-qemu is not synced on remote testboxes
40     def kill_all_qemus(self,nodename):
41         self.run_in_buildname("qemu-%s/qemu-kill-node"%nodename)
42         return True
43
44     def list_all_qemus(self):
45         self.run_in_buildname("template-qemu/qemu-kill-node -l")
46         return True
47