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; -*- |
---|
2 | import sipb_xen_database.models as models |
---|
3 | from sipb_xen_database import connect |
---|
4 | |
---|
5 | connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen') |
---|
6 | # `machine_name' should get passed in from the xm create call |
---|
7 | |
---|
8 | machine = models.Machine.get_by(name=machine_name) |
---|
9 | machine_type = models.Type.get_by(type_id=machine.type_id) |
---|
10 | |
---|
11 | memory = machine.memory |
---|
12 | maxmem = memory |
---|
13 | name = machine.name |
---|
14 | uuid = machine.uuid |
---|
15 | |
---|
16 | vcpus = machine.cpus |
---|
17 | |
---|
18 | diskioemu = "" |
---|
19 | viftype = "" |
---|
20 | |
---|
21 | if 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' |
---|
29 | else: |
---|
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 | |
---|
34 | pae = machine_type.pae |
---|
35 | acpi = machine_type.acpi |
---|
36 | apic = machine_type.apic |
---|
37 | |
---|
38 | vif = [] |
---|
39 | |
---|
40 | for 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 | |
---|
44 | disk = [] |
---|
45 | |
---|
46 | for 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 | |
---|
51 | restart = 'destroy' |
---|
52 | if machine.autorestart: |
---|
53 | restart = 'restart' |
---|
54 | |
---|
55 | on_poweroff = 'destroy' |
---|
56 | on_reboot = 'restart' |
---|
57 | on_crash = restart |
---|
Note: See
TracBrowser
for help on using the repository browser.