changed call parameters. Accept a dict of config options rather than single config...
[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         'plcs': ['TestPLC'],
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         'model': '/minhw',
17         'nodenetworks': [],             # node networks
18         'homedir': '/var/VirtualMachines/',
19         'rootkey': None                  # path to root ssh key
20         }
21
22     def __init__(self, config, fields = {}):
23
24         # XX Filter out fields not specified in fields
25         dict.__init__(self, self.fields)
26         
27         # Merge defined fields with defaults
28         self.update(fields)
29         self.config = config
30
31     def host_popen(self, command, fatal = True):
32         command = self.get_host_command(command)
33         return utils.popen(command, fatal, self.config.verbose)
34
35     def host_popen3(self, command):
36         command = self.get_host_command(command)
37         return utils.popen3(command, self.config.verbose)
38
39     def host_commands(self, command, fatal = True):
40         command = self.get_host_command(command)
41         return utils.commands(command, fatal, self.config.verbose)    
42          
43 class Nodes(list, Table):
44
45     def __init__(self, config, nodes):
46         nodelist = [Node(config, node) for node in nodes]
47         list.__init__(self, nodelist)
48         self.config = config
49