v6, with a script to autocreate any new logical volumes
[invirt/packages/invirt-database.git] / client / usr / bin / sipb-xen-lvcreate
1 #!/usr/bin/env python
2
3 from sipb_xen_database import *
4 import sys
5 import os.path
6 from subprocess import call
7
8 connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
9
10 vg = "xenvg"
11 for d in Disk.select():
12     machine = Machine.get(d.machine_id)
13     lvname = machine.name + "_" + d.guest_device_name
14     if not os.path.exists("/dev/%s/%s" % (vg, lvname)):
15         # LV doesn't exist
16         print >>sys.stderr, "Creating LV %s..." % (lvname,)
17         rv = call(["lvcreate", "-L", str(d.size) + "M", "-n", lvname, vg])
18         if rv != 0:
19             print >>sys.stderr, "Error creating LV %s\n" %(lvname,)