qa: fix RemoveInstanceOfflineNode for file-based
authorGuido Trotter <ultrotter@google.com>
Sun, 7 Apr 2013 02:23:58 +0000 (04:23 +0200)
committerGuido Trotter <ultrotter@google.com>
Sun, 7 Apr 2013 11:59:23 +0000 (13:59 +0200)
- The cleanup should only happen for non externally mirrored disk
  templates
- It should behave differently for file and lvm based instances
- It should definitely *not* be explicit in the qa file :/ (but it's
  more important to fix qa, as of now)

Also fix a typo in the same function's docstring.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

qa/qa_instance.py

index 0f3b877..f331b5d 100644 (file)
@@ -888,7 +888,7 @@ def TestBackupListFields():
 
 
 def TestRemoveInstanceOfflineNode(instance, snode, set_offline, set_online):
-  """gtn-instance remove with an off-line node
+  """gnt-instance remove with an off-line node
 
   @param instance: instance
   @param snode: secondary node, to be set offline
@@ -902,7 +902,15 @@ def TestRemoveInstanceOfflineNode(instance, snode, set_offline, set_online):
     TestInstanceRemove(instance)
   finally:
     set_online(snode)
-  # Clean up the disks on the offline node
-  for minor in info["drbd-minors"][snode.primary]:
-    AssertCommand(["drbdsetup", str(minor), "down"], node=snode)
-  AssertCommand(["lvremove", "-f"] + info["volumes"], node=snode)
+
+  # Clean up the disks on the offline node, if necessary
+  if instance.disk_template not in constants.DTS_EXT_MIRROR:
+    # FIXME: abstract the cleanup inside the disks
+    if info["storage-type"] == constants.ST_LVM_VG:
+      for minor in info["drbd-minors"][snode.primary]:
+        AssertCommand(["drbdsetup", str(minor), "down"], node=snode)
+      AssertCommand(["lvremove", "-f"] + info["volumes"], node=snode)
+    elif info["storage-type"] == constants.ST_FILE:
+      filestorage = pathutils.DEFAULT_FILE_STORAGE_DIR
+      disk = os.path.join(filestorage, instance.name)
+      AssertCommand(["rm", "-rf", disk], node=snode)