summaryrefslogtreecommitdiff
path: root/targetcli
diff options
context:
space:
mode:
authorAndy Grover <andy@groveronline.com>2017-09-29 16:24:03 -0700
committerGitHub <noreply@github.com>2017-09-29 16:24:03 -0700
commitf220d9a5bd2c64715397ee8e0a98f210132c68a5 (patch)
tree3231e3538ade4720a838d047dc2a38fa7f52c185 /targetcli
parentb3660b32441dfdac515d569cc31b14fd253ca616 (diff)
parent0872eb88390e28e558a4a118864ea46224ce49f6 (diff)
downloadtargetcli-f220d9a5bd2c64715397ee8e0a98f210132c68a5.tar.gz
Merge pull request #91 from cvubrugier/dbus-gobject
Replace dbus-python with GObject Introspection
Diffstat (limited to 'targetcli')
-rw-r--r--targetcli/ui_backstore.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/targetcli/ui_backstore.py b/targetcli/ui_backstore.py
index a303487..2140e88 100644
--- a/targetcli/ui_backstore.py
+++ b/targetcli/ui_backstore.py
@@ -17,11 +17,11 @@ License for the specific language governing permissions and limitations
under the License.
'''
+from gi.repository import Gio
import glob
import os
import re
import stat
-import dbus
from configshell_fb import ExecutionError
from rtslib_fb import BlockStorageObject, FileIOStorageObject
@@ -229,16 +229,26 @@ class UIBackstores(UINode):
tcmu-runner (or other daemon providing the same service) exposes a
DBus ObjectManager-based iface to find handlers it supports.
'''
- bus = dbus.SystemBus()
+ bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
try:
- mgr_obj = bus.get_object('org.kernel.TCMUService1', '/org/kernel/TCMUService1')
- mgr_iface = dbus.Interface(mgr_obj, 'org.freedesktop.DBus.ObjectManager')
-
- for k,v in mgr_iface.GetManagedObjects().items():
- tcmu_obj = bus.get_object('org.kernel.TCMUService1', k)
- tcmu_iface = dbus.Interface(tcmu_obj, dbus_interface='org.kernel.TCMUService1')
+ mgr_iface = Gio.DBusProxy.new_sync(bus,
+ Gio.DBusProxyFlags.NONE,
+ None,
+ 'org.kernel.TCMUService1',
+ '/org/kernel/TCMUService1',
+ 'org.freedesktop.DBus.ObjectManager',
+ None)
+
+ for k, v in mgr_iface.GetManagedObjects().items():
+ tcmu_iface = Gio.DBusProxy.new_sync(bus,
+ Gio.DBusProxyFlags.NONE,
+ None,
+ 'org.kernel.TCMUService1',
+ k,
+ 'org.kernel.TCMUService1',
+ None)
yield (k[k.rfind("/")+1:], tcmu_iface, v)
- except dbus.DBusException as e:
+ except Exception as e:
return
def refresh(self):
@@ -595,7 +605,7 @@ class UIUserBackedBackstore(UIBackstore):
config = self.handler + "/" + cfgstring
- ok, errmsg = self.iface.CheckConfig(config)
+ ok, errmsg = self.iface.CheckConfig('(s)', config)
if not ok:
raise ExecutionError("cfgstring invalid: %s" % errmsg)