Merge pull request #10570 from ahammond/normalize_mapper_mounts

guess at how to solve issue #10257
This commit is contained in:
Thomas S Hatch 2014-02-20 10:11:55 -07:00
commit b67272ea1b

View File

@ -18,6 +18,7 @@ Mount any type of mountable filesystem with the mounted function:
# Import python libs # Import python libs
import os.path import os.path
import re
# Import salt libs # Import salt libs
from salt._compat import string_types from salt._compat import string_types
@ -90,6 +91,19 @@ def mounted(name,
real_device = os.path.realpath(device) real_device = os.path.realpath(device)
else: else:
real_device = device real_device = device
# LVS devices have 2 names under /dev:
# /dev/mapper/vgname-lvname and /dev/vgname/lvname
# No matter what name is used for mounting,
# mount always displays the device as /dev/mapper/vgname-lvname
# So, let's call that the canonical device name
# We should normalize names of the /dev/vgname/lvname 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())
if os.path.exists(mapper_device):
real_device = mapper_device
device_list = [] device_list = []
if real_name in active: if real_name in active:
device_list.append(active[real_name]['device']) device_list.append(active[real_name]['device'])