
On Mon, May 07, 2018 at 04:40:56PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 30 ++++++++++++++++++++++++++++++ tests/test_connect.py | 15 +++++++++++++++ 3 files changed, 51 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 6b156d1..55c0883 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -217,6 +217,12 @@ <arg name="params" type="a{sv}" direction="in"/> <arg name="flags" type="u" direction="in"/> </method> + <method name="StoragePoolLookupByName"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolLookupByName"/> + <arg name="name" type="s" direction="in"/> + <arg name="storagePool" 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"/> diff --git a/src/connect.c b/src/connect.c index 97c4857..fa4078f 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1104,6 +1104,35 @@ virtDBusConnectNodeSetMemoryParameters(GVariant *inArgs, } }
+static void +virtDBusConnectStoragePoolLookupByName(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; + const gchar *name; + + g_variant_get(inArgs, "(s)", &name); + + if (!virtDBusConnectOpen(connect, error)) + return; + + storagePool = virStoragePoolLookupByName(connect->connection, name); + if (!storagePool) + return virtDBusUtilSetLastVirtError(error); + + path = virtDBusUtilBusPathForVirStoragePool(storagePool, + connect->storagePoolPath); + + *outArgs = g_variant_new("(o)", path); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1143,6 +1172,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats }, { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel }, { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters }, + { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName }, { 0 } };
diff --git a/tests/test_connect.py b/tests/test_connect.py index d8f05e8..2e0cd7f 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -190,6 +190,21 @@ class TestConnect(libvirttest.BaseTestClass): info = self.connect.NodeGetCPUMap(0) assert isinstance(info, dbus.Array)
+ @pytest.mark.parametrize("lookup_method_name,lookup_item", [ + ("StoragePoolLookupByName", 'Name'), + ]) + def test_connect_network_lookup_by_property( + self, + lookup_method_name, + lookup_item):
The function name is not correct, it should say 'storage_pool'. I don't like this style :) how about: def test_connect_storage_pool_lookup_by_property(self, lookup_method_name, lookup_item): Pavel