api: content: pass encrypted status for PBS backups
Prefer the fingerprint, fallback to checking the files crypt-mode. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -92,6 +92,12 @@ __PACKAGE__->register_method ({
|
|||||||
type => 'string',
|
type => 'string',
|
||||||
optional => 1,
|
optional => 1,
|
||||||
},
|
},
|
||||||
|
encrypted => {
|
||||||
|
description => "If whole backup is encrypted, value is the fingerprint or '1' "
|
||||||
|
." if encrypted. Only useful for the Proxmox Backup Server storage type.",
|
||||||
|
type => 'string',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
verification => {
|
verification => {
|
||||||
description => "Last backup verification result, only useful for PBS storages.",
|
description => "Last backup verification result, only useful for PBS storages.",
|
||||||
type => 'object',
|
type => 'object',
|
||||||
|
|||||||
@ -528,6 +528,24 @@ sub list_images {
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my sub snapshot_files_encrypted {
|
||||||
|
my ($files) = @_;
|
||||||
|
return 0 if !$files;
|
||||||
|
|
||||||
|
my $any;
|
||||||
|
my $all = 1;
|
||||||
|
for my $file (@$files) {
|
||||||
|
my $fn = $file->{filename};
|
||||||
|
next if $fn eq 'client.log.blob' || $fn eq 'index.json.blob';
|
||||||
|
|
||||||
|
my $crypt = $file->{'crypt-mode'};
|
||||||
|
|
||||||
|
$all = 0 if !$crypt || $crypt ne 'encrypt';
|
||||||
|
$any ||= $crypt eq 'encrypt';
|
||||||
|
}
|
||||||
|
return $any && $all;
|
||||||
|
}
|
||||||
|
|
||||||
sub list_volumes {
|
sub list_volumes {
|
||||||
my ($class, $storeid, $scfg, $vmid, $content_types) = @_;
|
my ($class, $storeid, $scfg, $vmid, $content_types) = @_;
|
||||||
|
|
||||||
@ -560,6 +578,11 @@ sub list_volumes {
|
|||||||
|
|
||||||
$info->{verification} = $item->{verification} if defined($item->{verification});
|
$info->{verification} = $item->{verification} if defined($item->{verification});
|
||||||
$info->{notes} = $item->{comment} if defined($item->{comment});
|
$info->{notes} = $item->{comment} if defined($item->{comment});
|
||||||
|
if (defined($item->{fingerprint})) {
|
||||||
|
$info->{encrypted} = $item->{fingerprint};
|
||||||
|
} elsif (snapshot_files_encrypted($item->{files})) {
|
||||||
|
$info->{encrypted} = '1';
|
||||||
|
}
|
||||||
|
|
||||||
push @$res, $info;
|
push @$res, $info;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user