mirror of https://github.com/apache/cloudstack.git
Bug 12404 - Failure in Removing host
status 12404: resolved fixed
This commit is contained in:
parent
30ed5fc381
commit
494517cd6a
|
|
@ -236,8 +236,12 @@ public class OvmDiscoverer extends DiscovererBase implements Discoverer, Resourc
|
|||
|
||||
@Override
|
||||
public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.Ovm) {
|
||||
return null;
|
||||
}
|
||||
|
||||
_resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
|
||||
return new DeleteHostAnswer(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import com.cloud.resource.ResourceManager;
|
|||
import com.cloud.resource.ResourceStateAdapter;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.resource.UnableDeleteHostException;
|
||||
import com.cloud.resource.ResourceStateAdapter.DeleteHostAnswer;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
|
|
@ -279,8 +280,12 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||
|
||||
@Override
|
||||
public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.VMware) {
|
||||
return null;
|
||||
}
|
||||
|
||||
_resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
|
||||
return new DeleteHostAnswer(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import com.cloud.agent.api.AgentControlAnswer;
|
|||
import com.cloud.agent.api.AgentControlCommand;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.PoolEjectCommand;
|
||||
import com.cloud.agent.api.SetupAnswer;
|
||||
import com.cloud.agent.api.SetupCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
|
|
@ -77,6 +78,7 @@ import com.cloud.resource.ResourceManager;
|
|||
import com.cloud.resource.ResourceStateAdapter;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.resource.UnableDeleteHostException;
|
||||
import com.cloud.resource.ResourceStateAdapter.DeleteHostAnswer;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
|
|
@ -658,8 +660,37 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
|
||||
@Override
|
||||
public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.XenServer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
_resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
|
||||
if (host.getClusterId() != null) {
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(com.cloud.host.Host.Type.Routing, host.getClusterId(), host.getPodId(), host.getDataCenterId());
|
||||
hosts.add(host);
|
||||
boolean success = true;
|
||||
for (HostVO thost : hosts) {
|
||||
long thostId = thost.getId();
|
||||
PoolEjectCommand eject = new PoolEjectCommand(host.getGuid());
|
||||
Answer answer = _agentMgr.easySend(thostId, eject);
|
||||
if (answer != null && answer.getResult()) {
|
||||
s_logger.debug("Eject Host: " + host.getId() + " from " + thostId + " Succeed");
|
||||
success = true;
|
||||
break;
|
||||
} else {
|
||||
success = false;
|
||||
s_logger.warn("Eject Host: " + host.getId() + " from " + thostId + " failed due to " + (answer != null ? answer.getDetails() : "no answer"));
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
String msg = "Unable to eject host " + host.getGuid() + " due to there is no host up in this cluster, please execute xe pool-eject host-uuid="
|
||||
+ host.getGuid() + "in this host " + host.getPrivateIpAddress();
|
||||
s_logger.warn(msg);
|
||||
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Unable to eject host " + host.getGuid(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
return new DeleteHostAnswer(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -706,10 +706,9 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
List<StoragePoolHostVO> pools = _storagePoolHostDao.listByHostIdIncludingRemoved(hostId);
|
||||
|
||||
ResourceStateAdapter.DeleteHostAnswer answer = (ResourceStateAdapter.DeleteHostAnswer) dispatchToStateAdapters(ResourceStateAdapter.Event.DELETE_HOST, false, host, new Boolean(isForced), new Boolean(isForceDeleteStorage));
|
||||
|
||||
|
||||
if (answer == null) {
|
||||
s_logger.warn("Unable to delete host: " + hostId);
|
||||
return false;
|
||||
throw new CloudRuntimeException("No resource adapter respond to DELETE_HOST event for " + host.getName() + " id = " + hostId + ", hypervisorType is " + host.getHypervisorType() + ", host type is " + host.getType());
|
||||
}
|
||||
|
||||
if (answer.getIsException()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue