mirror of https://github.com/apache/cloudstack.git
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.
This commit is contained in:
parent
088c1e2a46
commit
c076ae875a
|
|
@ -857,6 +857,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
|
||||
|
|
|
|||
Loading…
Reference in New Issue