[pve-devel] [PATCH pve-client] Add the remaining guest commands

Dietmar Maurer dietmar at proxmox.com
Thu Jun 14 12:47:25 CEST 2018


applied (but made timeout optional)

> On June 14, 2018 at 12:15 PM René Jochum <r.jochum at proxmox.com> wrote:
> 
> 
> Signed-off-by: René Jochum <r.jochum at proxmox.com>
> ---
>  PVE/APIClient/Commands/GuestStatus.pm | 87
> +++++++++++++++++++++++++++++++++++
>  pveclient                             |  3 ++
>  2 files changed, 90 insertions(+)
> 
> diff --git a/PVE/APIClient/Commands/GuestStatus.pm
> b/PVE/APIClient/Commands/GuestStatus.pm
> index 57784e5..92f424d 100644
> --- a/PVE/APIClient/Commands/GuestStatus.pm
> +++ b/PVE/APIClient/Commands/GuestStatus.pm
> @@ -61,6 +61,11 @@ __PACKAGE__->register_method ({
>  	properties => {
>  	    remote => get_standard_option('pveclient-remote-name'),
>  	    vmid => get_standard_option('pve-vmid'),
> +	    timeout => {
> +		description => "Timeout in seconds",
> +		type => 'integer',
> +		minimum => 1

why is this required (should be optional => 1)?

> +	    },
>  	},
>      },
>      returns => { type => 'null'},
> @@ -76,6 +81,88 @@ __PACKAGE__->register_method ({
>      }});
>  
>  __PACKAGE__->register_method ({
> +    name => 'shutdown',
> +    path => 'shutdown',
> +    method => 'POST',
> +    description => "Stop a guest (VM/Container).",
> +    parameters => {
> +	additionalProperties => 0,
> +	properties => {
> +	    remote => get_standard_option('pveclient-remote-name'),
> +	    vmid => get_standard_option('pve-vmid'),
> +	    force => {
> +		description => "Make sure the Container/VM stops.",
> +		type => 'boolean',
> +		optional => 1,
> +	    },
> +	    timeout => {
> +		description => "Timeout in seconds",
> +		type => 'integer',
> +		minimum => 1

why is this required (should be optional => 1)?

> +	    },
> +	},
> +    },
> +    returns => { type => 'null'},
> +    code => sub {
> +	my ($param) = @_;
> +
> +	my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
> +	my $vmid = PVE::APIClient::Tools::extract_param($param, 'vmid');
> +
> +	$guest_status_command->($remote, $vmid, 'shutdown', $param);
> +
> +	return undef;
> +    }});
> +
> +__PACKAGE__->register_method ({
> +    name => 'suspend',
> +    path => 'suspend',
> +    method => 'POST',
> +    description => "Suspend a guest VM.",
> +    parameters => {
> +	additionalProperties => 0,
> +	properties => {
> +	    remote => get_standard_option('pveclient-remote-name'),
> +	    vmid => get_standard_option('pve-vmid'),
> +	},
> +    },
> +    returns => { type => 'null'},
> +    code => sub {
> +	my ($param) = @_;
> +
> +	my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
> +	my $vmid = PVE::APIClient::Tools::extract_param($param, 'vmid');
> +
> +	$guest_status_command->($remote, $vmid, 'suspend', $param);
> +
> +	return undef;
> +    }});
> +
> +__PACKAGE__->register_method ({
> +    name => 'resume',
> +    path => 'resume',
> +    method => 'POST',
> +    description => "Resume a guest VM.",
> +    parameters => {
> +	additionalProperties => 0,
> +	properties => {
> +	    remote => get_standard_option('pveclient-remote-name'),
> +	    vmid => get_standard_option('pve-vmid'),
> +	},
> +    },
> +    returns => { type => 'null'},
> +    code => sub {
> +	my ($param) = @_;
> +
> +	my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
> +	my $vmid = PVE::APIClient::Tools::extract_param($param, 'vmid');
> +
> +	$guest_status_command->($remote, $vmid, 'resume', $param);
> +
> +	return undef;
> +    }});
> +
> +__PACKAGE__->register_method ({
>      name => 'spice',
>      path => 'spice',
>      method => 'POST',
> diff --git a/pveclient b/pveclient
> index 404090f..9bcbff2 100755
> --- a/pveclient
> +++ b/pveclient
> @@ -177,9 +177,12 @@ our $cmddef = {
>      lxc => $PVE::APIClient::Commands::lxc::cmddef,
>      remote => $PVE::APIClient::Commands::remote::cmddef,
>  
> +    resume => [ 'PVE::APIClient::Commands::GuestStatus', 'resume', ['remote',
> 'vmid']],
> +    shutdown => [ 'PVE::APIClient::Commands::GuestStatus', 'shutdown',
> ['remote', 'vmid']],
>      spice => [ 'PVE::APIClient::Commands::GuestStatus', 'spice', ['remote',
> 'vmid']],
>      start => [ 'PVE::APIClient::Commands::GuestStatus', 'start', ['remote',
> 'vmid']],
>      stop => [ 'PVE::APIClient::Commands::GuestStatus', 'stop', ['remote',
> 'vmid']],
> +    suspend => [ 'PVE::APIClient::Commands::GuestStatus', 'suspend',
> ['remote', 'vmid']],
>  
>      api => {
>  	get => [ __PACKAGE__, 'pveclient_get', ['remote', 'api_path'], {},
> $format_result ],
> -- 
> 2.11.0
> 
> _______________________________________________
> 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