diff --git a/PVE/API2.pm b/PVE/API2.pm index ff2592b7..847736af 100644 --- a/PVE/API2.pm +++ b/PVE/API2.pm @@ -4,6 +4,7 @@ use strict; use warnings; use Apache2::Const qw(:http); +use PVE::pvecfg; use PVE::RESTHandler; use base qw(PVE::RESTHandler); @@ -57,7 +58,7 @@ __PACKAGE__->register_method ({ code => sub { my ($resp, $param) = @_; - my $res = []; + my $res = [ { subdir => 'version' } ]; my $ma = PVE::API2->method_attributes(); @@ -72,4 +73,27 @@ __PACKAGE__->register_method ({ 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; diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index d2be863b..fe6249c3 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -92,6 +92,7 @@ __PACKAGE__->register_method ({ my ($param) = @_; my $result = [ + { name => 'version' }, { name => 'syslog' }, { name => 'status' }, { name => 'tasks' }, @@ -115,6 +116,33 @@ __PACKAGE__->register_method ({ 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({ name => 'beancounters_failcnt', path => 'ubcfailcnt', @@ -266,8 +294,7 @@ __PACKAGE__->register_method({ }; $res->{pveversion} = PVE::pvecfg::package() . "/" . - PVE::pvecfg::version() . "/" . - PVE::pvecfg::repoid(); + PVE::pvecfg::version_text(); my $dinfo = df('/', 1); # output is bytes diff --git a/PVE/Makefile b/PVE/Makefile index ec604fde..4f42ce14 100644 --- a/PVE/Makefile +++ b/PVE/Makefile @@ -17,7 +17,7 @@ all: pvecfg.pm ${SUBDIRS} REPOID=`../repoid.pl ../.git` 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 $@ %: diff --git a/PVE/pvecfg.pm.in b/PVE/pvecfg.pm.in index 12a633db..376ed5d1 100644 --- a/PVE/pvecfg.pm.in +++ b/PVE/pvecfg.pm.in @@ -12,8 +12,26 @@ sub version { return '@VERSION@'; } +sub release { + return '@PACKAGERELEASE@'; +} + sub repoid { return '@REPOID@'; } -1; \ No newline at end of file +# 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; diff --git a/www/manager/index.pl b/www/manager/index.pl index 7f89a948..ddde3867 100644 --- a/www/manager/index.pl +++ b/www/manager/index.pl @@ -42,7 +42,7 @@ if (my $cookie = $r->headers_in->{Cookie}) { $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; my $cgi = CGI->new($r);