added methods for interacting with host machine
[tests.git] / qaapi / qa / Nodes.py
1 import utils
2 import os
3 from Remote import Remote
4 from Table import Table
5
6
7 class Node(dict, Remote):
8
9     fields = {
10         'plc': None,
11         'hostname': None,               # Node Hostname
12         'host': 'localhost',            # host where node lives
13         'redir_port': None,             # Port on host where ssh is redirected to virtual node
14         'vserver': None,                # vserver where this node lives
15         'type': 'vm',                   # type of node
16         'nodenetworks': [],             # node networks
17         'homedir': '/var/VirtualMachines/',
18         'rootkey': None                  # path to root ssh key
19         }
20
21     def __init__(self, config, fields = {}):
22
23         # XX Filter out fields not specified in fields
24         dict.__init__(self, self.fields)
25         
26         # Merge defined fields with defaults
27         self.update(fields)
28         self.config = config
29
30     def host_popen(self, command, fatal = True):
31         command = self.get_host_command(command)
32         return utils.popen(command, fatal, self.config.verbose)
33
34     def host_popen3(self, command):
35         command = self.get_host_command(command)
36         return utils.popen3(command, self.config.verbose)
37
38     def host_commands(self, command, fatal = True):
39         command = self.get_host_command(command)
40         return utils.commands(command, fatal, self.config.verbose)    
41          
42 class Nodes(list, Table):
43
44     def __init__(self, config, nodes):
45         nodelist = [Node(config, node) for node in nodes]
46         list.__init__(self, nodelist)
47         self.config = config
48