Add start command
[pve-client.git] / PVE / APIClient / Commands / start.pm
1 package PVE::APIClient::Commands::start;
2
3 use strict;
4 use warnings;
5
6 use PVE::APIClient::Helpers;
7 use PVE::JSONSchema qw(get_standard_option);
8
9 use PVE::CLIHandler;
10
11 use base qw(PVE::CLIHandler);
12
13 __PACKAGE__->register_method ({
14 name => 'start',
15 path => 'start',
16 method => 'POST',
17 description => "Start a Qemu VM/LinuX Container.",
18 parameters => {
19 additionalProperties => 0,
20 properties => {
21 remote => get_standard_option('pveclient-remote-name'),
22 vmid => get_standard_option('pve-vmid'),
23 },
24 },
25 returns => { type => 'null'},
26 code => sub {
27 my ($param) = @_;
28
29 my $config = PVE::APIClient::Config->load();
30 my $conn = PVE::APIClient::Config->remote_conn($config, $param->{remote});
31
32 my $resource = PVE::APIClient::Helpers::get_vmid_resource($conn, $param->{vmid});
33
34 my $upid = $conn->post("api2/json/nodes/$resource->{node}/$resource->{type}/$resource->{vmid}/status/start", {});
35
36 print PVE::APIClient::Helpers::poll_task($conn, $resource->{node}, $upid) . "\n";
37
38 return undef;
39 }});
40
41 our $cmddef = [ __PACKAGE__, 'start', ['remote', 'vmid']];
42
43 1;