From 0b6b98d1891a1cc203bebc90851ae0784038dca3 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 12 Nov 2020 18:05:26 +0100 Subject: [PATCH] pbs: add/update: return enc. key, if newly set or auto-generated Signed-off-by: Thomas Lamprecht --- PVE/Storage/PBSPlugin.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/PVE/Storage/PBSPlugin.pm b/PVE/Storage/PBSPlugin.pm index f3bf016..41d5b89 100644 --- a/PVE/Storage/PBSPlugin.pm +++ b/PVE/Storage/PBSPlugin.pm @@ -371,6 +371,8 @@ my $autogen_encryption_key = sub { sub on_add_hook { my ($class, $storeid, $scfg, %param) = @_; + my $res = {}; + if (defined(my $password = $param{password})) { pbs_set_password($scfg, $storeid, $password); } else { @@ -379,19 +381,24 @@ sub on_add_hook { if (defined(my $encryption_key = $param{'encryption-key'})) { if ($encryption_key eq 'autogen') { - $autogen_encryption_key->($scfg, $storeid); + $res->{'encryption-key'} = $autogen_encryption_key->($scfg, $storeid); } else { pbs_set_encryption_key($scfg, $storeid, $encryption_key); + $res->{'encryption-key'} = $encryption_key; } $scfg->{'encryption-key'} = 1; } else { pbs_delete_encryption_key($scfg, $storeid); } + + return $res; } sub on_update_hook { my ($class, $storeid, $scfg, %param) = @_; + my $res = {}; + if (exists($param{password})) { if (defined($param{password})) { pbs_set_password($scfg, $storeid, $param{password}); @@ -403,15 +410,18 @@ sub on_update_hook { if (exists($param{'encryption-key'})) { if (defined(my $encryption_key = delete($param{'encryption-key'}))) { if ($encryption_key eq 'autogen') { - $autogen_encryption_key->($scfg, $storeid); + $res->{'encryption-key'} = $autogen_encryption_key->($scfg, $storeid); } else { pbs_set_encryption_key($scfg, $storeid, $encryption_key); + $res->{'encryption-key'} = $encryption_key; } $scfg->{'encryption-key'} = 1; } else { pbs_delete_encryption_key($scfg, $storeid); } } + + return $res; } sub on_delete_hook { -- 2.39.2