1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvmdbusd: Add env variable to use session bus

export LVMDBUSD_SESSION=True to run on the session bus instead
of the system bus so that we can run the unit test without
installing the dbus conf file.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
This commit is contained in:
Tony Asleson 2016-02-22 14:28:11 -06:00
parent 64aab5885d
commit 21034644b6
2 changed files with 14 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import sys
from . import udevwatch
from .utils import log_debug
import argparse
import os
class Lvm(objectmanager.ObjectManager):
@ -71,6 +72,8 @@ def main():
help="Dump debug messages", default=False,
dest='debug')
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
args = parser.parse_args()
cfg.DEBUG = args.debug
@ -90,7 +93,11 @@ def main():
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
GObject.threads_init()
dbus.mainloop.glib.threads_init()
cfg.bus = dbus.SystemBus()
if use_session:
cfg.bus = dbus.SessionBus()
else:
cfg.bus = dbus.SystemBus()
# The base name variable needs to exist for things to work.
# noinspection PyUnusedLocal
base_name = dbus.service.BusName(BASE_INTERFACE, cfg.bus)

View File

@ -44,7 +44,12 @@ def rs(length, suffix, character_set=string.ascii_lowercase):
for _ in range(length)) + suffix
bus = dbus.SystemBus(mainloop=DBusGMainLoop())
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
if use_session:
bus = dbus.SessionBus(mainloop=DBusGMainLoop())
else:
bus = dbus.SystemBus(mainloop=DBusGMainLoop())
def mib(s):