def _RemoveBlockDevLinks(instance_name, disks):
  """Remove the block device symlinks belonging to the given instance.

  """
  def _remove_symlink(link_name):
    if os.path.islink(link_name):
      try:
        os.remove(link_name)
      except __HOLE__:
        logging.exception("Can't remove symlink '%s'", link_name)

  for idx, disk in enumerate(disks):
    link_name = _GetBlockDevSymlinkPath(instance_name, uuid=disk.uuid)
    _remove_symlink(link_name)
    # Remove also the deprecated symlink (if any)
    link_name = _GetBlockDevSymlinkPath(instance_name, idx=idx)
    _remove_symlink(link_name)
dataset/ETHPy150Open ganeti/ganeti/lib/backend.py/_RemoveBlockDevLinks