+ return;
+ };
+ cfs_lock_file('vzdump.cron', undef, sub {
+ cfs_lock_file('jobs.cfg', undef, $update_job);
+ die "$@" if ($@);
+ });
+ die "$@" if ($@);
+ }});
+
+__PACKAGE__->register_method({
+ name => 'get_volume_backup_included',
+ path => '{id}/included_volumes',
+ method => 'GET',
+ protected => 1,
+ description => "Returns included guests and the backup status of their disks. Optimized to be used in ExtJS tree views.",
+ permissions => {
+ check => ['perm', '/', ['Sys.Audit']],
+ },
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ id => $vzdump_job_id_prop
+ },
+ },
+ returns => {
+ type => 'object',
+ description => 'Root node of the tree object. Children represent guests, grandchildren represent volumes of that guest.',
+ properties => {
+ children => {
+ type => 'array',
+ items => {
+ type => 'object',
+ properties => {
+ id => {
+ type => 'integer',
+ description => 'VMID of the guest.',
+ },
+ name => {
+ type => 'string',
+ description => 'Name of the guest',
+ optional => 1,
+ },
+ type => {
+ type => 'string',
+ description => 'Type of the guest, VM, CT or unknown for removed but not purged guests.',
+ enum => ['qemu', 'lxc', 'unknown'],
+ },
+ children => {
+ type => 'array',
+ optional => 1,
+ description => 'The volumes of the guest with the information if they will be included in backups.',
+ items => {
+ type => 'object',
+ properties => {
+ id => {
+ type => 'string',
+ description => 'Configuration key of the volume.',
+ },
+ name => {
+ type => 'string',
+ description => 'Name of the volume.',
+ },
+ included => {
+ type => 'boolean',
+ description => 'Whether the volume is included in the backup or not.',
+ },
+ reason => {
+ type => 'string',
+ description => 'The reason why the volume is included (or excluded).',
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+
+ my $user = $rpcenv->get_user();
+
+ my $vzconf = cfs_read_file('vzdump.cron');
+ my $all_jobs = $vzconf->{jobs} || [];
+ my $job;
+ my $rrd = PVE::Cluster::rrd_dump();
+
+ for my $j (@$all_jobs) {
+ if ($j->{id} eq $param->{id}) {
+ $job = $j;
+ last;
+ }
+ }
+ if (!$job) {
+ my $jobs_data = cfs_read_file('jobs.cfg');
+ my $j = $jobs_data->{ids}->{$param->{id}};
+ if ($j && $j->{type} eq 'vzdump') {
+ $job = $j;