From 9cb886551160cecc50a20d1867aaa5e1e75b61a6 Mon Sep 17 00:00:00 2001 From: Tony Asleson Date: Mon, 19 Sep 2016 09:54:24 -0500 Subject: [PATCH] lvmdbusd: Fix dbus object with only properties and no method Gris debugged that when we don't have a method the introspection data is missing the interface itself eg. 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 | 7 ------- daemons/lvmdbusd/utils.py | 24 +++++++++++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py index 4ec6f23df..455f371df 100644 --- a/daemons/lvmdbusd/lv.py +++ b/daemons/lvmdbusd/lv.py @@ -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): diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py index 7d217df19..4fb6a6c27 100644 --- a/daemons/lvmdbusd/utils.py +++ b/daemons/lvmdbusd/utils.py @@ -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 = '\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 = '\n' % \ + (p['p_t'], p['p_name'], p['p_access']) + interface_element.append(Et.fromstring(temp)) return Et.tostring(root, encoding='utf8') return xml -- 2.43.5