source: trunk/packages/sipb-xen-database/sipb-xen-database/client/etc/xen/sipb-database @ 104

Last change on this file since 104 was 104, checked in by andersk, 17 years ago

Stuff that works is happy.

File size: 1.3 KB
Line 
1# -*- mode: python; -*-
2import sipb_xen_database.models as models
3from sipb_xen_database import connect
4
5connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
6# `machine_name' should get passed in from the xm create call
7
8machine = models.Machine.get_by(name=machine_name)
9machine_type = models.Type.get_by(type_id=machine.type_id)
10
11memory = machine.memory
12maxmem = memory
13name = machine.name
14uuid = machine.uuid
15
16vcpus = machine.cpus
17
18diskioemu = ""
19viftype = ""
20
21if machine_type.hvm:
22    ioemu = "ioemu:"
23    viftype = "type=ioemu, "
24
25    kernel = 'hvmloader'
26    builder = 'hvm'
27    vnc = 1
28    vncpasswd = 'moocow'
29    device_model = '/usr/sbin/qemu-dm-sipb'
30else:
31    kernel  = '/boot/vmlinuz-2.6.18-4-xen-amd64'
32    ramdisk = '/boot/initrd.img-2.6.18-4-xen-amd64'
33    builder = 'linux'
34
35pae = machine_type.pae
36acpi = machine_type.acpi
37apic = machine_type.apic
38
39vif = []
40
41for n in machine.nics:
42    d = '%smac=%s, ip=%s, bridge=xenbr0, script=vif-sipbroute' % (viftype, n.mac_addr, n.ip)
43    vif.append(d)
44
45disk = []
46
47for d in machine.disks:
48    device = '/dev/xenvg/' + machine.name + '_' + d.guest_device_name
49    dspec = 'phy:%s,%s%s,w' % (device, diskioemu, d.guest_device_name)
50    disk.append(dspec)
51
52restart = 'destroy'
53if machine.autorestart:
54    restart = 'restart'
55
56on_poweroff = 'destroy'
57on_reboot = 'restart'
58on_crash = restart
Note: See TracBrowser for help on using the repository browser.