]> sourceware.org Git - lvm2.git/commitdiff
lvmdbusd: Fix dbus object with only properties and no method
authorTony Asleson <tasleson@redhat.com>
Mon, 19 Sep 2016 14:54:24 +0000 (09:54 -0500)
committerTony Asleson <tasleson@redhat.com>
Mon, 19 Sep 2016 20:32:47 +0000 (15:32 -0500)
Gris debugged that when we don't have a method the introspection
data is missing the interface itself eg.

<interface name="<your_obj_iface_name>" />

When adding the properties to the dbus object introspection we will
add the interface too if it's missing.  This now allows us the
ability to have a dbus object with only properties.

daemons/lvmdbusd/lv.py
daemons/lvmdbusd/utils.py

index 4ec6f23df2b42cc74a8b51eadfea1ea5b9dbbe55..455f371df575126198b479ecd6ef956c4e2d1f6d 100644 (file)
@@ -354,13 +354,6 @@ class LvCommon(AutomatedProperties):
        def Active(self):
                return dbus.Boolean(self.state.active == "active")
 
-       @dbus.service.method(
-               dbus_interface=LV_COMMON_INTERFACE,
-               in_signature='ia{sv}',
-               out_signature='o')
-       def _Future(self, tmo, open_options):
-               raise dbus.exceptions.DBusException(LV_COMMON_INTERFACE, 'Do not use!')
-
 
 # noinspection PyPep8Naming
 class Lv(LvCommon):
index 7d217df1900923695ca411cf8bd243b46557c9d9..4fb6a6c278185f91050c255fda4baf1fe4c80ca6 100644 (file)
@@ -147,17 +147,27 @@ def add_properties(xml, interface, props):
        :param props:       Output from get_properties
        :return: updated XML string
        """
-       root = Et.fromstring(xml)
-
        if props:
+               root = Et.fromstring(xml)
+               interface_element = None
 
+               # Check to see if interface is present
                for c in root:
-                       # print c.attrib['name']
                        if c.attrib['name'] == interface:
-                               for p in props:
-                                       temp = '<property type="%s" name="%s" access="%s"/>\n' % \
-                                               (p['p_t'], p['p_name'], p['p_access'])
-                                       c.append(Et.fromstring(temp))
+                               interface_element = c
+                               break
+
+               # Interface is not present, lets create it so we have something to
+               # attach the properties too
+               if interface_element is None:
+                       interface_element = Et.Element("interface", name=interface)
+                       root.append(interface_element)
+
+               # Add the properties
+               for p in props:
+                       temp = '<property type="%s" name="%s" access="%s"/>\n' % \
+                               (p['p_t'], p['p_name'], p['p_access'])
+                       interface_element.append(Et.fromstring(temp))
 
                return Et.tostring(root, encoding='utf8')
        return xml
This page took 0.037575 seconds and 5 git commands to generate.