]> git.proxmox.com Git - pve-manager.git/blob - PVE/VZDump/Plugin.pm
989135222f2f90295b7cdb3f1b3afb6adf3fbaa6
[pve-manager.git] / PVE / VZDump / Plugin.pm
1 package PVE::VZDump::Plugin;
2
3 use strict;
4 use warnings;
5 use PVE::VZDump;
6
7 sub set_logfd {
8 my ($self, $logfd) = @_;
9
10 $self->{logfd} = $logfd;
11 }
12
13 sub cmd {
14 my ($self, $cmdstr, %param) = @_;
15
16 return PVE::VZDump::run_command($self->{logfd}, $cmdstr, %param);
17 }
18
19 sub cmd_noerr {
20 my ($self, $cmdstr, %param) = @_;
21
22 my $res;
23 eval { $res = $self->cmd($cmdstr, %param); };
24 $self->logerr ($@) if $@;
25 return $res;
26 }
27
28 sub loginfo {
29 my ($self, $msg) = @_;
30
31 PVE::VZDump::debugmsg('info', $msg, $self->{logfd}, 0);
32 }
33
34 sub logerr {
35 my ($self, $msg) = @_;
36
37 PVE::VZDump::debugmsg('err', $msg, $self->{logfd}, 0);
38 }
39
40 sub type {
41 return 'unknown';
42 };
43
44 sub vmlist {
45 my ($self) = @_;
46
47 return [ keys %{$self->{vmlist}} ] if $self->{vmlist};
48
49 return [];
50 }
51
52 sub vm_status {
53 my ($self, $vmid) = @_;
54
55 die "internal error"; # implement in subclass
56 }
57
58 sub prepare {
59 my ($self, $task, $vmid, $mode) = @_;
60
61 die "internal error"; # implement in subclass
62 }
63
64 sub lock_vm {
65 my ($self, $vmid) = @_;
66
67 die "internal error"; # implement in subclass
68 }
69
70 sub unlock_vm {
71 my ($self, $vmid) = @_;
72
73 die "internal error"; # implement in subclass
74 }
75
76 sub stop_vm {
77 my ($self, $task, $vmid) = @_;
78
79 die "internal error"; # implement in subclass
80 }
81
82 sub start_vm {
83 my ($self, $task, $vmid) = @_;
84
85 die "internal error"; # implement in subclass
86 }
87
88 sub suspend_vm {
89 my ($self, $task, $vmid) = @_;
90
91 die "internal error"; # implement in subclass
92 }
93
94 sub resume_vm {
95 my ($self, $task, $vmid) = @_;
96
97 die "internal error"; # implement in subclass
98 }
99
100 sub snapshot {
101 my ($self, $task, $vmid) = @_;
102
103 die "internal error"; # implement in subclass
104 }
105
106 sub copy_data_phase2 {
107 my ($self, $task, $vmid) = @_;
108
109 die "internal error"; # implement in subclass
110 }
111
112 sub assemble {
113 my ($self, $task, $vmid) = @_;
114
115 die "internal error"; # implement in subclass
116 }
117
118 sub archive {
119 my ($self, $task, $vmid, $filename, $comp) = @_;
120
121 die "internal error"; # implement in subclass
122 }
123
124 sub cleanup {
125 my ($self, $task, $vmid) = @_;
126
127 die "internal error"; # implement in subclass
128 }
129
130 1;