1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00

lvmdbus: Make bus name configurable

Add env LVM_DBUS_NAME to change what the bus name is.
This commit is contained in:
Tony Asleson 2016-11-04 13:26:31 -05:00
parent 560229178c
commit affe2cebf5
4 changed files with 22 additions and 20 deletions

View File

@ -44,6 +44,7 @@ worker_q = queue.Queue()
# Main event loop
loop = None
BUS_NAME = os.getenv('LVM_DBUS_NAME', 'com.redhat.lvmdbus1')
BASE_INTERFACE = 'com.redhat.lvmdbus1'
PV_INTERFACE = BASE_INTERFACE + '.Pv'
VG_INTERFACE = BASE_INTERFACE + '.Vg'

View File

@ -10,7 +10,7 @@
from . import cfg
from . import objectmanager
from . import utils
from .cfg import BASE_INTERFACE, BASE_OBJ_PATH, MANAGER_OBJ_PATH
from .cfg import BUS_NAME, BASE_INTERFACE, BASE_OBJ_PATH, MANAGER_OBJ_PATH
import threading
from . import cmdhandler
import time
@ -148,7 +148,7 @@ def main():
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)
base_name = dbus.service.BusName(BUS_NAME, cfg.bus)
cfg.om = Lvm(BASE_OBJ_PATH)
cfg.om.register_object(Manager(MANAGER_OBJ_PATH))

View File

@ -17,7 +17,6 @@ import unittest
import sys
import time
import pyudev
import os
from testlib import *
g_tmo = 0
@ -56,7 +55,7 @@ def get_objects():
CACHE_POOL_INT: [], CACHE_LV_INT: []}
manager = dbus.Interface(bus.get_object(
BUSNAME, "/com/redhat/lvmdbus1"),
BUS_NAME, "/com/redhat/lvmdbus1"),
"org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()
@ -71,7 +70,7 @@ def get_objects():
def set_execution(lvmshell):
lvm_manager = dbus.Interface(bus.get_object(
BUSNAME, "/com/redhat/lvmdbus1/Manager"),
BUS_NAME, "/com/redhat/lvmdbus1/Manager"),
"com.redhat.lvmdbus1.Manager")
return lvm_manager.UseLvmShell(lvmshell)

View File

@ -14,19 +14,21 @@ import functools
import xml.etree.ElementTree as Et
from collections import OrderedDict
import dbus
import os
BUSNAME = "com.redhat.lvmdbus1"
MANAGER_INT = BUSNAME + '.Manager'
MANAGER_OBJ = '/' + BUSNAME.replace('.', '/') + '/Manager'
PV_INT = BUSNAME + ".Pv"
VG_INT = BUSNAME + ".Vg"
LV_INT = BUSNAME + ".Lv"
THINPOOL_INT = BUSNAME + ".ThinPool"
SNAPSHOT_INT = BUSNAME + ".Snapshot"
LV_COMMON_INT = BUSNAME + ".LvCommon"
JOB_INT = BUSNAME + ".Job"
CACHE_POOL_INT = BUSNAME + ".CachePool"
CACHE_LV_INT = BUSNAME + ".CachedLv"
BUS_NAME = os.getenv('LVM_DBUS_NAME', 'com.redhat.lvmdbus1')
BASE_INTERFACE = 'com.redhat.lvmdbus1'
MANAGER_INT = BASE_INTERFACE + '.Manager'
MANAGER_OBJ = '/' + BASE_INTERFACE.replace('.', '/') + '/Manager'
PV_INT = BASE_INTERFACE + ".Pv"
VG_INT = BASE_INTERFACE + ".Vg"
LV_INT = BASE_INTERFACE + ".Lv"
THINPOOL_INT = BASE_INTERFACE + ".ThinPool"
SNAPSHOT_INT = BASE_INTERFACE + ".Snapshot"
LV_COMMON_INT = BASE_INTERFACE + ".LvCommon"
JOB_INT = BASE_INTERFACE + ".Job"
CACHE_POOL_INT = BASE_INTERFACE + ".CachePool"
CACHE_LV_INT = BASE_INTERFACE + ".CachedLv"
THINPOOL_LV_PATH = '/' + THINPOOL_INT.replace('.', '/')
@ -162,7 +164,7 @@ class RemoteObject(object):
for i in range(0, 3):
try:
prop_fetch = dbus.Interface(self.bus.get_object(
BUSNAME, self.object_path),
BUS_NAME, self.object_path),
'org.freedesktop.DBus.Properties')
props = prop_fetch.GetAll(self.interface)
break
@ -186,7 +188,7 @@ class RemoteObject(object):
self.introspect = introspect
self.dbus_method = dbus.Interface(specified_bus.get_object(
BUSNAME, self.object_path), self.interface)
BUS_NAME, self.object_path), self.interface)
self._set_props(properties)
@ -222,7 +224,7 @@ class ClientProxy(object):
def __init__(self, specified_bus, object_path, interface=None, props=None):
i = dbus.Interface(specified_bus.get_object(
BUSNAME, object_path), 'org.freedesktop.DBus.Introspectable')
BUS_NAME, object_path), 'org.freedesktop.DBus.Introspectable')
introspection_xml = i.Introspect()