From 1e53b5b3f672d0f42ee78a4f0ab5d06123f67a11 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 22 May 2013 07:47:15 +0200 Subject: [PATCH] allow to delete pools with non-existent VMs/Storage --- PVE/API2/Pool.pm | 16 ++++++++++++++-- debian/changelog.Debian | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Pool.pm b/PVE/API2/Pool.pm index bd602eca..68ed3378 100644 --- a/PVE/API2/Pool.pm +++ b/PVE/API2/Pool.pm @@ -311,6 +311,11 @@ __PACKAGE__->register_method ({ PVE::AccessControl::lock_user_config( sub { + my $vmlist = PVE::Cluster::get_vmlist() || {}; + my $idlist = $vmlist->{ids} || {}; + + my $storecfg = PVE::Storage::config(); + my $usercfg = cfs_read_file("user.cfg"); my $pool = $param->{poolid}; @@ -320,8 +325,15 @@ __PACKAGE__->register_method ({ die "pool '$pool' does not exist\n" if !$data; - die "pool '$pool' is not empty\n" - if scalar (keys %{$data->{vms}}) || scalar(keys %{$data->{storage}}); + foreach my $vmid (keys %{$data->{vms}}) { + next if !$idlist->{$vmid}; + die "pool '$pool' is not empty (contains VM $vmid)\n"; + } + + foreach my $storeid (keys %{$data->{storage}}) { + next if !PVE::Storage::storage_config ($storecfg, $storeid, 1); + die "pool '$pool' is not empty (contains storage '$storeid')\n"; + } delete ($usercfg->{pools}->{$pool}); diff --git a/debian/changelog.Debian b/debian/changelog.Debian index 7086278a..6a9c6135 100644 --- a/debian/changelog.Debian +++ b/debian/changelog.Debian @@ -3,6 +3,8 @@ pve-manager (3.0-19) unstable; urgency=low * updated Chinese translation * allow to upload files with spaces in filename (replace with '_') + + * allow to delete pools with non-existent VMs/Storage -- Proxmox Support Team Wed, 22 May 2013 06:04:49 +0200 -- 2.39.2