Commit 87d6d0c8 authored by Anya Harter's avatar Anya Harter Committed by Katerina Koukiou

Implement InterfaceLookupByMAC method for Connect Interface

Signed-off-by: 's avatarAnya Harter <aharter@redhat.com>
Reviewed-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
parent e542bcef
......@@ -170,6 +170,12 @@
<arg name="flags" type="u" direction="in"/>
<arg name="interface" type="o" direction="out"/>
</method>
<method name="InterfaceLookupByMAC">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByMACString"/>
<arg name="mac" type="s" 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"/>
......
......@@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectInterfaceLookupByMAC(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 *mac;
g_variant_get(inArgs, "(&s)", &mac);
if (!virtDBusConnectOpen(connect, NULL))
return;
interface = virInterfaceLookupByMACString(connect->connection, mac);
if (!interface)
return virtDBusUtilSetLastVirtError(error);
path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath);
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectInterfaceLookupByName(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -1927,6 +1955,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit },
{ "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback },
{ "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML },
{ "InterfaceLookupByMAC", virtDBusConnectInterfaceLookupByMAC },
{ "InterfaceLookupByName", virtDBusConnectInterfaceLookupByName },
{ "ListDomains", virtDBusConnectListDomains },
{ "ListInterfaces", virtDBusConnectListInterfaces },
......
......@@ -90,6 +90,7 @@ class TestConnect(libvirttest.BaseTestClass):
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("InterfaceLookupByName", 'Name'),
("InterfaceLookupByMAC", 'MAC'),
])
def test_connect_interface_lookup_by_property(self, lookup_method_name, lookup_item):
"""Parameterized test for all InterfaceLookupBy* API calls of Connect interface
......
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