From 967a3566b99b42fe71a52c2b6e5be99bfb24718f Mon Sep 17 00:00:00 2001
From: Peter Iannucci <iannucci@mit.edu>
Date: Tue, 28 May 2013 20:21:11 -0400
Subject: [PATCH] Make invirt-lvm lvcreate-all use sqlalchemy correctly.

---
 debian/changelog         |    6 ++++++
 host/usr/sbin/invirt-lvm |    8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9a903b8..9b74add 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+invirt-remote (0.4.14) unstable; urgency=low
+
+  * Make invirt-lvm lvcreate-all use sqlalchemy correctly
+
+ -- Peter A. Iannucci <iannucci@mit.edu>  Tue, 28 May 2013 20:19:00 -0400
+
 invirt-remote (0.4.13) unstable; urgency=low
 
   * Make the listvms remctl include domains that get stuck in pygrub
diff --git a/host/usr/sbin/invirt-lvm b/host/usr/sbin/invirt-lvm
index cae6b2b..6860d9c 100755
--- a/host/usr/sbin/invirt-lvm
+++ b/host/usr/sbin/invirt-lvm
@@ -31,12 +31,12 @@ if machine_specific:
     lvpath = "/dev/" + vg + "/" + lvname
 
 if subcommand == "lvcreate-all":
-    from invirt import database
+    from invirt.database import models, connect
     import re
-    database.connect()
-    for d in Disk.select():
+    connect()
+    for d in models.Disk.query().all():
         check(re.match('^[A-Za-z0-9]+$', d.guest_device_name))
-        machine = Machine.get(d.machine_id)
+        machine = models.Machine.query().filter_by(machine_id=d.machine_id).one()
         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)):
-- 
1.7.9.5