088922a28de667e6004ef1bd322f3b1a5ea321f2
[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 utils
5
6 class TestBox:
7
8     def __init__(self,hostname,key=None):
9         self.hostname=hostname
10         self.key=key
11
12     def run (self,command):
13         if self.hostname == "localhost":
14             return utils.system(command)
15         else:
16             if self.key:
17                 to_run="ssh -i %s.rsa %s %s"%(self.key,self.hostname,command)
18             else:
19                 to_run="ssh %s %s"%(self.hostname,command)
20             return utils.system(to_run)
21         
22     def kill_all_qemus(self):
23         self.run("killall qemu")