[dbus PATCH 03/10] Implement UUID property 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.Network.xml |  4 ++++
 src/network.c                | 21 +++++++++++++++++++++
 test/test_network.py         |  1 +
 3 files changed, 26 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index 30b352a..d144c5d 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -15,5 +15,9 @@
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetName"/>
     </property>
+    <property name="UUID" type="s" access="read">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUIDString"/>
+    </property>
   </interface>
 </node>
diff --git a/src/network.c b/src/network.c
index 5e48fa7..90c2d9c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -87,10 +87,31 @@ virtDBusNetworkGetName(const gchar *objectPath,
     *value = g_variant_new("s", name);
 }
 
+static void
+virtDBusNetworkGetUUID(const gchar *objectPath,
+                       gpointer userData,
+                       GVariant **value,
+                       GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virNetwork) network = NULL;
+    gchar uuid[VIR_UUID_STRING_BUFLEN] = "";
+
+    network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+    if (!network)
+        return;
+
+    if (virNetworkGetUUIDString(network, uuid) < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *value = g_variant_new("s", uuid);
+}
+
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
     { "Autostart", virtDBusNetworkGetAutostart, NULL },
     { "BridgeName", virtDBusNetworkGetBridgeName, NULL },
     { "Name", virtDBusNetworkGetName, NULL },
+    { "UUID", virtDBusNetworkGetUUID, NULL },
     { 0 }
 };
 
diff --git a/test/test_network.py b/test/test_network.py
index 1842944..e753f7f 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -15,6 +15,7 @@ class TestNetwork(libvirttest.BaseTestClass):
         assert isinstance(props['Autostart'], dbus.Boolean)
         assert isinstance(props['BridgeName'], dbus.String)
         assert isinstance(props['Name'], dbus.String)
+        assert isinstance(props['UUID'], dbus.String)
 
 
 if __name__ == '__main__':
-- 
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