Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com>
---
 PVE/API2/Storage/Config.pm | 22 ----------------------
 PVE/Storage/RBDPlugin.pm   | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/PVE/API2/Storage/Config.pm b/PVE/API2/Storage/Config.pm
index 240c9e0..bb9d0a5 100755
--- a/PVE/API2/Storage/Config.pm
+++ b/PVE/API2/Storage/Config.pm
@@ -182,21 +182,6 @@ __PACKAGE__->register_method ({
                    PVE::Storage::activate_storage($cfg, $baseid);
 
                    PVE::Storage::LVMPlugin::lvm_create_volume_group($path, 
$opts->{vgname}, $opts->{shared});
-               } elsif ($type eq 'rbd' && !defined($opts->{monhost})) {
-                   my $ceph_admin_keyring = 
'/etc/pve/priv/ceph.client.admin.keyring';
-                   my $ceph_storage_keyring = 
"/etc/pve/priv/ceph/${storeid}.keyring";
-
-                   die "ceph authx keyring file for storage '$storeid' already 
exists!\n"
-                       if -e $ceph_storage_keyring;
-
-                   eval {
-                       mkdir '/etc/pve/priv/ceph';
-                       PVE::Tools::file_copy($ceph_admin_keyring, 
$ceph_storage_keyring);
-                   };
-                   if (my $err = $@) {
-                       unlink $ceph_storage_keyring;
-                       die "failed to copy ceph authx keyring for storage 
'$storeid': $err\n";
-                   }
                }
 
                eval {
@@ -297,13 +282,6 @@ __PACKAGE__->register_method ({
 
                $plugin->on_delete_hook($storeid, $scfg);
 
-               if ($scfg->{type} eq 'rbd' && !defined($scfg->{monhost})) {
-                   my $ceph_storage_keyring = 
"/etc/pve/priv/ceph/${storeid}.keyring";
-                   if (-f $ceph_storage_keyring) {
-                       unlink($ceph_storage_keyring) or warn "removing keyring 
of storage failed: $!\n";
-                   }
-               }
-
                delete $cfg->{ids}->{$storeid};
 
                PVE::Storage::write_config($cfg);
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 15cbe67..9ff784e 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -320,6 +320,40 @@ sub options {
 
 # Storage implementation
 
+sub on_add_hook {
+    my ($class, $storeid, $scfg, %param) = @_;
+
+    return if defined($scfg->{monhost}); # nothing to do if not pve managed 
ceph
+
+    my $ceph_admin_keyring = '/etc/pve/priv/ceph.client.admin.keyring';
+    my $ceph_storage_keyring = "/etc/pve/priv/ceph/${storeid}.keyring";
+
+    die "ceph authx keyring file for storage '$storeid' already exists!\n"
+       if -e $ceph_storage_keyring;
+
+    eval {
+       mkdir '/etc/pve/priv/ceph';
+       PVE::Tools::file_copy($ceph_admin_keyring, $ceph_storage_keyring);
+    };
+    if (my $err = $@) {
+       unlink $ceph_storage_keyring;
+       die "failed to copy ceph authx keyring for storage '$storeid': $err\n";
+    }
+
+}
+
+sub on_delete_hook {
+    my ($class, $storeid, $scfg) = @_;
+
+    return if defined($scfg->{monhost}); # nothing to do if not pve managed 
ceph
+
+    my $ceph_storage_keyring = "/etc/pve/priv/ceph/${storeid}.keyring";
+    if (-f $ceph_storage_keyring) {
+       unlink($ceph_storage_keyring) or warn "removing keyring of storage 
failed: $!\n";
+    }
+
+}
+
 sub parse_volname {
     my ($class, $volname) = @_;
 
-- 
2.17.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to