1 # -*- mode: python; -*-
2 import sipb_xen_database.models as models
3 from sipb_xen_database import connect
6 connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
8 # 'machine_name', and optionally 'cdrom_image', should get passed in
9 # from the xm create call
16 machine = models.Machine.get_by(name=machine_name)
17 check(machine is not None)
18 machine_type = models.Type.get_by(type_id=machine.type_id)
20 memory = machine.memory
22 check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name))
24 check(re.match('^[0-9a-f-]+$', machine.uuid))
34 viftype = "type=ioemu, "
40 device_model = '/usr/sbin/qemu-dm-sipb'
42 kernel = '/boot/vmlinuz-2.6.18-4-xen-amd64'
43 ramdisk = '/boot/initrd.img-2.6.18-4-xen-amd64'
46 pae = machine_type.pae
47 acpi = machine_type.acpi
48 apic = machine_type.apic
52 for n in machine.nics:
53 check(re.match('^[0-9a-fA-F:]+$', n.mac_addr) and re.match('^[0-9.]*$', n.ip))
54 d = '%smac=%s, ip=%s, bridge=xenbr0, script=vif-sipbroute' % (viftype, n.mac_addr, n.ip)
59 for d in machine.disks:
60 check(re.match('^[A-Za-z0-9]+$', d.guest_device_name))
61 device = '/dev/xenvg/' + machine.name + '_' + d.guest_device_name
62 dspec = 'phy:%s,%s%s,w' % (device, diskioemu, d.guest_device_name)
65 if 'cdrom_image' in locals():
66 check(re.match('^[A-Za-z0-9][A-Za-z0-9_.-]*$', cdrom_image))
67 disk.append('file:/srv/images/' + cdrom_image + '.iso,hdc:cdrom,r')
70 on_poweroff = 'destroy'
73 if machine.autorestart: