+if subcommand == "lvcreate-all":
+ from invirt import database
+ import re
+ database.connect()
+ for d in Disk.select():
+ check(re.match('^[A-Za-z0-9]+$', d.guest_device_name))
+ machine = Machine.get(d.machine_id)
+ check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name))
+ lvname = prefix + machine.name + "_" + d.guest_device_name
+ if not os.path.exists("/dev/%s/%s" % (vg, lvname)):
+ # LV doesn't exist
+ print >>sys.stderr, "Creating LV %s..." % (lvname,)
+ rv = call(["/sbin/lvcreate", "-L", str(d.size) + "M", "-n", lvname, vg])
+ if rv != 0:
+ print >>sys.stderr, "Error creating LV %s\n" %(lvname,)
+ sys.exit(1)
+else:
+ machine = sys.argv[2]
+ disk = sys.argv[3]
+ lvname = prefix + machine + "_" + disk
+ lvpath = "/dev/" + vg + "/" + lvname