From 8fafc892d39f132bc25292ba6f6f4909c64aa8c1 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Tue, 26 Oct 2010 14:55:27 -0700 Subject: [PATCH] bug 6730: if a volume was never attached to a VM, then the poolId will be null and this will be flagged as not on shared storage. Since the code was deleting detached volumes only on shared storage, the never-attached volume was in an undeletable state. Instead, allow deletion of any detached volume, regardless of storage pool until some technical reason limits this from happening. Also, the UI was not allowing volumes to be deleted due to a bug in looking at the vmname property of the volume. The 'if' conditional always returned true that the volume was attached to a VM to due a boolean logic error. status 6730: resolved fixed --- server/src/com/cloud/storage/StorageManagerImpl.java | 9 ++++++--- ui/scripts/cloud.core.storage.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 842e0330602..047ca9fb469 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -2487,9 +2487,12 @@ public class StorageManagerImpl implements StorageManager { // Check that the volume is stored on shared storage - if (!volumeOnSharedStoragePool(volume)) { - throw new InvalidParameterValueException("Please specify a volume that has been created on a shared storage pool."); - } + // NOTE: We used to ensure the volume is on shared storage before deleting. However, this seems like an unnecessary check since all we allow + // is deleting a detached volume. Is there a technical reason why the volume has to be on shared storage? If so, uncomment this...otherwise, + // just delete the detached volume regardless of storage pool. +// if (!volumeOnSharedStoragePool(volume)) { +// throw new InvalidParameterValueException("Please specify a volume that has been created on a shared storage pool."); +// } // Check that the volume is not currently attached to any VM if (volume.getInstanceId() != null) { diff --git a/ui/scripts/cloud.core.storage.js b/ui/scripts/cloud.core.storage.js index 580b03046d8..10ca6570729 100644 --- a/ui/scripts/cloud.core.storage.js +++ b/ui/scripts/cloud.core.storage.js @@ -959,7 +959,7 @@ function showStorageTab(domainId, targetTab) { switch (linkAction) { case "volume_action_delete" : //check if this volume is attached to a virtual machine. If yes, can't be deleted. - if(vmname != null && (vmname != "" || vmname != "none")) { + if(vmname != null && vmname != "" && vmname != "none") { $("#dialog_alert").html("

This volume is attached to virtual machine " + vmname + " and can't be deleted.

") $("#dialog_alert").dialog("open"); return;