Commit 471b8f46 authored by Katerina Koukiou's avatar Katerina Koukiou

Implement StoragePoolDefineXML method for Connect Interface

Signed-off-by: default avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Pavel Hrdina's avatarPavel Hrdina <phrdina@redhat.com>
parent d1957cf5
......@@ -265,6 +265,13 @@
<arg name="flags" type="u" direction="in"/>
<arg name="storagePool" type="o" direction="out"/>
</method>
<method name="StoragePoolDefineXML">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDefineXML"/>
<arg name="xml" type="s" direction="in"/>
<arg name="flags" type="u" direction="in"/>
<arg name="storagePool" type="o" direction="out"/>
</method>
<method name="StoragePoolLookupByName">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolLookupByName"/>
......
......@@ -1333,6 +1333,36 @@ virtDBusConnectStoragePoolCreateXML(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectStoragePoolDefineXML(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(virStoragePool) storagePool = NULL;
g_autofree gchar *path = NULL;
gchar *xml;
guint flags;
g_variant_get(inArgs, "(&su)", &xml, &flags);
if (!virtDBusConnectOpen(connect, error))
return;
storagePool = virStoragePoolDefineXML(connect->connection, xml, flags);
if (!storagePool)
return virtDBusUtilSetLastVirtError(error);
path = virtDBusUtilBusPathForVirStoragePool(storagePool,
connect->storagePoolPath);
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectStoragePoolLookupByName(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -1438,6 +1468,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "SecretLookupByUUID", virtDBusConnectSecretLookupByUUID },
{ "SecretLookupByUsage", virtDBusConnectSecretLookupByUsage },
{ "StoragePoolCreateXML", virtDBusConnectStoragePoolCreateXML },
{ "StoragePoolDefineXML", virtDBusConnectStoragePoolDefineXML },
{ "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
{ "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID },
{ 0 }
......
......@@ -215,6 +215,21 @@ class TestConnect(libvirttest.BaseTestClass):
self.main_loop()
def test_connect_storage_pool_define_xml(self):
def storage_pool_defined(path, event, _detail):
if event != libvirttest.StoragePoolEvent.DEFINED:
return
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
self.connect.connect_to_signal('StoragePoolEvent', storage_pool_defined)
path = self.connect.StoragePoolDefineXML(
self.minimal_storage_pool_xml, 0)
assert isinstance(path, dbus.ObjectPath)
self.main_loop()
@pytest.mark.parametrize("lookup_method_name,lookup_item", [
("StoragePoolLookupByName", 'Name'),
("StoragePoolLookupByUUID", '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