Commit d684e2ef authored by Katerina Koukiou's avatar Katerina Koukiou

Implement ListStorageVolumes for StoragePool Interface

Signed-off-by: default avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Jano Tomko's avatarJán Tomko <jtomko@redhat.com>
parent 8a7c7ee9
......@@ -57,6 +57,12 @@
<arg name="flags" type="u" direction="in"/>
<arg name="xml" type="s" direction="out"/>
</method>
<method name="ListStorageVolumes">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolListAllVolumes"/>
<arg name="flags" type="u" direction="in"/>
<arg name="storageVols" type="ao" direction="out"/>
</method>
<method name="Refresh">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolRefresh"/>
......
......@@ -301,6 +301,48 @@ virtDBusStoragePoolGetXMLDesc(GVariant *inArgs,
*outArgs = g_variant_new("(s)", xml);
}
static void
virtDBusStoragePoolListStorageVolumes(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
const gchar *objectPath,
gpointer userData,
GVariant **outArgs,
GUnixFDList **outFDs G_GNUC_UNUSED,
GError **error)
{
virtDBusConnect *connect = userData;
g_autoptr(virStoragePool) storagePool = NULL;
g_autoptr(virStorageVolPtr) storageVols = NULL;
guint flags;
gint nVols;
GVariantBuilder builder;
GVariant *gstorageVols;
g_variant_get(inArgs, "(u)", &flags);
storagePool = virtDBusStoragePoolGetVirStoragePool(connect, objectPath,
error);
if (!storagePool)
return;
nVols = virStoragePoolListAllVolumes(storagePool, &storageVols, flags);
if (nVols < 0)
return virtDBusUtilSetLastVirtError(error);
g_variant_builder_init(&builder, G_VARIANT_TYPE("ao"));
for (gint i = 0; i < nVols; i++) {
g_autofree gchar *path = NULL;
path = virtDBusUtilBusPathForVirStorageVol(storageVols[i],
connect->storageVolPath);
g_variant_builder_add(&builder, "o", path);
}
gstorageVols = g_variant_builder_end(&builder);
*outArgs = g_variant_new_tuple(&gstorageVols, 1);
}
static void
virtDBusStoragePoolRefresh(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -363,6 +405,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] = {
{ "Destroy", virtDBusStoragePoolDestroy },
{ "GetInfo", virtDBusStoragePoolGetInfo },
{ "GetXMLDesc", virtDBusStoragePoolGetXMLDesc },
{ "ListStorageVolumes", virtDBusStoragePoolListStorageVolumes },
{ "Refresh", virtDBusStoragePoolRefresh },
{ "Undefine", virtDBusStoragePoolUndefine },
{ 0 }
......
......@@ -79,6 +79,14 @@ class TestStoragePool(libvirttest.BaseTestClass):
info = interface_obj.GetXMLDesc(0)
assert isinstance(info, dbus.String)
def test_storage_pool_list_storage_volumes(self):
_, test_storage_pool = self.test_storage_pool()
interface_obj = dbus.Interface(test_storage_pool,
'org.libvirt.StoragePool')
storage_vols = interface_obj.ListStorageVolumes(0)
assert isinstance(storage_vols, dbus.Array)
assert len(storage_vols) == 0
def test_storage_pool_properties_type(self):
_, obj = self.test_storage_pool()
......
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