Signed-off-by: Fabian Grünbichler <f.gruenbich...@proxmox.com>
---
 PVE/API2/Ceph.pm | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 470ff216..d7877d8b 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1998,7 +1998,13 @@ __PACKAGE__->register_method ({
                type => 'boolean',
                optional => 1,
                default => 0,
-           }
+           },
+           remove_storages => {
+               description => "Remove all pveceph-managed storages configured 
for this pool",
+               type => 'boolean',
+               optional => 1,
+               default => 0,
+           },
        },
     },
     returns => { type => 'null' },
@@ -2007,6 +2013,15 @@ __PACKAGE__->register_method ({
 
        PVE::CephTools::check_ceph_inited();
 
+       my $rpcenv = PVE::RPCEnvironment::get();
+       my $user = $rpcenv->get_user();
+       $rpcenv->check($user, '/storage', ['Datastore.Allocate'])
+           if $param->{remove_storages};
+
+       my $storages;
+       $storages = $get_storages->($param->{name})
+           if $param->{remove_storages};
+
        # if not forced, destroy ceph pool only when no
        # vm disks are on it anymore
        if (!$param->{force}) {
@@ -2033,6 +2048,13 @@ __PACKAGE__->register_method ({
            format => 'plain',
         });
 
+       if ($param->{remove_storages}) {
+           foreach my $storeid (keys %$storages) {
+               eval { $remove_storage->($storeid); };
+               warn "failed removing storage '$storeid': $@\n" if $@;
+           }
+       }
+
        return undef;
     }});
 
-- 
2.11.0


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

Reply via email to