mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #10634 from ahammond/esacpe_dashed_vg_lv_names
dashes in vg or lv names should be escaped
This commit is contained in:
commit
2ed60b0689
@ -93,14 +93,16 @@ def mounted(name,
|
||||
real_device = device
|
||||
|
||||
# LVS devices have 2 names under /dev:
|
||||
# /dev/mapper/vgname-lvname and /dev/vgname/lvname
|
||||
# /dev/mapper/vg--name-lv--name and /dev/vg-name/lv-name
|
||||
# No matter what name is used for mounting,
|
||||
# mount always displays the device as /dev/mapper/vgname-lvname
|
||||
# mount always displays the device as /dev/mapper/vg--name-lv--name
|
||||
# Note the double-dash escaping.
|
||||
# So, let's call that the canonical device name
|
||||
# We should normalize names of the /dev/vgname/lvname type to the canonical name
|
||||
# We should normalize names of the /dev/vg-name/lv-name type to the canonical name
|
||||
m = re.match(r'^/dev/(?P<vg_name>[^/]+)/(?P<lv_name>[^/]+$)', device)
|
||||
if m:
|
||||
mapper_device = '/dev/mapper/{vg_name}-{lv_name}'.format(**m.groupdict())
|
||||
double_dash_escaped = dict((k, re.sub(r'-', '--', v)) for k, v in m.groupdict().iteritems())
|
||||
mapper_device = '/dev/mapper/{vg_name}-{lv_name}'.format(**double_dash_escaped)
|
||||
if os.path.exists(mapper_device):
|
||||
real_device = mapper_device
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user