]>
Commit | Line | Data |
---|---|---|
cc7b93ec DM |
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 | ||
5e4035c7 DM |
17 | sub setup_environment { |
18 | PVE::RPCEnvironment->setup_default_cli_env(); | |
19 | } | |
20 | ||
cc7b93ec DM |
21 | __PACKAGE__->register_method({ |
22 | name => 'qmrestore', | |
23 | path => 'qmrestore', | |
24 | method => 'POST', | |
25 | description => "Restore QemuServer vzdump backups.", | |
26 | parameters => { | |
27 | additionalProperties => 0, | |
28 | properties => { | |
29 | vmid => get_standard_option('pve-vmid', { completion => \&PVE::Cluster::complete_next_vmid }), | |
30 | archive => { | |
31 | description => "The backup file. You can pass '-' to read from standard input.", | |
32 | type => 'string', | |
33 | maxLength => 255, | |
34 | completion => \&PVE::QemuServer::complete_backup_archives, | |
35 | }, | |
36 | storage => get_standard_option('pve-storage-id', { | |
37 | description => "Default storage.", | |
38 | optional => 1, | |
39 | completion => \&PVE::QemuServer::complete_storage, | |
40 | }), | |
41 | force => { | |
42 | optional => 1, | |
43 | type => 'boolean', | |
44 | description => "Allow to overwrite existing VM.", | |
45 | }, | |
46 | unique => { | |
47 | optional => 1, | |
48 | type => 'boolean', | |
49 | description => "Assign a unique random ethernet address.", | |
50 | }, | |
51 | pool => { | |
52 | optional => 1, | |
53 | type => 'string', format => 'pve-poolid', | |
54 | description => "Add the VM to the specified pool.", | |
55 | }, | |
7c536e11 WB |
56 | bwlimit => { |
57 | description => "Override io bandwidth.", | |
58 | optional => 1, | |
59 | type => 'number', | |
60 | minimum => '0', | |
61 | } | |
cc7b93ec DM |
62 | }, |
63 | }, | |
64 | returns => { | |
65 | type => 'string', | |
66 | }, | |
67 | code => sub { | |
68 | my ($param) = @_; | |
69 | ||
70 | $param->{node} = PVE::INotify::nodename(); | |
71 | ||
72 | return PVE::API2::Qemu->create_vm($param); | |
73 | }}); | |
74 | ||
75 | our $cmddef = [ __PACKAGE__, 'qmrestore', ['archive', 'vmid'], undef, | |
76 | sub { | |
77 | my $upid = shift; | |
78 | my $status = PVE::Tools::upid_read_status($upid); | |
79 | exit($status eq 'OK' ? 0 : -1); | |
80 | }]; | |
81 | ||
82 | 1; |