mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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. <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.
This commit is contained in:
parent
cb2b261510
commit
9cb8865511
@ -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):
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user