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
17 'nodenetworks': [], # node networks
18 'homedir': '/var/VirtualMachines/',
19 'rootkey': None # path to root ssh key
22 def __init__(self, config, fields = {}):
24 # XX Filter out fields not specified in fields
25 dict.__init__(self, self.fields)
27 # Merge defined fields with defaults
31 def host_popen(self, command, fatal = True):
32 command = self.get_host_command(command)
33 return utils.popen(command, fatal, self.config.verbose)
35 def host_popen3(self, command):
36 command = self.get_host_command(command)
37 return utils.popen3(command, self.config.verbose)
39 def host_commands(self, command, fatal = True):
40 command = self.get_host_command(command)
41 return utils.commands(command, fatal, self.config.verbose)
43 class Nodes(list, Table):
45 def __init__(self, config, nodes):
46 nodelist = [Node(config, node) for node in nodes]
47 list.__init__(self, nodelist)