v6, with a script to autocreate any new logical volumes
[invirt/packages/invirt-database.git] / client / usr / bin / sipb-xen-lvcreate
diff --git a/client/usr/bin/sipb-xen-lvcreate b/client/usr/bin/sipb-xen-lvcreate
new file mode 100755 (executable)
index 0000000..25c5942
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+from sipb_xen_database import *
+import sys
+import os.path
+from subprocess import call
+
+connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
+
+vg = "xenvg"
+for d in Disk.select():
+    machine = Machine.get(d.machine_id)
+    lvname = 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(["lvcreate", "-L", str(d.size) + "M", "-n", lvname, vg])
+        if rv != 0:
+            print >>sys.stderr, "Error creating LV %s\n" %(lvname,)