]> git.proxmox.com Git - qemu-server.git/blob - PVE/CLI/qmrestore.pm
use pve-doc-generator to generate man pages
[qemu-server.git] / PVE / CLI / qmrestore.pm
1 package PVE::CLI::qmrestore;
2
3 use strict;
4 use warnings;
5 use PVE::SafeSyslog;
6 use PVE::Tools qw(extract_param);
7 use PVE::INotify;
8 use PVE::RPCEnvironment;
9 use PVE::CLIHandler;
10 use PVE::JSONSchema qw(get_standard_option);
11 use PVE::Cluster;
12 use PVE::QemuServer;
13 use PVE::API2::Qemu;
14
15 use base qw(PVE::CLIHandler);
16
17 __PACKAGE__->register_method({
18 name => 'qmrestore',
19 path => 'qmrestore',
20 method => 'POST',
21 description => "Restore QemuServer vzdump backups.",
22 parameters => {
23 additionalProperties => 0,
24 properties => {
25 vmid => get_standard_option('pve-vmid', { completion => \&PVE::Cluster::complete_next_vmid }),
26 archive => {
27 description => "The backup file. You can pass '-' to read from standard input.",
28 type => 'string',
29 maxLength => 255,
30 completion => \&PVE::QemuServer::complete_backup_archives,
31 },
32 storage => get_standard_option('pve-storage-id', {
33 description => "Default storage.",
34 optional => 1,
35 completion => \&PVE::QemuServer::complete_storage,
36 }),
37 force => {
38 optional => 1,
39 type => 'boolean',
40 description => "Allow to overwrite existing VM.",
41 },
42 unique => {
43 optional => 1,
44 type => 'boolean',
45 description => "Assign a unique random ethernet address.",
46 },
47 pool => {
48 optional => 1,
49 type => 'string', format => 'pve-poolid',
50 description => "Add the VM to the specified pool.",
51 },
52 },
53 },
54 returns => {
55 type => 'string',
56 },
57 code => sub {
58 my ($param) = @_;
59
60 $param->{node} = PVE::INotify::nodename();
61
62 return PVE::API2::Qemu->create_vm($param);
63 }});
64
65 our $cmddef = [ __PACKAGE__, 'qmrestore', ['archive', 'vmid'], undef,
66 sub {
67 my $upid = shift;
68 my $status = PVE::Tools::upid_read_status($upid);
69 exit($status eq 'OK' ? 0 : -1);
70 }];
71
72 1;