master - lvmdbusd: Simplify add_no_notify for loop
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=957e283de8298e2bb83...
Commit: 957e283de8298e2bb83517dbf8b724bc733cbbd9
Parent: 075f8e658c33400ceaa8ff40b261fe31f69eb825
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Mar 9 16:06:00 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbusd: Simplify add_no_notify for loop
---
daemons/lvmdbusd/utils.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index 42dd7e5..2e7b808 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -514,8 +514,8 @@ def add_no_notify(cmdline):
return cmdline
if '--config' in cmdline:
- for i in range(0, len(cmdline)):
- if cmdline[i] == '--config':
+ for i, arg in enumerate(cmdline):
+ if arg == '--config':
cmdline[i] += "global/notify_dbus=0"
break
else:
6 years, 9 months
master - lvmdbusd: Correct utils.add_no_notify doc
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=075f8e658c33400ceaa...
Commit: 075f8e658c33400ceaa8ff40b261fe31f69eb825
Parent: 00143753ee4aec09eb40176ada5d34c3bde91884
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Mar 9 16:04:24 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbusd: Correct utils.add_no_notify doc
---
daemons/lvmdbusd/utils.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index bf2552c..42dd7e5 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -503,9 +503,11 @@ def add_no_notify(cmdline):
"""
Given a command line to execute we will see if `--config` is present, if it
is we will add the global/notify_dbus=0 to it, otherwise we will append it
- to the end
- :param cmdline:
+ to the end of the list.
+ :param: cmdline: The command line to inspect
+ :type: cmdline: list
:return: cmdline with notify_dbus config option present
+ :rtype: list
"""
if 'help' in cmdline:
6 years, 9 months
master - lvmdbusd: Add debug message to lvm ID lookup
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=00143753ee4aec09eb4...
Commit: 00143753ee4aec09eb40176ada5d34c3bde91884
Parent: 28754145d8cdad50bfa003fb13fc46af1cbadae8
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Mar 9 16:03:20 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbusd: Add debug message to lvm ID lookup
---
daemons/lvmdbusd/manager.py | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/daemons/lvmdbusd/manager.py b/daemons/lvmdbusd/manager.py
index 3c2bfcb..433473f 100644
--- a/daemons/lvmdbusd/manager.py
+++ b/daemons/lvmdbusd/manager.py
@@ -6,7 +6,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
+from utils import log_debug
from .automatedproperties import AutomatedProperties
from . import utils
@@ -143,9 +143,10 @@ class Manager(AutomatedProperties):
@staticmethod
def _lookup_by_lvm_id(key):
p = cfg.om.get_object_path_by_uuid_lvm_id(key, key)
- if p:
- return p
- return '/'
+ if not p:
+ p = '/'
+ log_debug('LookUpByLvmId: key = %s, result = %s' % (key, p))
+ return p
@dbus.service.method(
dbus_interface=MANAGER_INTERFACE,
6 years, 9 months
master - lvmdbustest.py: Add unit test for external PV create
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=28754145d8cdad50bfa...
Commit: 28754145d8cdad50bfa003fb13fc46af1cbadae8
Parent: e06e4d9355a314acc82eb568829f9696d7969b89
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 8 15:52:48 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbustest.py: Add unit test for external PV create
Ensure a PV created outside of the dbus service is immediately found by
service user.
---
test/dbus/lvmdbustest.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index c2ac7df..2a65466 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1760,6 +1760,24 @@ class TestDbusService(unittest.TestCase):
cmd = ['lvcreate', '-L4M', '-n', lv_name, vg.Name]
self._verify_existence(cmd, cmd[0], full_name)
+ def test_external_pv_create(self):
+ # Lets create a PV outside of service and see if we correctly handle
+ # it's inclusion
+ target = self.objs[PV_INT][0]
+
+ # Remove the PV
+ rc = self._pv_remove(target)
+ self.assertTrue(rc == '/')
+ self._check_consistency()
+
+ # Make sure the PV we removed no longer exists
+ self.assertTrue(self._lookup(target.Pv.Name) == '/')
+
+ # Add it back with external command line
+ cmd = ['pvcreate', target.Pv.Name]
+ self._verify_existence(cmd, cmd[0], target.Pv.Name)
+
+
class AggregateResults(object):
def __init__(self):
6 years, 9 months
master - lvmdbustest.py: Add unit test for external LV create
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e06e4d9355a314acc82...
Commit: e06e4d9355a314acc82eb568829f9696d7969b89
Parent: 43d0fbeba281b1f9f97bf9bcf1149e682f9e6b6d
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 8 15:52:30 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbustest.py: Add unit test for external LV create
Ensure a LV created outside of the dbus service is immediately found by
service user.
---
test/dbus/lvmdbustest.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 4788eb3..c2ac7df 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1750,6 +1750,16 @@ class TestDbusService(unittest.TestCase):
cmd.extend(pv_paths)
self._verify_existence(cmd, cmd[0], vg_name)
+ def test_external_lv_create(self):
+ # Lets create a LV outside of service and see if we correctly handle
+ # it's inclusion
+ vg = self._vg_create().Vg
+ lv_name = lv_n()
+ full_name = "%s/%s" % (vg.Name, lv_name)
+
+ cmd = ['lvcreate', '-L4M', '-n', lv_name, vg.Name]
+ self._verify_existence(cmd, cmd[0], full_name)
+
class AggregateResults(object):
def __init__(self):
6 years, 9 months
master - lvmdbustest.py: Add unit test for external VG create
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=43d0fbeba281b1f9f97...
Commit: 43d0fbeba281b1f9f97bf9bcf1149e682f9e6b6d
Parent: 92b7c329ee6524fdf868a4261025406445744b12
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 8 15:50:46 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbustest.py: Add unit test for external VG create
Ensure a VG created outside of the dbus service is immediately found by
service user.
---
test/dbus/lvmdbustest.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 71b62e1..4788eb3 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -17,6 +17,7 @@ import unittest
import pyudev
from testlib import *
import testlib
+from subprocess import Popen, PIPE
g_tmo = 0
@@ -35,6 +36,9 @@ pv_device_list = os.getenv('LVM_DBUSD_PV_DEVICE_LIST', None)
# Other == Test just lvm shell mode
test_shell = os.getenv('LVM_DBUSD_TEST_MODE', 1)
+# LVM binary to use
+LVM_EXECUTABLE = os.getenv('LVM_BINARY', '/usr/sbin/lvm')
+
# Empty options dictionary (EOD)
EOD = dbus.Dictionary({}, signature=dbus.Signature('sv'))
# Base interfaces on LV objects
@@ -111,6 +115,26 @@ def set_execution(lvmshell, test_result):
return rc
+def call_lvm(command):
+ """
+ Call lvm executable and return a tuple of exitcode, stdout, stderr
+ :param command: Command to execute
+ :param debug: Dump debug to stdout
+ """
+
+ # Prepend the full lvm executable so that we can run different versions
+ # in different locations on the same box
+ command.insert(0, LVM_EXECUTABLE)
+
+ process = Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True,
+ env=os.environ)
+ out = process.communicate()
+
+ stdout_text = bytes(out[0]).decode("utf-8")
+ stderr_text = bytes(out[1]).decode("utf-8")
+ return process.returncode, stdout_text, stderr_text
+
+
# noinspection PyUnresolvedReferences
class TestDbusService(unittest.TestCase):
def setUp(self):
@@ -1702,6 +1726,29 @@ class TestDbusService(unittest.TestCase):
tag in vg_proxy.Vg.Tags,
"%s not in %s" % (tag, str(vg_proxy.Vg.Tags)))
+ def _verify_existence(self, cmd, operation, resource_name):
+ ec, stdout, stderr = call_lvm(cmd)
+ if ec == 0:
+ path = self._lookup(resource_name)
+ self.assertTrue(path != '/')
+ else:
+ self.assertTrue(ec == 0, "%s exit code = %d" % (operation, ec))
+ std_err_print(
+ "%s failed with stdout= %s, stderr= %s" %
+ (operation, stdout, stderr))
+
+ def test_external_vg_create(self):
+ # We need to ensure that if a user creates something outside of lvm
+ # dbus service that things are sequenced correctly so that if a dbus
+ # user calls into the service they will find the same information.
+ vg_name = vg_n()
+
+ # Get all the PV device paths
+ pv_paths = [p.Pv.Name for p in self.objs[PV_INT]]
+
+ cmd = ['vgcreate', vg_name]
+ cmd.extend(pv_paths)
+ self._verify_existence(cmd, cmd[0], vg_name)
class AggregateResults(object):
6 years, 9 months
master - lvmdbustest.py: Remove un-used `import time`
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=92b7c329ee6524fdf86...
Commit: 92b7c329ee6524fdf868a4261025406445744b12
Parent: 0c0002d7659ef27fcb7c8cf21b6b86d62e955499
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 8 15:49:40 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbustest.py: Remove un-used `import time`
---
test/dbus/lvmdbustest.py | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 58d8d10..71b62e1 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -14,7 +14,6 @@ import dbus
# noinspection PyUnresolvedReferences
from dbus.mainloop.glib import DBusGMainLoop
import unittest
-import time
import pyudev
from testlib import *
import testlib
6 years, 9 months
master - lvmdbusd: Correct src doc for Manager.UseLvmShell
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0c0002d7659ef27fcb7...
Commit: 0c0002d7659ef27fcb7c8cf21b6b86d62e955499
Parent: 11cfc58976df33b810e28c0b652274158d683131
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 8 15:37:08 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbusd: Correct src doc for Manager.UseLvmShell
It returns a boolean.
---
daemons/lvmdbusd/manager.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmdbusd/manager.py b/daemons/lvmdbusd/manager.py
index 6d122ba..3c2bfcb 100644
--- a/daemons/lvmdbusd/manager.py
+++ b/daemons/lvmdbusd/manager.py
@@ -183,7 +183,7 @@ class Manager(AutomatedProperties):
:param yes_no:
:param cb: dbus python call back parameter, not client visible
:param cbe: dbus python error call back parameter, not client visible
- :return: Nothing
+ :return: Boolean
"""
r = RequestEntry(-1, Manager._use_lvm_shell, (yes_no,), cb, cbe, False)
cfg.worker_q.put(r)
6 years, 9 months
master - lvmdbusd: Disable notify_dbus for service command use
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=11cfc58976df33b810e...
Commit: 11cfc58976df33b810e28c0b652274158d683131
Parent: e53454d6de07de56736303dd2157c3859f6fa848
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 8 15:35:53 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbusd: Disable notify_dbus for service command use
Utilizing the --config option we will utilize global/notify_dbus=0 so
that the service itself doesn't generate change events which it then needs to
process.
---
daemons/lvmdbusd/cmdhandler.py | 3 ++-
daemons/lvmdbusd/lvm_shell_proxy.py | 4 +++-
daemons/lvmdbusd/utils.py | 22 ++++++++++++++++++++++
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index 31b7c5c..cbf6036 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -16,7 +16,7 @@ import traceback
import os
from lvmdbusd import cfg
-from lvmdbusd.utils import pv_dest_ranges, log_debug, log_error
+from lvmdbusd.utils import pv_dest_ranges, log_debug, log_error, add_no_notify
from lvmdbusd.lvm_shell_proxy import LVMShellProxy
try:
@@ -93,6 +93,7 @@ def call_lvm(command, debug=False):
# Prepend the full lvm executable so that we can run different versions
# in different locations on the same box
command.insert(0, cfg.LVM_CMD)
+ command = add_no_notify(command)
process = Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True,
env=os.environ)
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py b/daemons/lvmdbusd/lvm_shell_proxy.py
index f3862a1..a26dd70 100755
--- a/daemons/lvmdbusd/lvm_shell_proxy.py
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py
@@ -29,7 +29,7 @@ except ImportError:
from lvmdbusd.cfg import LVM_CMD
-from lvmdbusd.utils import log_debug, log_error
+from lvmdbusd.utils import log_debug, log_error, add_no_notify
SHELL_PROMPT = "lvm> "
@@ -206,6 +206,8 @@ class LVMShellProxy(object):
self.lvm_shell.returncode,
"Underlying lvm shell process is not present!")
+ argv = add_no_notify(argv)
+
# create the command string
cmd = " ".join(_quote_arg(arg) for arg in argv)
cmd += "\n"
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index b95f80a..bf2552c 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -499,6 +499,28 @@ def validate_tag(interface, tag):
% (tag, _ALLOWABLE_TAG_CH))
+def add_no_notify(cmdline):
+ """
+ Given a command line to execute we will see if `--config` is present, if it
+ is we will add the global/notify_dbus=0 to it, otherwise we will append it
+ to the end
+ :param cmdline:
+ :return: cmdline with notify_dbus config option present
+ """
+
+ if 'help' in cmdline:
+ return cmdline
+
+ if '--config' in cmdline:
+ for i in range(0, len(cmdline)):
+ if cmdline[i] == '--config':
+ cmdline[i] += "global/notify_dbus=0"
+ break
+ else:
+ cmdline.extend(['--config', 'global/notify_dbus=0'])
+ return cmdline
+
+
# The methods below which start with mt_* are used to execute the desired code
# on the the main thread of execution to alleviate any issues the dbus-python
# library with regards to multi-threaded access. Essentially, we are trying to
6 years, 9 months
master - lvmdbusd: Use work queue for queries too
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e53454d6de07de56736...
Commit: e53454d6de07de56736303dd2157c3859f6fa848
Parent: 470a1f1c5031590823f8a58e641873da76dc1f46
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 8 15:31:45 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 9 16:39:47 2017 -0600
lvmdbusd: Use work queue for queries too
We need to place query operations in the queue to prevent the case where
a client knows of something before the service does. For example if a
client creates a PV/VG/LV outside of the dbus API and then immediately
tries to lookup and use that resource in the lvm dbus service it should
be present. By placing the queries in the work queue any previous
refresh operation will complete before we process the query.
---
daemons/lvmdbusd/automatedproperties.py | 45 ++++++++++++++++++++++--------
daemons/lvmdbusd/cfg.py | 3 ++
daemons/lvmdbusd/main.py | 3 +-
daemons/lvmdbusd/manager.py | 33 ++++++++++++++++------
daemons/lvmdbusd/objectmanager.py | 18 ++++++++----
daemons/lvmdbusd/udevwatch.py | 12 +++++++-
6 files changed, 85 insertions(+), 29 deletions(-)
diff --git a/daemons/lvmdbusd/automatedproperties.py b/daemons/lvmdbusd/automatedproperties.py
index 7b22d19..68cea6e 100644
--- a/daemons/lvmdbusd/automatedproperties.py
+++ b/daemons/lvmdbusd/automatedproperties.py
@@ -38,7 +38,7 @@ class AutomatedProperties(dbus.service.Object):
props = {}
for i in self.interface():
- props[i] = self.GetAll(i)
+ props[i] = AutomatedProperties._get_all_prop(self, i)
return self._ap_o_path, props
@@ -65,33 +65,54 @@ class AutomatedProperties(dbus.service.Object):
return self._ap_interface
- # Properties
- # noinspection PyUnusedLocal
- @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
- in_signature='ss', out_signature='v')
- def Get(self, interface_name, property_name):
- value = getattr(self, property_name)
+ @staticmethod
+ def _get_prop(obj, interface_name, property_name):
+ value = getattr(obj, property_name)
# Note: If we get an exception in this handler we won't know about it,
# only the side effect of no returned value!
log_debug('Get (%s), type (%s), value(%s)' %
(property_name, str(type(value)), str(value)))
return value
+ # Properties
+ # noinspection PyUnusedLocal
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
- in_signature='s', out_signature='a{sv}')
- def GetAll(self, interface_name):
- if interface_name in self.interface(True):
+ in_signature='ss', out_signature='v',
+ async_callbacks=('cb', 'cbe'))
+ def Get(self, interface_name, property_name, cb, cbe):
+ # Note: If we get an exception in this handler we won't know about it,
+ # only the side effect of no returned value!
+ r = cfg.create_request_entry(
+ -1, AutomatedProperties._get_prop,
+ (self, interface_name, property_name),
+ cb, cbe, False)
+ cfg.worker_q.put(r)
+
+
+ @staticmethod
+ def _get_all_prop(obj, interface_name):
+ if interface_name in obj.interface(True):
# Using introspection, lets build this dynamically
- properties = get_properties(self)
+ properties = get_properties(obj)
if interface_name in properties:
return properties[interface_name][1]
return {}
raise dbus.exceptions.DBusException(
- self._ap_interface,
+ obj._ap_interface,
'The object %s does not implement the %s interface'
% (self.__class__, interface_name))
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
+ in_signature='s', out_signature='a{sv}',
+ async_callbacks=('cb', 'cbe'))
+ def GetAll(self, interface_name, cb, cbe):
+ r = cfg.create_request_entry(
+ -1, AutomatedProperties._get_all_prop,
+ (self, interface_name),
+ cb, cbe, False)
+ cfg.worker_q.put(r)
+
+ @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
in_signature='ssv')
def Set(self, interface_name, property_name, new_value):
setattr(self, property_name, new_value)
diff --git a/daemons/lvmdbusd/cfg.py b/daemons/lvmdbusd/cfg.py
index afb682c..f3eadf1 100644
--- a/daemons/lvmdbusd/cfg.py
+++ b/daemons/lvmdbusd/cfg.py
@@ -84,3 +84,6 @@ db = None
# lvm flight recorder
blackbox = None
+
+# RequestEntry ctor
+create_request_entry = None
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index 17e2175..ff97683 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -30,6 +30,7 @@ import argparse
import os
import sys
from .cmdhandler import LvmFlightRecorder
+from .request import RequestEntry
class Lvm(objectmanager.ObjectManager):
@@ -97,6 +98,7 @@ def main():
os.environ["LC_ALL"] = "C"
cfg.args = parser.parse_args()
+ cfg.create_request_entry = RequestEntry
# We create a flight recorder in cmdhandler too, but we replace it here
# as the user may be specifying a different size. The default one in
@@ -144,7 +146,6 @@ def main():
thread_list.append(updater.thread)
cfg.load = updater.load
- cfg.event = updater.event
cfg.loop = GLib.MainLoop()
diff --git a/daemons/lvmdbusd/manager.py b/daemons/lvmdbusd/manager.py
index 5575e39..6d122ba 100644
--- a/daemons/lvmdbusd/manager.py
+++ b/daemons/lvmdbusd/manager.py
@@ -139,11 +139,20 @@ class Manager(AutomatedProperties):
Dump the flight recorder to syslog
"""
cfg.blackbox.dump()
+
+ @staticmethod
+ def _lookup_by_lvm_id(key):
+ p = cfg.om.get_object_path_by_uuid_lvm_id(key, key)
+ if p:
+ return p
+ return '/'
+
@dbus.service.method(
dbus_interface=MANAGER_INTERFACE,
in_signature='s',
- out_signature='o')
- def LookUpByLvmId(self, key):
+ out_signature='o',
+ async_callbacks=('cb', 'cbe'))
+ def LookUpByLvmId(self, key, cb, cbe):
"""
Given a lvm id in one of the forms:
@@ -157,10 +166,8 @@ class Manager(AutomatedProperties):
:param key: The lookup value
:return: Return the object path. If object not found you will get '/'
"""
- p = cfg.om.get_object_path_by_uuid_lvm_id(key, key)
- if p:
- return p
- return '/'
+ r = RequestEntry(-1, Manager._lookup_by_lvm_id, (key,), cb, cbe, False)
+ cfg.worker_q.put(r)
@staticmethod
def _use_lvm_shell(yes_no):
@@ -181,11 +188,17 @@ class Manager(AutomatedProperties):
r = RequestEntry(-1, Manager._use_lvm_shell, (yes_no,), cb, cbe, False)
cfg.worker_q.put(r)
+ @staticmethod
+ def _external_event(command):
+ utils.log_debug("Processing _external_event= %s" % command,
+ 'bg_black', 'fg_orange')
+ cfg.load()
+
@dbus.service.method(
dbus_interface=MANAGER_INTERFACE,
in_signature='s', out_signature='i')
def ExternalEvent(self, command):
-
+ utils.log_debug("ExternalEvent %s" % command)
# If a user didn't explicitly specify udev, we will turn it off now.
if not cfg.args.use_udev:
if udevwatch.remove():
@@ -193,8 +206,10 @@ class Manager(AutomatedProperties):
"udev monitoring")
# We are dependent on external events now to stay current!
cfg.ee = True
- utils.log_debug("ExternalEvent %s" % command)
- cfg.event()
+
+ r = RequestEntry(
+ -1, Manager._external_event, (command,), None, None, False)
+ cfg.worker_q.put(r)
return dbus.Int32(0)
@staticmethod
diff --git a/daemons/lvmdbusd/objectmanager.py b/daemons/lvmdbusd/objectmanager.py
index 71149a5..a9d13a7 100644
--- a/daemons/lvmdbusd/objectmanager.py
+++ b/daemons/lvmdbusd/objectmanager.py
@@ -32,14 +32,12 @@ class ObjectManager(AutomatedProperties):
self._id_to_object_path = {}
self.rlock = threading.RLock()
- @dbus.service.method(
- dbus_interface="org.freedesktop.DBus.ObjectManager",
- out_signature='a{oa{sa{sv}}}')
- def GetManagedObjects(self):
- with self.rlock:
+ @staticmethod
+ def _get_managed_objects(obj):
+ with obj.rlock:
rc = {}
try:
- for k, v in list(self._objects.items()):
+ for k, v in list(obj._objects.items()):
path, props = v[0].emit_data()
rc[path] = props
except Exception:
@@ -47,6 +45,14 @@ class ObjectManager(AutomatedProperties):
sys.exit(1)
return rc
+ @dbus.service.method(
+ dbus_interface="org.freedesktop.DBus.ObjectManager",
+ out_signature='a{oa{sa{sv}}}', async_callbacks=('cb', 'cbe'))
+ def GetManagedObjects(self, cb, cbe):
+ r = cfg.create_request_entry(-1, ObjectManager._get_managed_objects,
+ (self, ), cb, cbe, False)
+ cfg.worker_q.put(r)
+
def locked(self):
"""
If some external code need to run across a number of different
diff --git a/daemons/lvmdbusd/udevwatch.py b/daemons/lvmdbusd/udevwatch.py
index e2ac63a..eaf31df 100644
--- a/daemons/lvmdbusd/udevwatch.py
+++ b/daemons/lvmdbusd/udevwatch.py
@@ -10,11 +10,18 @@
import pyudev
import threading
from . import cfg
+from .request import RequestEntry
+from . import utils
observer = None
observer_lock = threading.RLock()
+def _udev_event():
+ utils.log_debug("Processing udev event")
+ cfg.load()
+
+
# noinspection PyUnusedLocal
def filter_event(action, device):
# Filter for events of interest and add a request object to be processed
@@ -37,7 +44,10 @@ def filter_event(action, device):
refresh = True
if refresh:
- cfg.event()
+ # Place this on the queue so any other operations will sequence behind it
+ r = RequestEntry(
+ -1, _udev_event, (), None, None, False)
+ cfg.worker_q.put(r)
def add():
6 years, 9 months