]> git.proxmox.com Git - pve-client.git/blobdiff - PVE/APIClient/Commands/GuestStatus.pm
Fix old none ::APIClient uses.
[pve-client.git] / PVE / APIClient / Commands / GuestStatus.pm
index 50730db3885015f053dbe6dbabf66e41b15d5c0b..03e2e4aea3a6b65ddc5ccb85a7f44c6e4edc965b 100644 (file)
@@ -6,13 +6,13 @@ use warnings;
 use PVE::APIClient::Helpers;
 use PVE::APIClient::Config;
 
-use PVE::JSONSchema qw(get_standard_option);
+use PVE::APIClient::JSONSchema qw(get_standard_option);
 
 use File::Temp qw(tempfile);
 
-use PVE::CLIHandler;
+use PVE::APIClient::CLIHandler;
 
-use base qw(PVE::CLIHandler);
+use base qw(PVE::APIClient::CLIHandler);
 
 my $guest_status_command = sub {
     my ($remote, $vmid, $cmd, $param) = @_,
@@ -43,8 +43,8 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
-       my $remote = PVE::Tools::extract_param($param, 'remote');
-       my $vmid = PVE::Tools::extract_param($param, 'vmid');
+       my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
+       my $vmid = PVE::APIClient::Tools::extract_param($param, 'vmid');
 
        $guest_status_command->($remote, $vmid, 'start', $param);
 
@@ -61,20 +61,109 @@ __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,
+               optional => 1,
+           },
        },
     },
     returns => { type => 'null'},
     code => sub {
        my ($param) = @_;
 
-       my $remote = PVE::Tools::extract_param($param, 'remote');
-       my $vmid = PVE::Tools::extract_param($param, 'vmid');
+       my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
+       my $vmid = PVE::APIClient::Tools::extract_param($param, 'vmid');
 
        $guest_status_command->($remote, $vmid, 'stop', $param);
 
        return undef;
     }});
 
+__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,
+               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',
@@ -91,8 +180,8 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
-       my $remote = PVE::Tools::extract_param($param, 'remote');
-       my $vmid = PVE::Tools::extract_param($param, 'vmid');
+       my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
+       my $vmid = PVE::APIClient::Tools::extract_param($param, 'vmid');
 
        my $config = PVE::APIClient::Config->load();
        my $conn = PVE::APIClient::Config->remote_conn($config, $remote);