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

Last change on this file since 101 was 101, checked in by nelhage, 17 years ago

Fix the vif generation for non-hvms

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    device_model = 'qemu-dm'
29else:
30    kernel  = '/boot/vmlinuz-2.6.18-4-xen-amd64'
31    ramdisk = '/boot/initrd.img-2.6.18-4-xen-amd64'
32    builder = 'linux'
33
34pae = machine_type.pae
35acpi = machine_type.acpi
36apic = machine_type.apic
37
38vif = []
39
40for n in machine.nics:
41    d = '%smac=%s, ip=%s, bridge=xenbr0, script=vif-sipbroute' % (viftype, n.mac_addr, n.ip)
42    vif.append(d)
43
44disk = []
45
46for d in machine.disks:
47    device = 'xenvg/' + machine.name + '_' + d.guest_device_name
48    dspec = 'phy:%s,%s%s,w' % (device, diskioemu, d.guest_device_name)
49    disk.append(dspec)
50
51restart = 'destroy'
52if machine.autorestart:
53    restart = 'restart'
54
55on_poweroff = 'destroy'
56on_reboot = 'restart'
57on_crash = restart
Note: See TracBrowser for help on using the repository browser.