From 03dfa658bc0377e2d7bff329b5a3969ccd7dc244 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 7 Jan 2009 17:02:12 +0000 Subject: [PATCH] Fix the _RemoveBlockDevLinks() function This is a forward-port of commit 1163 on the 1.2 branch: This fixes the removal of the instance symlinks (probably breakage from the glob changes). Reviewed-by: imsnah --- lib/backend.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 419b9a7d0..45434dcaf 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -768,12 +768,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: + logging.exception("Can't remove symlink '%s'", link_name) def _GatherAndLinkBlockDevs(instance): -- GitLab