Updated Branches: refs/heads/master 535903f92 -> 5c3013a69
CLOUDSTACK-3248: XenServer Host got removed successfully inspite of running VMs on the host In UI there is a restriction to first put a host in maintenance and only then deletion is allowed. But there is no such restriction in the deleteHost API. Added a validation in deleteHost API to prevent deletion if the host is not in maintenance. In case of a forced deletion the restriction doesn't apply. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5c3013a6 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5c3013a6 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5c3013a6 Branch: refs/heads/master Commit: 5c3013a694666adc0466f88ab138f211f33038df Parents: 535903f Author: Koushik Das <koushik....@citrix.com> Authored: Thu Jul 11 17:25:42 2013 +0530 Committer: Koushik Das <koushik....@citrix.com> Committed: Thu Jul 11 17:25:42 2013 +0530 ---------------------------------------------------------------------- server/src/com/cloud/resource/ResourceManagerImpl.java | 3 +++ 1 file changed, 3 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5c3013a6/server/src/com/cloud/resource/ResourceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 41c6ad7..b009e63 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -859,6 +859,9 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), host.getDataCenterId()); + if (!isForced && host.getResourceState() != ResourceState.Maintenance) { + throw new CloudRuntimeException("Host " + host.getUuid() + " cannot be deleted as it is not in maintenance mode. Either put the host into maintenance or perform a forced deletion."); + } /* * TODO: check current agent status and updateAgentStatus to removed. If * it was already removed, that means someone is deleting host