Changeset 109
- Timestamp:
- Oct 7, 2007, 2:45:37 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-database/sipb-xen-database/client/etc/xen/sipb-database
r104 r109 2 2 import sipb_xen_database.models as models 3 3 from sipb_xen_database import connect 4 import re 5 import sys 4 6 5 7 connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen') 6 # `machine_name' should get passed in from the xm create call 8 9 # 'machine_name', and optionally 'cdrom_image', should get passed in 10 # from the xm create call 11 12 def check(b): 13 if not b: 14 exit(1) 7 15 8 16 machine = models.Machine.get_by(name=machine_name) 17 check(machine is not None) 9 18 machine_type = models.Type.get_by(type_id=machine.type_id) 10 19 11 20 memory = machine.memory 12 21 maxmem = memory 22 check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name)) 13 23 name = machine.name 24 check(re.match('^[0-9a-f-]+$', machine.uuid)) 14 25 uuid = machine.uuid 15 26 … … 40 51 41 52 for n in machine.nics: 53 check(re.match('^[0-9a-fA-F:]+$', n.mac_addr) and re.match('^[0-9.]*$', n.ip)) 42 54 d = '%smac=%s, ip=%s, bridge=xenbr0, script=vif-sipbroute' % (viftype, n.mac_addr, n.ip) 43 55 vif.append(d) … … 46 58 47 59 for d in machine.disks: 60 check(re.match('^[A-Za-z0-9]+$', d.guest_device_name)) 48 61 device = '/dev/xenvg/' + machine.name + '_' + d.guest_device_name 49 62 dspec = 'phy:%s,%s%s,w' % (device, diskioemu, d.guest_device_name) 50 63 disk.append(dspec) 51 64 52 restart = 'destroy' 53 if machine.autorestart: 54 restart = 'restart' 65 if 'cdrom_image' in locals(): 66 check(re.match('^[A-Za-z0-9][A-Za-z0-9_.-]*$', cdrom_image)) 67 disk.append('file:/srv/images/' + cdrom_image + '.iso,hdc:cdrom,r') 68 boot = 'd' 55 69 56 70 on_poweroff = 'destroy' 57 71 on_reboot = 'restart' 58 on_crash = restart 72 on_crash = 'destroy' 73 if machine.autorestart: 74 on_crash = 'restart'
Note: See TracChangeset
for help on using the changeset viewer.