[pve-devel] [PATCH cluster] add qdevice status api method

Oguz Bektas o.bektas at proxmox.com
Thu Apr 4 15:43:09 CEST 2019


this enables the qdevice config to be retrieved using the api.

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 data/PVE/API2/Makefile   |  2 +-
 data/PVE/API2/QDevice.pm | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 data/PVE/API2/QDevice.pm

diff --git a/data/PVE/API2/Makefile b/data/PVE/API2/Makefile
index 0eeba51..79700ce 100644
--- a/data/PVE/API2/Makefile
+++ b/data/PVE/API2/Makefile
@@ -1,6 +1,6 @@
 PVEDIR=${DESTDIR}/usr/share/perl5/PVE
 
-SOURCES=ClusterConfig.pm
+SOURCES=ClusterConfig.pm QDevice.pm
 
 .PHONY: install
 install: ${SOURCES}
diff --git a/data/PVE/API2/QDevice.pm b/data/PVE/API2/QDevice.pm
new file mode 100644
index 0000000..c5d8b01
--- /dev/null
+++ b/data/PVE/API2/QDevice.pm
@@ -0,0 +1,36 @@
+package PVE::API2::QDevice;
+
+use strict;
+use warnings;
+
+use PVE::RESTHandler;
+use PVE::Cluster;
+
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method ({
+    name => 'status',
+    path => '',
+    method => 'GET',
+    description => 'Get QDevice and configuration.',
+    permissions => {
+	check => ['perm', '/', [ 'Sys.Audit' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {},
+    },
+    returns => {
+	type => "object",
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
+
+	my $qdevice_cfg = $conf->{main}->{quorum}->{device} // {};
+
+	return $qdevice_cfg;
+    }});
+#TODO: possibly add setup and remove methods
+1;
-- 
2.11.0





More information about the pve-devel mailing list