1 # -*- mode: python; -*-
2 from invirt.database import models, connect
3 from invirt.config import structs as config
6 from subprocess import call
11 # 'machine_name', and optionally 'cdrom_image', should get passed in
12 # from the xm create call
19 machine = models.Machine.query().filter_by(name=machine_name).one()
20 check(machine is not None)
21 machine_type = models.Type.query().filter_by(type_id=machine.type_id).one()
23 memory = machine.memory
25 check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name))
26 name = prefix + machine.name
27 check(re.match('^[0-9a-f-]+$', machine.uuid))
35 pae = machine_type.pae
36 acpi = machine_type.acpi
37 apic = machine_type.apic
48 if 'mirror' in locals(): #Installer
49 disk.append('phy:/dev/xenvg/s_install_hda,hdb,r')
51 kernel = '/boot/vmlinuz-2.6.24-19-xen' #From hardy
52 ramdisk = '/boot/initrd.img-2.6.24-19-xen'
55 raise RuntimeError('You must have a nic to autoinstall')
58 extra += (' ip=%s::%s:%s:%s:eth0:off'
59 % (n.ip, config.dhcp.gateway, config.dhcp.netmask, machine.name))
60 extra += ' mirror=%s dist=%s' % (mirror, dist)
61 extra += ' imagesize=%s' % imagesize
62 if 'noinstall' in locals():
66 elif 'cdrom_image' in locals():
67 check(re.match('^[A-Za-z0-9][A-Za-z0-9_.-]*$', cdrom_image))
68 disk.append('phy:/srv/images/' + cdrom_image + '.iso,hdc:cdrom,r')
74 viftype = "type=ioemu, "
75 kernel = '/usr/lib/xen/boot/hvmloader'
79 device_model = '/usr/sbin/qemu-dm-sipb'
81 elif codepath == 'paravm':
82 bootloader = '/usr/lib/xen-default/bin/pygrub'
85 for n in machine.nics:
86 check(re.match('^[0-9a-fA-F:]+$', n.mac_addr) and re.match('^[0-9.]*$', n.ip))
87 d = '%smac=%s, ip=%s, bridge=xenbr0, script=vif-sipbroute' % (viftype, n.mac_addr, n.ip)
90 for d in machine.disks:
91 check(re.match('^[A-Za-z0-9]+$', d.guest_device_name))
92 device = '/dev/xenvg/' + prefix + machine.name + '_' + d.guest_device_name
93 dspec = 'phy:%s,%s%s,w' % (device, diskioemu, d.guest_device_name)
98 on_poweroff = 'destroy'
101 if machine.autorestart: