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

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Apr 4 18:54:47 CEST 2019


On 4/4/19 3:43 PM, Oguz Bektas wrote:
> 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",

what properties can the return object have?
document those, with optionalness, type, format, ...

> +    },
> +    code => sub {
> +	my ($param) = @_;
> +
> +	my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
> +
> +	my $qdevice_cfg = $conf->{main}->{quorum}->{device} // {};

hmm, if we only return the configuration we could put this in ClusterConfig.pm
for now? totem, and nodes, both also returning parts of the config almost directly
are also there... that said, maybe it makes sense to have a plain return corosync
config call, so that if something else comes along we do not need to add yet another
one?

> +
> +	return $qdevice_cfg;
> +    }});
> +#TODO: possibly add setup and remove methods
> +1;
> 





More information about the pve-devel mailing list