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 'vserver': None, # vserver where this node lives
14 'type': 'virtual', # type of node
15 'nodenetworks': [], # node networks
16 'homedir': '/var/VirtualMachines/',
17 'rootkey': '/home/tmack/.ssh/plc-root' # path to root ssh key
20 def __init__(self, config, fields = {}):
22 # XX Filter out fields not specified in fields
23 dict.__init__(self, self.fields)
25 # Merge defined fields with defaults
29 def create_boot_image(self):
32 if self['host'] and self['host'] not in ['localhost']:
33 command += "ssh -i %s root@%s " % (self['rootkey'], self['host'])
35 def create_disk_image(self, size = '10G'):
36 diskimg_path = self['homedir'] + os.sep + self['hostname'] + os.sep + \
39 command += " qemu-img create -f qcow2 %(diskimg_path)s %(size)s " % locals()
41 #utils.header(command)
42 (status, output) = self.commands(command, True)
50 class Nodes(list, Table):
52 def __init__(self, config, nodes):
53 nodelist = [Node(config, node) for node in nodes]
54 list.__init__(self, nodelist)