Commit 5dbc7822 authored by Anya Harter's avatar Anya Harter Committed by Katerina Koukiou

Implement Active property for Interface Interface

Signed-off-by: 's avatarAnya Harter <aharter@redhat.com>
Reviewed-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
parent d42d6fa4
......@@ -3,6 +3,11 @@
<node name="/org/libvirt/interface">
<interface name="org.libvirt.Interface">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
<property name="Active" type="b" access="read">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceIsActive"/>
</property>
<property name="MAC" type="s" access="read">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/>
......
......@@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs,
virtDBusUtilSetLastVirtError(error);
}
static void
virtDBusInterfaceGetActive(const gchar *objectPath,
gpointer userData,
GVariant **value,
GError **error)
{
virtDBusConnect *connect = userData;
g_autoptr(virInterface) interface = NULL;
gint active;
interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error);
if (!interface)
return;
active = virInterfaceIsActive(interface);
if (active < 0)
return virtDBusUtilSetLastVirtError(error);
*value = g_variant_new("b", !!active);
}
static void
virtDBusInterfaceGetMAC(const gchar *objectPath,
gpointer userData,
......@@ -160,6 +181,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED,
}
static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = {
{ "Active", virtDBusInterfaceGetActive, NULL },
{ "MAC", virtDBusInterfaceGetMAC, NULL },
{ "Name", virtDBusInterfaceGetName, NULL },
{ 0 }
......
......@@ -33,6 +33,7 @@ class TestInterface(libvirttest.BaseTestClass):
props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE)
assert isinstance(props['Name'], dbus.String)
assert isinstance(props['MAC'], dbus.String)
assert isinstance(props['Active'], dbus.Boolean)
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