Changeset 156
- Timestamp:
- Oct 9, 2007, 3:42:04 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-lvm
r155 r156 13 13 14 14 subcommand = sys.argv[1] 15 machine = sys.argv[2]16 disk = sys.argv[3]17 lvname = prefix + machine + "_" + disk18 lvpath = "/dev/" + vg + "/" + lvname19 15 20 16 def ensureoff(machine): … … 22 18 rv = call(["/usr/sbin/xm", "destroy", prefix + machine]) 23 19 20 if subcommand == "lvcreate-all": 21 from sipb_xen_database import * 22 import re 23 connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen') 24 for d in Disk.select(): 25 check(re.match('^[A-Za-z0-9]+$', d.guest_device_name)) 26 machine = Machine.get(d.machine_id) 27 check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name)) 28 lvname = prefix + machine.name + "_" + d.guest_device_name 29 if not os.path.exists("/dev/%s/%s" % (vg, lvname)): 30 # LV doesn't exist 31 print >>sys.stderr, "Creating LV %s..." % (lvname,) 32 rv = call(["/sbin/lvcreate", "-L", str(d.size) + "M", "-n", lvname, vg]) 33 if rv != 0: 34 print >>sys.stderr, "Error creating LV %s\n" %(lvname,) 35 sys.exit(1) 36 else: 37 machine = sys.argv[2] 38 disk = sys.argv[3] 39 lvname = prefix + machine + "_" + disk 40 lvpath = "/dev/" + vg + "/" + lvname 24 41 if subcommand == "lvremove": 25 42 rv = call(["/sbin/lvremove", "--force", lvpath]) … … 51 68 sys.exit(1) 52 69 53 elif subcommand == "lvcreate-all":54 from sipb_xen_database import *55 import re56 connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')57 for d in Disk.select():58 check(re.match('^[A-Za-z0-9]+$', d.guest_device_name))59 machine = Machine.get(d.machine_id)60 check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name))61 lvname = prefix + machine.name + "_" + d.guest_device_name62 if not os.path.exists("/dev/%s/%s" % (vg, lvname)):63 # LV doesn't exist64 print >>sys.stderr, "Creating LV %s..." % (lvname,)65 rv = call(["/sbin/lvcreate", "-L", str(d.size) + "M", "-n", lvname, vg])66 if rv != 0:67 print >>sys.stderr, "Error creating LV %s\n" %(lvname,)68 sys.exit(1)69 70
Note: See TracChangeset
for help on using the changeset viewer.