Last change
on this file since 330 was
142,
checked in by tabbott, 17 years ago
|
throw error when disk creation fails
|
-
Property svn:executable set to
*
|
File size:
813 bytes
|
Line | |
---|
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 | import re |
---|
8 | |
---|
9 | connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen') |
---|
10 | |
---|
11 | def check(b): |
---|
12 | if not b: |
---|
13 | exit(1) |
---|
14 | |
---|
15 | vg = "xenvg" |
---|
16 | for d in Disk.select(): |
---|
17 | check(re.match('^[A-Za-z0-9]+$', d.guest_device_name)) |
---|
18 | machine = Machine.get(d.machine_id) |
---|
19 | check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name)) |
---|
20 | lvname = machine.name + "_" + d.guest_device_name |
---|
21 | if not os.path.exists("/dev/%s/%s" % (vg, lvname)): |
---|
22 | # LV doesn't exist |
---|
23 | print >>sys.stderr, "Creating LV %s..." % (lvname,) |
---|
24 | rv = call(["lvcreate", "-L", str(d.size) + "M", "-n", lvname, vg]) |
---|
25 | if rv != 0: |
---|
26 | print >>sys.stderr, "Error creating LV %s\n" %(lvname,) |
---|
27 | sys.exit(1) |
---|
Note: See
TracBrowser
for help on using the repository browser.