mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-05-01 07:50:52 +00:00
add API to query version info
Normaly all nodes should have the same version, so /api2/json/version is good enough for most situations. But you can also query the version on each node using /api2/json/nodes/{node}/version
This commit is contained in:
parent
fe60654b30
commit
8747a9ece5
26
PVE/API2.pm
26
PVE/API2.pm
@ -4,6 +4,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Apache2::Const qw(:http);
|
use Apache2::Const qw(:http);
|
||||||
|
use PVE::pvecfg;
|
||||||
use PVE::RESTHandler;
|
use PVE::RESTHandler;
|
||||||
|
|
||||||
use base qw(PVE::RESTHandler);
|
use base qw(PVE::RESTHandler);
|
||||||
@ -57,7 +58,7 @@ __PACKAGE__->register_method ({
|
|||||||
code => sub {
|
code => sub {
|
||||||
my ($resp, $param) = @_;
|
my ($resp, $param) = @_;
|
||||||
|
|
||||||
my $res = [];
|
my $res = [ { subdir => 'version' } ];
|
||||||
|
|
||||||
my $ma = PVE::API2->method_attributes();
|
my $ma = PVE::API2->method_attributes();
|
||||||
|
|
||||||
@ -72,4 +73,27 @@ __PACKAGE__->register_method ({
|
|||||||
return $res;
|
return $res;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
__PACKAGE__->register_method ({
|
||||||
|
name => 'version',
|
||||||
|
path => 'version',
|
||||||
|
method => 'GET',
|
||||||
|
permissions => { user => 'all' },
|
||||||
|
description => "API version details",
|
||||||
|
parameters => {
|
||||||
|
additionalProperties => 0,
|
||||||
|
properties => {},
|
||||||
|
},
|
||||||
|
returns => {
|
||||||
|
type => "object",
|
||||||
|
properties => {
|
||||||
|
version => { type => 'string' },
|
||||||
|
release => { type => 'string' },
|
||||||
|
repoid => { type => 'string' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
code => sub {
|
||||||
|
my ($resp, $param) = @_;
|
||||||
|
|
||||||
|
return PVE::pvecfg::version_info();
|
||||||
|
}});
|
||||||
1;
|
1;
|
||||||
|
@ -92,6 +92,7 @@ __PACKAGE__->register_method ({
|
|||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
my $result = [
|
my $result = [
|
||||||
|
{ name => 'version' },
|
||||||
{ name => 'syslog' },
|
{ name => 'syslog' },
|
||||||
{ name => 'status' },
|
{ name => 'status' },
|
||||||
{ name => 'tasks' },
|
{ name => 'tasks' },
|
||||||
@ -115,6 +116,33 @@ __PACKAGE__->register_method ({
|
|||||||
return $result;
|
return $result;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
__PACKAGE__->register_method ({
|
||||||
|
name => 'version',
|
||||||
|
path => 'version',
|
||||||
|
method => 'GET',
|
||||||
|
proxyto => 'node',
|
||||||
|
permissions => { user => 'all' },
|
||||||
|
description => "API version details",
|
||||||
|
parameters => {
|
||||||
|
additionalProperties => 0,
|
||||||
|
properties => {
|
||||||
|
node => get_standard_option('pve-node'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
returns => {
|
||||||
|
type => "object",
|
||||||
|
properties => {
|
||||||
|
version => { type => 'string' },
|
||||||
|
release => { type => 'string' },
|
||||||
|
repoid => { type => 'string' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
code => sub {
|
||||||
|
my ($resp, $param) = @_;
|
||||||
|
|
||||||
|
return PVE::pvecfg::version_info();
|
||||||
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
name => 'beancounters_failcnt',
|
name => 'beancounters_failcnt',
|
||||||
path => 'ubcfailcnt',
|
path => 'ubcfailcnt',
|
||||||
@ -266,8 +294,7 @@ __PACKAGE__->register_method({
|
|||||||
};
|
};
|
||||||
|
|
||||||
$res->{pveversion} = PVE::pvecfg::package() . "/" .
|
$res->{pveversion} = PVE::pvecfg::package() . "/" .
|
||||||
PVE::pvecfg::version() . "/" .
|
PVE::pvecfg::version_text();
|
||||||
PVE::pvecfg::repoid();
|
|
||||||
|
|
||||||
my $dinfo = df('/', 1); # output is bytes
|
my $dinfo = df('/', 1); # output is bytes
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ all: pvecfg.pm ${SUBDIRS}
|
|||||||
REPOID=`../repoid.pl ../.git`
|
REPOID=`../repoid.pl ../.git`
|
||||||
|
|
||||||
pvecfg.pm: pvecfg.pm.in
|
pvecfg.pm: pvecfg.pm.in
|
||||||
sed -e s/@VERSION@/${VERSION}/ -e s/@PACKAGE@/${PACKAGE}/ -e s/@REPOID@/${REPOID}/ $< >$@.tmp
|
sed -e s/@VERSION@/${VERSION}/ -e s/@PACKAGERELEASE@/${PACKAGERELEASE}/ -e s/@PACKAGE@/${PACKAGE}/ -e s/@REPOID@/${REPOID}/ $< >$@.tmp
|
||||||
mv $@.tmp $@
|
mv $@.tmp $@
|
||||||
|
|
||||||
%:
|
%:
|
||||||
|
@ -12,8 +12,26 @@ sub version {
|
|||||||
return '@VERSION@';
|
return '@VERSION@';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub release {
|
||||||
|
return '@PACKAGERELEASE@';
|
||||||
|
}
|
||||||
|
|
||||||
sub repoid {
|
sub repoid {
|
||||||
return '@REPOID@';
|
return '@REPOID@';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# this is diplayed on the GUI
|
||||||
|
sub version_text {
|
||||||
|
return '@VERSION@-@PACKAGERELEASE@/@REPOID@';
|
||||||
|
}
|
||||||
|
|
||||||
|
# this is returned by the API
|
||||||
|
sub version_info {
|
||||||
|
return {
|
||||||
|
'version' => '@VERSION@',
|
||||||
|
'release' => '@PACKAGERELEASE@',
|
||||||
|
'repoid' => '@REPOID@',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
@ -42,7 +42,7 @@ if (my $cookie = $r->headers_in->{Cookie}) {
|
|||||||
$token = PVE::AccessControl::assemble_csrf_prevention_token($username);
|
$token = PVE::AccessControl::assemble_csrf_prevention_token($username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $version = PVE::pvecfg::version() . "/" . PVE::pvecfg::repoid();
|
my $version = PVE::pvecfg::version_text();
|
||||||
$username = '' if !$username;
|
$username = '' if !$username;
|
||||||
|
|
||||||
my $cgi = CGI->new($r);
|
my $cgi = CGI->new($r);
|
||||||
|
Loading…
Reference in New Issue
Block a user