[pve-devel] [PATCH v3 storage 08/23] Add apiinfo helper to pvesm

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Mar 16 12:06:01 CET 2020


On March 12, 2020 1:08 pm, Fabian Ebner wrote:
> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
> ---
>  PVE/CLI/pvesm.pm | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/PVE/CLI/pvesm.pm b/PVE/CLI/pvesm.pm
> index 510faba..7c0e259 100755
> --- a/PVE/CLI/pvesm.pm
> +++ b/PVE/CLI/pvesm.pm
> @@ -47,6 +47,30 @@ sub setup_environment {
>      PVE::RPCEnvironment->setup_default_cli_env();
>  }
>  
> +__PACKAGE__->register_method ({
> +    name => 'apiinfo',
> +    path => 'apiinfo',
> +    method => 'GET',
> +    description => "For internal use. Returns APIVER and APIAGE.",

IMHO this is just as much for internal as for third-party use. E.g., 
some config management tool might use this to check which version of a 
third-party plugin to deploy. or the install script of a third-party 
plugin might use this select a compatible version.

> +    parameters => {
> +	additionalProperties => 0,
> +	properties => {},
> +    },
> +    returns => {
> +	type => 'object',
> +	properties => {
> +	    apiver => { type => 'integer' },
> +	    apiage => { type => 'integer' },
> +	},
> +    },
> +    code => sub {
> +	return {
> +	    apiver => PVE::Storage::APIVER,
> +	    apiage => PVE::Storage::APIAGE,
> +	};
> +    }
> +});
> +
>  __PACKAGE__->register_method ({
>      name => 'path',
>      path => 'path',
> @@ -778,6 +802,12 @@ our $cmddef = {
>      extractconfig => [__PACKAGE__, 'extractconfig', ['volume']],
>      export => [ __PACKAGE__, 'export', ['volume', 'format', 'filename']],
>      import => [ __PACKAGE__, 'import', ['volume', 'format', 'filename']],
> +    apiinfo => [ __PACKAGE__, 'apiinfo', [], {}, sub {
> +	my $res = shift;
> +
> +	print "APIVER $res->{apiver}\n";
> +	print "APIAGE $res->{apiage}\n";
> +    }],
>  };
>  
>  1;
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 




More information about the pve-devel mailing list