1 # -*- mode: python; -*-
2 from invirt.database import models, connect
5 from subprocess import call
10 # 'machine_name', and optionally 'cdrom_image', should get passed in
11 # from the xm create call
18 machine = models.Machine.get_by(name=machine_name)
19 check(machine is not None)
20 machine_type = models.Type.get_by(type_id=machine.type_id)
22 memory = machine.memory
24 check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name))
25 name = prefix + machine.name
26 check(re.match('^[0-9a-f-]+$', machine.uuid))
34 pae = machine_type.pae
35 acpi = machine_type.acpi
36 apic = machine_type.apic
47 if 'mirror' in locals(): #Installer
48 disk.append('phy:/dev/xenvg/d_foobar3_hda,hdb,r')
50 kernel = '/boot/vmlinuz-2.6.24-19-xen' #From hardy
51 ramdisk = '/boot/initrd.img-2.6.24-19-xen'
54 raise RuntimeError('You must have a nic to autoinstall')
57 extra += ' ip=%s::18.181.0.1:255.255.0.0:%s:eth0:off' % (n.ip, machine.name)
58 extra += ' mirror=%s dist=%s' % (mirror, dist)
59 extra += ' imagesize=%s' % imagesize
60 if 'noinstall' in locals():
64 elif 'cdrom_image' in locals():
65 check(re.match('^[A-Za-z0-9][A-Za-z0-9_.-]*$', cdrom_image))
66 disk.append('file:/srv/images/' + cdrom_image + '.iso,hdc:cdrom,r')
72 viftype = "type=ioemu, "
77 device_model = '/usr/sbin/qemu-dm-sipb'
79 elif codepath == 'paravm':
80 bootloader = '/usr/lib/xen-default/bin/pygrub'
83 for n in machine.nics:
84 check(re.match('^[0-9a-fA-F:]+$', n.mac_addr) and re.match('^[0-9.]*$', n.ip))
85 d = '%smac=%s, ip=%s, bridge=xenbr0, script=vif-sipbroute' % (viftype, n.mac_addr, n.ip)
88 for d in machine.disks:
89 check(re.match('^[A-Za-z0-9]+$', d.guest_device_name))
90 device = '/dev/xenvg/' + prefix + machine.name + '_' + d.guest_device_name
91 dspec = 'phy:%s,%s%s,w' % (device, diskioemu, d.guest_device_name)
96 on_poweroff = 'destroy'
99 if machine.autorestart: