Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 5 +++++
src/connect.c | 25 +++++++++++++++++++++++++
tests/test_connect.py | 4 ++++
3 files changed, 34 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index c642aff..6b6758f 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -178,6 +178,11 @@
value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetFreeMemory&q...
<arg name="freemem" type="t" direction="out"/>
</method>
+ <method name="NodeGetInfo">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetInfo"/>
+ <arg name="info" type="(stuuuuuu)"
direction="out"/>
+ </method>
<signal name="DomainEvent">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEven...
diff --git a/src/connect.c b/src/connect.c
index b161925..367d5ae 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -905,6 +905,30 @@ virtDBusConnectNodeGetFreeMemory(GVariant *inArgs G_GNUC_UNUSED,
*outArgs = g_variant_new("(t)", freemem);
}
+static void
+virtDBusConnectNodeGetInfo(GVariant *inArgs G_GNUC_UNUSED,
+ 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;
+ virNodeInfo info;
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ if (virNodeGetInfo(connect->connection, &info) < 0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ *outArgs = g_variant_new("((stuuuuuu))", info.model, info.memory,
+ info.cpus, info.mhz, info.nodes, info.sockets,
+ info.cores, info.threads);
+}
+
static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
{ "Encrypted", virtDBusConnectGetEncrypted, NULL },
{ "Hostname", virtDBusConnectGetHostname, NULL },
@@ -938,6 +962,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID },
{ "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats },
{ "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory },
+ { "NodeGetInfo", virtDBusConnectNodeGetInfo },
{ 0 }
};
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 7b9ad0d..f0f68b1 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -164,6 +164,10 @@ class TestConnect(libvirttest.BaseTestClass):
free_mem = self.connect.NodeGetFreeMemory()
assert isinstance(free_mem, dbus.UInt64)
+ def test_connect_node_get_info(self):
+ info = self.connect.NodeGetInfo()
+ assert isinstance(info, dbus.Struct)
+
if __name__ == '__main__':
libvirttest.run()
--
2.15.0