Commit 8d7ae56b authored by Katerina Koukiou's avatar Katerina Koukiou

Implement NodeDeviceLookupByName method for Connect Interface

Signed-off-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Pavel Hrdina's avatarPavel Hrdina <phrdina@redhat.com>
parent 04b8cdf6
......@@ -215,6 +215,12 @@
<arg name="flags" type="u" direction="in"/>
<arg name="dev" type="o" direction="out"/>
</method>
<method name="NodeDeviceLookupByName">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceLookupByName"/>
<arg name="name" type="s" direction="in"/>
<arg name="dev" type="o" direction="out"/>
</method>
<method name="NWFilterDefineXML">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterDefineXML"/>
......
......@@ -1098,6 +1098,34 @@ virtDBusConnectNodeDeviceCreateXML(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectNodeDeviceLookupByName(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(virNodeDevice) dev = NULL;
g_autofree gchar *path = NULL;
const gchar *name;
g_variant_get(inArgs, "(&s)", &name);
if (!virtDBusConnectOpen(connect, error))
return;
dev = virNodeDeviceLookupByName(connect->connection, name);
if (!dev)
return virtDBusUtilSetLastVirtError(error);
path = virtDBusUtilBusPathForVirNodeDevice(dev, connect->nodeDevPath);
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectNWFilterDefineXML(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -1717,6 +1745,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NetworkLookupByName", virtDBusConnectNetworkLookupByName },
{ "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID },
{ "NodeDeviceCreateXML", virtDBusConnectNodeDeviceCreateXML },
{ "NodeDeviceLookupByName", virtDBusConnectNodeDeviceLookupByName },
{ "NWFilterDefineXML", virtDBusConnectNWFilterDefineXML },
{ "NWFilterLookupByName", virtDBusConnectNWFilterLookupByName },
{ "NWFilterLookupByUUID", virtDBusConnectNWFilterLookupByUUID },
......
......@@ -143,6 +143,19 @@ class TestConnect(libvirttest.BaseTestClass):
self.main_loop()
@pytest.mark.usefixtures("node_device_create")
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("NodeDeviceLookupByName", 'Name'),
])
def test_connect_node_device_lookup_by_property(self, lookup_method_name, lookup_item):
"""Parameterized test for all NodeDeviceLookupBy* API calls of Connect interface
"""
original_path = self.node_device_create()
obj = self.bus.get_object('org.libvirt', original_path)
prop = obj.Get('org.libvirt.NodeDevice', lookup_item, dbus_interface=dbus.PROPERTIES_IFACE)
path = getattr(self.connect, lookup_method_name)(prop)
assert original_path == path
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("NetworkLookupByName", 'Name'),
("NetworkLookupByUUID", 'UUID'),
......
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