Changeset 156 for trunk


Ignore:
Timestamp:
Oct 9, 2007, 3:42:04 PM (17 years ago)
Author:
tabbott
Message:

Make lvcreate-all work.

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  
    1313
    1414subcommand = sys.argv[1]
    15 machine = sys.argv[2]
    16 disk = sys.argv[3]
    17 lvname = prefix + machine + "_" + disk
    18 lvpath = "/dev/" + vg + "/" + lvname
    1915
    2016def ensureoff(machine):
     
    2218    rv = call(["/usr/sbin/xm", "destroy", prefix + machine])
    2319
     20if 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)
     36else:
     37    machine = sys.argv[2]
     38    disk = sys.argv[3]
     39    lvname = prefix + machine + "_" + disk
     40    lvpath = "/dev/" + vg + "/" + lvname
    2441if subcommand == "lvremove":
    2542    rv = call(["/sbin/lvremove", "--force", lvpath])
     
    5168        sys.exit(1)
    5269   
    53 elif subcommand == "lvcreate-all":
    54     from sipb_xen_database import *
    55     import re
    56     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_name
    62         if not os.path.exists("/dev/%s/%s" % (vg, lvname)):
    63             # LV doesn't exist
    64             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)
    6970
Note: See TracChangeset for help on using the changeset viewer.