[pve-devel] [PATCH manager 09/20] ceph: add remove_storage helper
    Fabian Grünbichler 
    f.gruenbichler at proxmox.com
       
    Fri Aug 25 10:48:11 CEST 2017
    
    
  
$storeid must already be validated via the API/Config
parser
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 PVE/API2/Ceph.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 7aee4b66..a49fa9c7 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -815,6 +815,18 @@ my $update_storage = sub {
     PVE::API2::Storage::Config->update($params);
 };
 
+my $remove_storage = sub {
+    my ($storeid) = @_;
+
+    PVE::API2::Storage::Config->delete({storage => $storeid});
+
+    my $pve_ceph_keydir = PVE::CephTools::get_config('pve_ceph_keydir');
+    my $keyring = "$pve_ceph_keydir/$storeid.keyring";
+    if (-f $keyring) {
+	unlink($keyring) or warn "removing keyring of storage failed: $!\n";
+    }
+};
+
 __PACKAGE__->register_method ({
     name => 'listmon',
     path => 'mon',
-- 
2.11.0
    
    
More information about the pve-devel
mailing list