Prevent double hyphens in thin_pool parsing

This commit is contained in:
Frédéric Pierret (fepitre) 2020-05-15 15:15:37 +02:00
parent 71159bfca2
commit e4d7df4976
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2

View File

@ -932,8 +932,13 @@ class DirectoryThinPool:
.format(thin_pool_devnum), "r") as thin_pool_tpool_f: .format(thin_pool_devnum), "r") as thin_pool_tpool_f:
thin_pool_tpool = thin_pool_tpool_f.read().rstrip('\n') thin_pool_tpool = thin_pool_tpool_f.read().rstrip('\n')
if thin_pool_tpool.endswith("-tpool"): if thin_pool_tpool.endswith("-tpool"):
# LVM replaces '-' by '--' if name contains
# a hyphen
thin_pool_tpool = thin_pool_tpool.replace('--', '=')
volume_group, thin_pool, _tpool = \ volume_group, thin_pool, _tpool = \
thin_pool_tpool.rsplit("-", 2) thin_pool_tpool.rsplit("-", 2)
volume_group = volume_group.replace('=', '-')
thin_pool = thin_pool.replace('=', '-')
cls._thin_pool[dir_path] = volume_group, thin_pool cls._thin_pool[dir_path] = volume_group, thin_pool
except: # pylint: disable=bare-except except: # pylint: disable=bare-except
pass pass