[dbus PATCH 04/10] Implement NetworkLookupByUUID method for network interface.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Connect.xml |  6 ++++++
 src/connect.c                | 29 +++++++++++++++++++++++++++++
 test/test_connect.py         |  1 +
 3 files changed, 36 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 043ee32..d15c2f6 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -56,6 +56,12 @@
       <arg name="name" type="s" direction="in"/>
       <arg name="network" type="o" direction="out"/>
     </method>
+    <method name="NetworkLookupByUUID">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkLookupByUUID"/>
+      <arg name="uuid" type="s" direction="in"/>
+      <arg name="network" 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 d036753..f22f682 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -348,6 +348,34 @@ virtDBusNetworkLookupByName(GVariant *inArgs,
     *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusNetworkLookupByUUID(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(virNetwork) network = NULL;
+    g_autofree gchar *path = NULL;
+    const gchar *uuidstr;
+
+    g_variant_get(inArgs, "(s)", &uuidstr);
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    network = virNetworkLookupByUUIDString(connect->connection, uuidstr);
+    if (!network)
+        return virtDBusUtilSetLastVirtError(error);
+
+    path = virtDBusUtilBusPathForVirNetwork(network, connect->networkPath);
+
+    *outArgs = g_variant_new("(o)", path);
+}
+
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
     { "Version", virtDBusConnectGetVersion, NULL },
     { 0 }
@@ -362,6 +390,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "DomainLookupByUUID", virtDBusDomainLookupByUUID },
     { "ListNetworks", virtDBusConnectListNetworks },
     { "NetworkLookupByName", virtDBusNetworkLookupByName },
+    { "NetworkLookupByUUID", virtDBusNetworkLookupByUUID },
     { 0 }
 };
 
diff --git a/test/test_connect.py b/test/test_connect.py
index 440a496..5bddd2f 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -88,6 +88,7 @@ class TestConnect(libvirttest.BaseTestClass):
 
     @pytest.mark.parametrize("lookup_method_name,lookup_item", [
         ("NetworkLookupByName", 'Name'),
+        ("NetworkLookupByUUID", 'UUID'),
     ])
     def test_connect_network_lookup_by_property(self, lookup_method_name, lookup_item):
         """Parameterized test for all NetworkLookupBy* API calls of Connect interface
-- 
2.15.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux