summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2016-03-21 17:19:38 -0500
committerTony Asleson <tasleson@redhat.com>2016-03-21 17:28:51 -0500
commita0c7875c547fb8a420d789271f5e6660210e749f (patch)
treef11b5b5d5d47dc613cc5f3ea63a0c1b76633fe96
parent86e9d12b6f06c741ada66cd417f3fa82ea0364b6 (diff)
downloadlvm2-a0c7875c547fb8a420d789271f5e6660210e749f.tar.gz
lvmdbusd: Allow PV devices to be referenced by symlink(s)
See: https://bugzilla.redhat.com/show_bug.cgi?id=1318754 Signed-off-by: Tony Asleson <tasleson@redhat.com>
-rwxr-xr-xdaemons/lvmdbusd/lvmdb.py6
-rw-r--r--daemons/lvmdbusd/objectmanager.py31
2 files changed, 29 insertions, 8 deletions
diff --git a/daemons/lvmdbusd/lvmdb.py b/daemons/lvmdbusd/lvmdb.py
index 132bee726..be3786892 100755
--- a/daemons/lvmdbusd/lvmdb.py
+++ b/daemons/lvmdbusd/lvmdb.py
@@ -12,6 +12,7 @@
from collections import OrderedDict
import pprint as prettyprint
+import os
try:
from . import cmdhandler
@@ -309,6 +310,11 @@ class DataStore(object):
else:
rc = []
for s in pv_name:
+ # Ths user could be using a symlink instead of the actual
+ # block device, make sure we are using actual block device file
+ # if the pv name isn't in the lookup
+ if s not in self.pv_path_to_uuid:
+ s = os.path.realpath(s)
rc.append(self.pvs[self.pv_path_to_uuid[s]])
return rc
diff --git a/daemons/lvmdbusd/objectmanager.py b/daemons/lvmdbusd/objectmanager.py
index e2f1e0a6e..f28c5c867 100644
--- a/daemons/lvmdbusd/objectmanager.py
+++ b/daemons/lvmdbusd/objectmanager.py
@@ -11,6 +11,7 @@ import sys
import threading
import traceback
import dbus
+import os
from . import cfg
from .utils import log_debug
from .automatedproperties import AutomatedProperties
@@ -184,13 +185,13 @@ class ObjectManager(AutomatedProperties):
return self.get_object_by_path(self._id_to_object_path[lvm_id])
return None
- def _uuid_verify(self, path, lvm_id, uuid):
+ def _uuid_verify(self, path, uuid, lvm_id):
"""
Ensure uuid is present for a successful lvm_id lookup
NOTE: Internal call, assumes under object manager lock
:param path: Path to object we looked up
- :param lvm_id: lvm_id used to find object
:param uuid: lvm uuid to verify
+ :param lvm_id: lvm_id used to find object
:return: None
"""
# This gets called when we found an object based on lvm_id, ensure
@@ -200,6 +201,17 @@ class ObjectManager(AutomatedProperties):
obj = self.get_object_by_path(path)
self._lookup_add(obj, path, lvm_id, uuid)
+ def _return_lookup(self, uuid, lvm_identifier):
+ """
+ We found an identifier, so lets return the path to the found object
+ :param uuid: The lvm uuid
+ :param lvm_identifier: The lvm_id used to find object
+ :return:
+ """
+ path = self._id_to_object_path[lvm_identifier]
+ self._uuid_verify(path, uuid, lvm_identifier)
+ return path
+
def get_object_path_by_lvm_id(self, uuid, lvm_id, path_create=None,
gen_new=True):
"""
@@ -221,16 +233,19 @@ class ObjectManager(AutomatedProperties):
path = None
if lvm_id in self._id_to_object_path:
- path = self._id_to_object_path[lvm_id]
- self._uuid_verify(path, lvm_id, uuid)
- return path
+ self._return_lookup(uuid, lvm_id)
+
if "/" in lvm_id:
vg, lv = lvm_id.split("/", 1)
int_lvm_id = vg + "/" + ("[%s]" % lv)
if int_lvm_id in self._id_to_object_path:
- path = self._id_to_object_path[int_lvm_id]
- self._uuid_verify(path, int_lvm_id, uuid)
- return path
+ self._return_lookup(uuid, int_lvm_id)
+ elif lvm_id.startswith('/'):
+ # We could have a pv device path lookup that failed,
+ # lets try canonical form and try again.
+ canonical = os.path.realpath(lvm_id)
+ if canonical in self._id_to_object_path:
+ self._return_lookup(uuid, canonical)
if uuid and uuid in self._id_to_object_path:
# If we get here it indicates that we found the object, but