Fix the _RemoveBlockDevLinks() function
authorIustin Pop <iustin@google.com>
Mon, 23 Jun 2008 13:22:12 +0000 (13:22 +0000)
committerIustin Pop <iustin@google.com>
Mon, 23 Jun 2008 13:22:12 +0000 (13:22 +0000)
This fixes the removal of the instance symlinks (probably breakage from
the glob changes).

Reviewed-by: imsnah

lib/backend.py

index 911cd83..f93b28e 100644 (file)
@@ -582,12 +582,14 @@ def _RemoveBlockDevLinks(instance_name):
   """Remove the block device symlinks belonging to the given instance.
 
   """
-  for i in os.listdir(constants.DISK_LINKS_DIR):
-    if os.path.islink(i) and i.startswith('%s-' % instance_name):
+  for short_name in os.listdir(constants.DISK_LINKS_DIR):
+    link_name = os.path.join(constants.DISK_LINKS_DIR, short_name)
+    if (os.path.islink(link_name) and
+        short_name.startswith('%s-' % instance_name)):
       try:
-        os.remove(link)
-      except OSError, e:
-        pass # Ignore errors when removing the symlinks
+        os.remove(link_name)
+      except OSError, err:
+        logger.Error("Can't remove symlink '%s': %s" % (link_name, err))
 
 
 def _GatherAndLinkBlockDevs(instance):