Commit 155d3424 authored by Katerina Koukiou's avatar Katerina Koukiou

Implement StorageVolLookupByKey method for Connect Interface

Signed-off-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Jano Tomko's avatarJán Tomko <jtomko@redhat.com>
parent 4c789a82
......@@ -308,6 +308,12 @@
<arg name="uuid" type="s" direction="in"/>
<arg name="storagePool" type="o" direction="out"/>
</method>
<method name="StorageVolLookupByKey">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolLookupByKey"/>
<arg name="key" type="s" direction="in"/>
<arg name="storageVol" type="o" direction="out"/>
</method>
<signal name="DomainEvent">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
......
......@@ -1544,6 +1544,35 @@ virtDBusConnectStoragePoolLookupByUUID(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectStorageVolLookupByKey(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(virStorageVol) storageVol = NULL;
g_autofree gchar *path = NULL;
const gchar *key;
g_variant_get(inArgs, "(&s)", &key);
if (!virtDBusConnectOpen(connect, error))
return;
storageVol = virStorageVolLookupByKey(connect->connection, key);
if (!storageVol)
return virtDBusUtilSetLastVirtError(error);
path = virtDBusUtilBusPathForVirStorageVol(storageVol,
connect->storageVolPath);
*outArgs = g_variant_new("(o)", path);
}
static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
{ "Encrypted", virtDBusConnectGetEncrypted, NULL },
{ "Hostname", virtDBusConnectGetHostname, NULL },
......@@ -1597,6 +1626,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "StoragePoolDefineXML", virtDBusConnectStoragePoolDefineXML },
{ "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
{ "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID },
{ "StorageVolLookupByKey", virtDBusConnectStorageVolLookupByKey },
{ 0 }
};
......
......@@ -212,6 +212,21 @@ class TestConnect(libvirttest.BaseTestClass):
path = getattr(self.connect, lookup_method_name)(prop)
assert original_path == path
@pytest.mark.usefixtures("storage_volume_create")
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("StorageVolLookupByKey", 'Key'),
])
def test_connect_storage_vol_lookup_by_property(self,
lookup_method_name,
lookup_item):
"""Parameterized test for all StorageVolLookupBy* API calls of Connect interface
"""
original_path, obj = self.get_test_storage_volume()
prop = obj.Get('org.libvirt.StorageVol', lookup_item,
dbus_interface=dbus.PROPERTIES_IFACE)
path = getattr(self.connect, lookup_method_name)(prop)
assert original_path == path
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