Commit 282186a3 authored by Anya Harter's avatar Anya Harter Committed by Katerina Koukiou

Implement Name property for Interface Interface

Signed-off-by: 's avatarAnya Harter <aharter@redhat.com>
Reviewed-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
parent 9d2bc236
......@@ -3,6 +3,11 @@
<node name="/org/libvirt/interface">
<interface name="org.libvirt.Interface">
<property name="Name" type="s" access="read">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/>
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
</property>
<method name="Create">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/>
......
......@@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs,
virtDBusUtilSetLastVirtError(error);
}
static void
virtDBusInterfaceGetName(const gchar *objectPath,
gpointer userData,
GVariant **value,
GError **error)
{
virtDBusConnect *connect = userData;
g_autoptr(virInterface) interface = NULL;
const gchar *name;
interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error);
if (!interface)
return;
name = virInterfaceGetName(interface);
if (!name)
return virtDBusUtilSetLastVirtError(error);
*value = g_variant_new("s", name);
}
static void
virtDBusInterfaceGetXMLDesc(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -118,6 +139,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED,
}
static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = {
{ "Name", virtDBusInterfaceGetName, NULL },
{ 0 }
};
......
......@@ -25,5 +25,13 @@ class TestInterface(libvirttest.BaseTestClass):
_,interface_obj = self.interface_create()
assert isinstance(interface_obj.GetXMLDesc(0), dbus.String)
def test_interface_properties_type(self):
""" Ensure correct return type for Interface properties
"""
test_interface_path,_ = self.interface_create()
obj = self.bus.get_object('org.libvirt', test_interface_path)
props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE)
assert isinstance(props['Name'], dbus.String)
if __name__ == '__main__':
libvirttest.run()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment