X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PVE%2FStorage%2FRBDPlugin.pm;h=4bd43d5c0c115050ba027475a040f551065d66a5;hb=d5fc368503fc04fdbc411d0a6dde13fce75ece18;hp=42641e28911dc745c59f68de109c4bd992ed0114;hpb=c27fe64810682f2a124dc38a975f3e34782db1b1;p=pve-storage.git diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm index 42641e2..4bd43d5 100644 --- a/PVE/Storage/RBDPlugin.pm +++ b/PVE/Storage/RBDPlugin.pm @@ -305,6 +305,10 @@ sub properties { description => "Always access rbd through krbd kernel module.", type => 'boolean', }, + keyring => { + description => "Client keyring contents (for external clusters).", + type => 'string', + }, }; } @@ -318,6 +322,7 @@ sub options { username => { optional => 1 }, content => { optional => 1 }, krbd => { optional => 1 }, + keyring => { optional => 1 }, bwlimit => { optional => 1 }, }; } @@ -327,20 +332,29 @@ sub options { sub on_add_hook { my ($class, $storeid, $scfg, %param) = @_; - return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph + my $secret = $param{keyring} if defined $param{keyring} // undef; + PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $secret); - PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid); + return; +} + +sub on_update_hook { + my ($class, $storeid, $scfg, %param) = @_; + + if (exists($param{keyring})) { + if (defined($param{keyring})) { + PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $param{keyring}); + } else { + PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid); + } + } return; } sub on_delete_hook { my ($class, $storeid, $scfg) = @_; - - return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph - PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid); - return; } @@ -503,7 +517,7 @@ sub alloc_image { $name = $class->find_free_diskname($storeid, $scfg, $vmid) if !$name; my $cmd = $rbd_cmd->($scfg, $storeid, 'create', '--image-format' , 2, '--size', int(($size+1023)/1024), $name); - run_rbd_command($cmd, errmsg => "rbd create $name' error"); + run_rbd_command($cmd, errmsg => "rbd create '$name' error"); return $name; }