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
|
Rev | Line | |
---|
[101] | 1 | # -*- mode: python; -*- |
---|
[24] | 2 | import sipb_xen_database.models as models |
---|
[85] | 3 | from sipb_xen_database import connect |
---|
[24] | 4 | |
---|
[99] | 5 | connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen') |
---|
[85] | 6 | # `machine_name' should get passed in from the xm create call |
---|
[24] | 7 | |
---|
[85] | 8 | machine = models.Machine.get_by(name=machine_name) |
---|
[65] | 9 | machine_type = models.Type.get_by(type_id=machine.type_id) |
---|
[24] | 10 | |
---|
| 11 | memory = machine.memory |
---|
| 12 | maxmem = memory |
---|
| 13 | name = machine.name |
---|
| 14 | uuid = machine.uuid |
---|
| 15 | |
---|
| 16 | vcpus = machine.cpus |
---|
| 17 | |
---|
[65] | 18 | diskioemu = "" |
---|
| 19 | viftype = "" |
---|
[24] | 20 | |
---|
[65] | 21 | if machine_type.hvm: |
---|
| 22 | ioemu = "ioemu:" |
---|
[101] | 23 | viftype = "type=ioemu, " |
---|
[65] | 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: |
---|
[101] | 41 | d = '%smac=%s, ip=%s, bridge=xenbr0, script=vif-sipbroute' % (viftype, n.mac_addr, n.ip) |
---|
[84] | 42 | vif.append(d) |
---|
[65] | 43 | |
---|
[24] | 44 | disk = [] |
---|
| 45 | |
---|
| 46 | for d in machine.disks: |
---|
[65] | 47 | device = 'xenvg/' + machine.name + '_' + d.guest_device_name |
---|
| 48 | dspec = 'phy:%s,%s%s,w' % (device, diskioemu, d.guest_device_name) |
---|
[24] | 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.