Fixed lv deactivation for rename dvorak42 precise-prod 0.0.6
authorSteven Valdez <dvorak42@mit.edu>
Thu, 1 Aug 2013 08:30:05 +0000 (04:30 -0400)
committerSteven Valdez <dvorak42@mit.edu>
Thu, 1 Aug 2013 08:40:07 +0000 (04:40 -0400)
debian/changelog
invirt-images

index 6fd8e36..1dd7308 100644 (file)
@@ -1,3 +1,9 @@
+invirt-images (0.0.6) precise; urgency=low
+
+  * Fixing images for new lv setup to deactivate volumes before modifying.
+
+ -- Steven Valdez <dvorak42@mit.edu>  Thu, 01 Aug 2013 04:29:37 -0400
+
 invirt-images (0.0.5) precise; urgency=low
 
   * Updating version for precise migration.
index ea208a5..e6f987d 100755 (executable)
@@ -41,19 +41,39 @@ def lvcreate(name, size):
         return 6
 
 def lvrename(dest, src):
-    lvr = subprocess.Popen(['lvrename', 'xenvg', src, dest],
+    lvr = subprocess.Popen(['lvchange', '-an', "xenvg/%s" % (src,)],
                            stderr=subprocess.PIPE,
                            stdout=getOutput()['stdout'])
     ret = lvr.wait()
-    if not ret:
-        return 0
-    stderr = lvr.stderr.read()
-    if 'not found in volume group' in stderr:
-        return 0
-    else:
+
+    if ret:
+       if verbosity > 0:
+           print lvr.stderr.read()
+       return ret
+
+    lvr = subprocess.Popen(['lvrename', "xenvg/%s" % (src,), "xenvg/%s" % (dest,)],
+                           stderr=subprocess.PIPE,
+                           stdout=getOutput()['stdout'])
+    ret = lvr.wait()
+
+    if ret:
+        stderr = lvr.stderr.read()
+        if not ('not found in volume group' in stderr):
+            if verbosity > 0:
+                print stderr
+            return ret
+
+    subprocess.Popen(['lvchange', '-ay', "xenvg/%s" % (dest,)],
+                     stderr=subprocess.PIPE,
+                     stdout=getOutput()['stdout'])
+    ret = lvr.wait()
+
+    if ret:
         if verbosity > 0:
-            print stderr
-        return ret
+           print lvr.stderr.read()
+
+    return ret
+
 
 def lv_random(func, pattern, *args):
     """