Commit e542bcef authored by Anya Harter's avatar Anya Harter Committed by Katerina Koukiou

Implement InterfaceLookupByName method for Connect Interface

Signed-off-by: 's avatarAnya Harter <aharter@redhat.com>
Reviewed-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
parent bb45647c
......@@ -170,6 +170,12 @@
<arg name="flags" type="u" direction="in"/>
<arg name="interface" type="o" direction="out"/>
</method>
<method name="InterfaceLookupByName">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByName"/>
<arg name="name" type="s" direction="in"/>
<arg name="interface" type="o" direction="out"/>
</method>
<method name="ListDomains">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/>
......
......@@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectInterfaceLookupByName(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
const gchar *objectPath G_GNUC_UNUSED,
gpointer userData,
GVariant **outArgs,
GUnixFDList **outFDs G_GNUC_UNUSED,
GError **error)
{
virtDBusConnect *connect = userData;
g_autoptr(virInterface) interface = NULL;
g_autofree gchar *path = NULL;
const gchar *name;
g_variant_get(inArgs, "(&s)", &name);
if (!virtDBusConnectOpen(connect, NULL))
return;
interface = virInterfaceLookupByName(connect->connection, name);
if (!interface)
return virtDBusUtilSetLastVirtError(error);
path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath);
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectListDomains(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -1899,6 +1927,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit },
{ "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback },
{ "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML },
{ "InterfaceLookupByName", virtDBusConnectInterfaceLookupByName },
{ "ListDomains", virtDBusConnectListDomains },
{ "ListInterfaces", virtDBusConnectListInterfaces },
{ "ListNetworks", virtDBusConnectListNetworks },
......
......@@ -88,6 +88,18 @@ class TestConnect(libvirttest.BaseTestClass):
path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0)
assert isinstance(path, dbus.ObjectPath)
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("InterfaceLookupByName", 'Name'),
])
def test_connect_interface_lookup_by_property(self, lookup_method_name, lookup_item):
"""Parameterized test for all InterfaceLookupBy* API calls of Connect interface
"""
original_path,_ = self.interface_create()
obj = self.bus.get_object('org.libvirt', original_path)
prop = obj.Get('org.libvirt.Interface', lookup_item, dbus_interface=dbus.PROPERTIES_IFACE)
path = getattr(self.connect, lookup_method_name)(prop)
assert original_path == path
def test_connect_list_networks(self):
networks = self.connect.ListNetworks(0)
assert isinstance(networks, dbus.Array)
......
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