Search in sources :

Example 1 with Discoverer

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;
    }
}
Also used : ServerResource(com.cloud.resource.ServerResource) Discoverer(com.cloud.resource.Discoverer) Host(com.cloud.host.Host)

Aggregations

Host (com.cloud.host.Host)1 Discoverer (com.cloud.resource.Discoverer)1 ServerResource (com.cloud.resource.ServerResource)1