1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

lvmdbusd: Add method get_object_path_by_lvm_id

The object manager method get_object_by_lvm_id was used in many cases for
the sole reason of getting the object path for the object.  Instead of
retrieving the object and then calling 'dbus_object_path' on the object, we
are adding a method which returns the object path.
This commit is contained in:
Tony Asleson 2016-06-10 12:05:52 -05:00
parent b717e8fe1d
commit b81186e535
3 changed files with 15 additions and 17 deletions

View File

@ -354,12 +354,7 @@ class Lv(LvCommon):
# The name is vg/name
full_name = "%s/%s" % (self.vg_name_lookup(), name)
o = cfg.om.get_object_by_lvm_id(full_name)
if o:
return o.dbus_object_path()
return '/'
return cfg.om.get_object_path_by_lvm_id(full_name)
def _get_data_meta(self):
@ -783,8 +778,7 @@ class LvCachePool(Lv):
cfg.om.remove_object(lv_to_cache, emit_signal=True)
cfg.load()
lv_converted = \
cfg.om.get_object_by_lvm_id(fcn).dbus_object_path()
lv_converted = cfg.om.get_object_path_by_lvm_id(fcn)
else:
raise dbus.exceptions.DBusException(
@ -847,9 +841,7 @@ class LvCacheLv(Lv):
cfg.om.remove_object(dbo, emit_signal=True)
cfg.load()
uncached_lv_path = \
cfg.om.get_object_by_lvm_id(lv_name).dbus_object_path()
uncached_lv_path = cfg.om.get_object_path_by_lvm_id(lv_name)
else:
raise dbus.exceptions.DBusException(
LV_INTERFACE,

View File

@ -185,6 +185,17 @@ class ObjectManager(AutomatedProperties):
return self.get_object_by_path(self._id_to_object_path[lvm_id])
return None
def get_object_path_by_lvm_id(self, lvm_id):
"""
Given an lvm identifier, return the object path for it
:param lvm_id: The lvm identifier
:return: Object path or '/' if not found
"""
with self.rlock:
if lvm_id in self._id_to_object_path:
return self._id_to_object_path[lvm_id]
return '/'
def _uuid_verify(self, path, uuid, lvm_id):
"""
Ensure uuid is present for a successful lvm_id lookup

View File

@ -144,13 +144,8 @@ class Vg(AutomatedProperties):
@staticmethod
def fetch_new_lv(vg_name, lv_name):
full_name = "%s/%s" % (vg_name, lv_name)
cfg.load()
l = cfg.om.get_object_by_lvm_id(full_name)
created_lv = l.dbus_object_path()
return created_lv
return cfg.om.get_object_by_lvm_id("%s/%s" % (vg_name, lv_name))
@staticmethod
def _rename(uuid, vg_name, new_name, rename_options):