[pve-devel] [PATCH pve-client] Use API definition for start/stop properties

René Jochum r.jochum at proxmox.com
Wed Jun 13 15:02:10 CEST 2018


This works but currently 'qemu' is hard coded in the
"merge_api_definition_properties" path which
has the behavior that we ALWAYS get qemu "properties" where we want LXC
properties often.

The only solution I can think of is to split those commands for Qemu/LXC
as in:
   
    $ pveclient qemu start lola 100
    $ pveclient lxc start lola 100

What do you think about this?


On 2018-06-13 14:17, René Jochum wrote:
> ---
>  PVE/APIClient/Commands/GuestStatus.pm | 18 ++++++++++--------
>  PVE/APIClient/Helpers.pm              | 10 ++++++++++
>  2 files changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/PVE/APIClient/Commands/GuestStatus.pm b/PVE/APIClient/Commands/GuestStatus.pm
> index 4a50164..7f90798 100644
> --- a/PVE/APIClient/Commands/GuestStatus.pm
> +++ b/PVE/APIClient/Commands/GuestStatus.pm
> @@ -34,10 +34,11 @@ __PACKAGE__->register_method ({
>      description => "Start a  guest (VM/Container).",
>      parameters => {
>  	additionalProperties => 0,
> -	properties => {
> -	    remote => get_standard_option('pveclient-remote-name'),
> -	    vmid => get_standard_option('pve-vmid'),
> -	},
> +	properties => PVE::APIClient::Helpers::merge_api_definition_properties(
> +	    '/nodes/{node}/qemu/{vmid}/status/start', 'POST', {
> +		remote => get_standard_option('pveclient-remote-name'),
> +		vmid => get_standard_option('pve-vmid'),
> +	}),
>      },
>      returns => { type => 'null'},
>      code => sub {
> @@ -58,10 +59,11 @@ __PACKAGE__->register_method ({
>      description => "Stop a guest (VM/Container).",
>      parameters => {
>  	additionalProperties => 0,
> -	properties => {
> -	    remote => get_standard_option('pveclient-remote-name'),
> -	    vmid => get_standard_option('pve-vmid'),
> -	},
> +	properties => PVE::APIClient::Helpers::merge_api_definition_properties(
> +	    '/nodes/{node}/qemu/{vmid}/status/stop', 'POST', {
> +		remote => get_standard_option('pveclient-remote-name'),
> +		vmid => get_standard_option('pve-vmid'),
> +	}),
>      },
>      returns => { type => 'null'},
>      code => sub {
> diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm
> index 1ea8a5e..4eb596a 100644
> --- a/PVE/APIClient/Helpers.pm
> +++ b/PVE/APIClient/Helpers.pm
> @@ -77,6 +77,16 @@ sub lookup_api_method {
>      return $data;
>  }
>  
> +sub merge_api_definition_properties {
> +    my ($path, $method, $properties) = @_;
> +
> +    my $info = PVE::APIClient::Helpers::lookup_api_method($path, $method);
> +
> +    my %tmp = (%{$info->{parameters}->{properties}}, %$properties);
> +
> +    return \%tmp;
> +};
> +
>  sub complete_api_call_options {
>      my ($cmd, $prop, $prev, $cur, $args) = @_;
>  





More information about the pve-devel mailing list