]>
git.proxmox.com Git - pve-manager.git/blob - PVE/API2/BackupInfo.pm
1 package PVE
::API2
::BackupInfo
;
8 use PVE
::Tools
qw(extract_param);
9 use PVE
::Cluster
qw(cfs_lock_file cfs_read_file cfs_write_file);
11 use PVE
::RPCEnvironment
;
14 use PVE
::Exception
qw(raise_param_exc);
16 use PVE
::VZDump
::Common
;
18 use base
qw(PVE::RESTHandler);
21 my ($job_included_guests, $included_vmids) = @_;
23 for my $node_vmids (values %{$job_included_guests}) {
24 for my $vmid (@{$node_vmids}) {
25 $included_vmids->{$vmid} = 1;
29 return $included_vmids;
32 sub get_included_vmids
{
33 my $included_vmids = {};
34 my $vzconf = cfs_read_file
('vzdump.cron');
36 my $all_jobs = $vzconf->{jobs
} || [];
38 for my $job (@$all_jobs) {
39 my $job_included_guests = PVE
::VZDump
::get_included_guests
($job);
40 $included_vmids = map_job_vmids
($job_included_guests, $included_vmids);
43 return $included_vmids;
46 __PACKAGE__-
>register_method({
47 name
=> 'get_backupinfo',
51 description
=> "Stub, waits for future use.",
53 additionalProperties
=> 0,
58 description
=> 'Shows stub message',
61 return "Stub endpoint. There is nothing here yet.";
64 __PACKAGE__-
>register_method({
65 name
=> 'get_guests_not_in_backup',
66 path
=> 'not_backed_up',
69 description
=> "Shows all guests which are not covered by any backup job.",
71 check
=> ['perm', '/', ['Sys.Audit']],
74 additionalProperties
=> 0,
79 description
=> 'Contains the guest objects.',
85 description
=> 'VMID of the guest.',
89 description
=> 'Name of the guest',
94 description
=> 'Type of the guest.',
95 enum
=> ['qemu', 'lxc'],
101 my $rpcenv = PVE
::RPCEnvironment
::get
();
102 my $user = $rpcenv->get_user();
103 my $rrd = PVE
::Cluster
::rrd_dump
();
104 my $included_vmids = get_included_vmids
();
105 my $vmlist = PVE
::Cluster
::get_vmlist
();
106 my @vmids = ( keys %{$vmlist->{ids
}} );
108 # remove VMIDs to which the user has no permission to not leak infos
109 # like the guest name
110 my @allowed_vmids = grep {
111 $rpcenv->check($user, "/vms/$_", [ 'VM.Audit' ], 1);
116 for my $vmid (@allowed_vmids) {
118 next if $included_vmids->{$vmid};
120 my $type = $vmlist->{ids
}->{$vmid}->{type
};
121 my $node = $vmlist->{ids
}->{$vmid}->{node
};
126 if ($type eq 'qemu') {
127 $conf = PVE
::QemuConfig-
>load_config($vmid, $node);
128 $name = $conf->{name
};
129 } elsif ($type eq 'lxc') {
130 $conf = PVE
::LXC
::Config-
>load_config($vmid, $node);
131 $name = $conf->{hostname
};
133 die "VMID $vmid is neither Qemu nor LXC guest\n";