]> git.proxmox.com Git - pve-storage.git/commitdiff
Use keyfile create/remove from CephTools
authorAlwin Antreich <a.antreich@proxmox.com>
Wed, 4 Jul 2018 10:43:32 +0000 (12:43 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 4 Jul 2018 11:18:32 +0000 (13:18 +0200)
in the RBDPlugin, that is also shared by the CephFSPlugin

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
PVE/Storage/RBDPlugin.pm

index 59f794173107cb19386b6d289a1d04ae0de12918..be88ad7999f160d00c043765dc40c57674c72bb8 100644 (file)
@@ -280,21 +280,7 @@ sub on_add_hook {
 
     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";
-    }
-
+    PVE::Storage::CephTools::ceph_create_keyfile($scfg->{type}, $storeid);
 }
 
 sub on_delete_hook {
@@ -302,11 +288,7 @@ sub on_delete_hook {
 
     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";
-    }
-
+    PVE::Storage::CephTools::ceph_remove_keyfile($scfg->{type}, $storeid);
 }
 
 sub parse_volname {