use of com.cloud.resource.Discoverer in project cloudstack by apache.
the class AgentManagerImpl method loadDirectlyConnectedHost.
protected boolean loadDirectlyConnectedHost(final HostVO host, final boolean forRebalance) {
boolean initialized = false;
ServerResource resource = null;
try {
// load the respective discoverer
final Discoverer discoverer = _resourceMgr.getMatchingDiscover(host.getHypervisorType());
if (discoverer == null) {
s_logger.info("Could not to find a Discoverer to load the resource: " + host.getId() + " for hypervisor type: " + host.getHypervisorType());
resource = loadResourcesWithoutHypervisor(host);
} else {
resource = discoverer.reloadResource(host);
}
if (resource == null) {
s_logger.warn("Unable to load the resource: " + host.getId());
return false;
}
initialized = true;
} finally {
if (!initialized) {
if (host != null) {
agentStatusTransitTo(host, Event.AgentDisconnected, _nodeId);
}
}
}
if (forRebalance) {
tapLoadingAgents(host.getId(), TapAgentsAction.Add);
final Host h = _resourceMgr.createHostAndAgent(host.getId(), resource, host.getDetails(), false, null, true);
tapLoadingAgents(host.getId(), TapAgentsAction.Del);
return h == null ? false : true;
} else {
_executor.execute(new SimulateStartTask(host.getId(), resource, host.getDetails()));
return true;
}
}
Aggregations