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