3 from Remote import Remote
4 from Table import Table
7 class Node(dict, Remote):
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
21 def __init__(self, config, fields = {}):
23 # XX Filter out fields not specified in fields
24 dict.__init__(self, self.fields)
26 # Merge defined fields with defaults
30 def host_popen(self, command, fatal = True):
31 command = self.get_host_command(command)
32 return utils.popen(command, fatal, self.config.verbose)
34 def host_popen3(self, command):
35 command = self.get_host_command(command)
36 return utils.popen3(command, self.config.verbose)
38 def host_commands(self, command, fatal = True):
39 command = self.get_host_command(command)
40 return utils.commands(command, fatal, self.config.verbose)
42 class Nodes(list, Table):
44 def __init__(self, config, nodes):
45 nodelist = [Node(config, node) for node in nodes]
46 list.__init__(self, nodelist)