Skip to content

Commit c076ae8

Browse files
author
Koushik Das
committed
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.
1 parent 088c1e2 commit c076ae8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎server/src/com/cloud/resource/ResourceManagerImpl.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,9 @@ protected boolean doDeleteHost(long hostId, boolean isForced, boolean isForceDel
857857
}
858858
_accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), host.getDataCenterId());
859859

860+
if (!isForced && host.getResourceState() != ResourceState.Maintenance) {
861+
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.");
862+
}
860863
/*
861864
* TODO: check current agent status and updateAgentStatus to removed. If
862865
* it was already removed, that means someone is deleting host

0 commit comments

Comments
 (0)