Search in sources :

Example 1 with StartupRoutingCommand

use of com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand in project cosmic by MissionCriticalCloud.

the class AgentManagerImplTest method setUp.

@Before
public void setUp() throws Exception {
    host = new HostVO("some-Uuid");
    host.setDataCenterId(1L);
    cmds = new StartupCommand[] { new StartupRoutingCommand() };
    attache = new ConnectedAgentAttache(null, 1L, "kvm-attache", null, false);
    hostDao = Mockito.mock(HostDao.class);
    storagePoolMonitor = Mockito.mock(Listener.class);
    mgr._hostDao = hostDao;
    mgr._hostMonitors = new ArrayList<>();
    mgr._hostMonitors.add(new Pair<>(0, storagePoolMonitor));
}
Also used : Listener(com.cloud.agent.Listener) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) HostVO(com.cloud.host.HostVO) HostDao(com.cloud.host.dao.HostDao) Before(org.junit.Before)

Example 2 with StartupRoutingCommand

use of com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand in project cosmic by MissionCriticalCloud.

the class KvmDummyResourceBase method initialize.

@Override
public StartupCommand[] initialize() {
    final StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, null, HypervisorType.KVM, new HashMap<>());
    cmd.setDataCenter(this._zoneId);
    cmd.setPod(this._podId);
    cmd.setCluster(this._clusterId);
    cmd.setGuid(this._guid);
    cmd.setName(this._agentIp);
    cmd.setPrivateIpAddress(this._agentIp);
    cmd.setStorageIpAddress(this._agentIp);
    cmd.setVersion(KvmDummyResourceBase.class.getPackage().getImplementationVersion());
    return new StartupCommand[] { cmd };
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)

Example 3 with StartupRoutingCommand

use of com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand in project cosmic by MissionCriticalCloud.

the class LibvirtServerDiscoverer method createHostVOForConnectedAgent.

@Override
public HostVO createHostVOForConnectedAgent(final HostVO host, final StartupCommand[] cmd) {
    final StartupCommand firstCmd = cmd[0];
    if (!(firstCmd instanceof StartupRoutingCommand)) {
        return null;
    }
    final StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
    if (ssCmd.getHypervisorType() != getHypervisorType()) {
        return null;
    }
    /* KVM requires host are the same in cluster */
    final ClusterVO clusterVO = this._clusterDao.findById(host.getClusterId());
    if (clusterVO == null) {
        s_logger.debug("cannot find cluster: " + host.getClusterId());
        throw new IllegalArgumentException("cannot add host, due to can't find cluster: " + host.getClusterId());
    }
    this._hostDao.loadDetails(host);
    return this._resourceMgr.fillRoutingHostVO(host, ssCmd, getHypervisorType(), host.getDetails(), null);
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) ClusterVO(com.cloud.dc.ClusterVO) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)

Example 4 with StartupRoutingCommand

use of com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand in project cosmic by MissionCriticalCloud.

the class XcpServerDiscoverer method processConnect.

@Override
public void processConnect(final com.cloud.legacymodel.dc.Host agent, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException {
    for (final StartupCommand startupCommand : startupCommands) {
        if (!(startupCommand instanceof StartupRoutingCommand)) {
            return;
        }
        final long agentId = agent.getId();
        final StartupRoutingCommand startup = (StartupRoutingCommand) startupCommand;
        if (startup.getHypervisorType() != HypervisorType.XenServer) {
            s_logger.debug("Not XenServer so moving on.");
            return;
        }
        final HostVO host = this._hostDao.findById(agentId);
        final ClusterVO cluster = this._clusterDao.findById(host.getClusterId());
        if (cluster.getGuid() == null) {
            cluster.setGuid(startup.getPool());
            this._clusterDao.update(cluster.getId(), cluster);
        } else if (!cluster.getGuid().equals(startup.getPool())) {
            final String msg = "pool uuid for cluster " + cluster.getId() + " changed from " + cluster.getGuid() + " to " + startup.getPool();
            s_logger.warn(msg);
            throw new CloudRuntimeException(msg);
        }
        final Map<String, String> details = startup.getHostDetails();
        final String prodBrand = details.get("product_brand").trim();
        final String prodVersion = details.get("product_version").trim();
        final String hotfix = details.get(XenserverConfigs.XS620HotFix);
        final String prodVersionTextShort = details.get("product_version_text_short");
        final String resource = createServerResource(prodBrand, prodVersion, prodVersionTextShort, hotfix).getClass().getName();
        if (!resource.equals(host.getResource())) {
            final String msg = "host " + host.getPrivateIpAddress() + " changed from " + host.getResource() + " to " + resource;
            s_logger.debug(msg);
            host.setResource(resource);
            host.setSetup(false);
            this._hostDao.update(agentId, host);
            throw new HypervisorVersionChangedException(msg);
        }
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Setting up host " + agentId);
        }
        final HostEnvironment env = new HostEnvironment();
        final SetupCommand setup = new SetupCommand(env);
        if (this._setupMultipath) {
            setup.setMultipathOn();
        }
        if (!host.isSetup()) {
            setup.setNeedSetup(true);
        }
        try {
            final Answer answer = this._agentMgr.send(agentId, setup);
            if (answer != null && answer.getResult() && answer instanceof SetupAnswer) {
                host.setSetup(true);
                host.setLastPinged((System.currentTimeMillis() >> 10) - 5 * 60);
                host.setHypervisorVersion(prodVersion);
                this._hostDao.update(host.getId(), host);
                if (((SetupAnswer) answer).needReconnect()) {
                    throw new ConnectionException(false, "Reinitialize agent after setup.");
                }
                return;
            } else {
                s_logger.warn("Unable to setup agent " + agentId + " due to " + ((answer != null) ? answer.getDetails() : "return null"));
            }
        } catch (final AgentUnavailableException e) {
            s_logger.warn("Unable to setup agent " + agentId + " because it became unavailable.", e);
        } catch (final OperationTimedoutException e) {
            s_logger.warn("Unable to setup agent " + agentId + " because it timed out", e);
        }
        throw new ConnectionException(true, "Reinitialize agent after setup.");
    }
}
Also used : OperationTimedoutException(com.cloud.legacymodel.exceptions.OperationTimedoutException) ClusterVO(com.cloud.dc.ClusterVO) HostEnvironment(com.cloud.legacymodel.dc.HostEnvironment) SetupCommand(com.cloud.legacymodel.communication.command.SetupCommand) HostVO(com.cloud.host.HostVO) SetupAnswer(com.cloud.legacymodel.communication.answer.SetupAnswer) StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) HypervisorVersionChangedException(com.cloud.legacymodel.exceptions.HypervisorVersionChangedException) AgentControlAnswer(com.cloud.legacymodel.communication.answer.AgentControlAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) SetupAnswer(com.cloud.legacymodel.communication.answer.SetupAnswer) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) AgentUnavailableException(com.cloud.legacymodel.exceptions.AgentUnavailableException) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) ConnectionException(com.cloud.legacymodel.exceptions.ConnectionException)

Example 5 with StartupRoutingCommand

use of com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand in project cosmic by MissionCriticalCloud.

the class CitrixResourceBase method initialize.

@Override
public StartupCommand[] initialize() throws IllegalArgumentException {
    final Connection conn = getConnection();
    if (!getHostInfo(conn)) {
        s_logger.warn("Unable to get host information for " + this._host.getIp());
        return null;
    }
    final StartupRoutingCommand cmd = new StartupRoutingCommand();
    fillHostInfo(conn, cmd);
    cmd.setHypervisorType(HypervisorType.XenServer);
    cmd.setCluster(this._cluster);
    cmd.setPoolSync(false);
    try {
        final Pool pool = Pool.getByUuid(conn, this._host.getPool());
        final Pool.Record poolr = pool.getRecord(conn);
        poolr.master.getRecord(conn);
    } catch (final XmlRpcException | XenAPIException e) {
        s_logger.warn("Check for master failed, failing the FULL Cluster sync command");
    }
    final StartupStorageCommand sscmd = initializeLocalSR(conn);
    if (sscmd != null) {
        return new StartupCommand[] { cmd, sscmd };
    }
    return new StartupCommand[] { cmd };
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) Connection(com.xensource.xenapi.Connection) URLConnection(java.net.URLConnection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) Pool(com.xensource.xenapi.Pool) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Aggregations

StartupRoutingCommand (com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)16 StartupCommand (com.cloud.legacymodel.communication.command.startup.StartupCommand)14 HostVO (com.cloud.host.HostVO)4 AgentUnavailableException (com.cloud.legacymodel.exceptions.AgentUnavailableException)4 ClusterVO (com.cloud.dc.ClusterVO)3 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)3 ConnectionException (com.cloud.legacymodel.exceptions.ConnectionException)3 Commands (com.cloud.agent.manager.Commands)2 HostPodVO (com.cloud.dc.HostPodVO)2 StartupSecondaryStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand)2 StartupStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupStorageCommand)2 Before (org.junit.Before)2 Listener (com.cloud.agent.Listener)1 Response (com.cloud.common.transport.Response)1 Zone (com.cloud.db.model.Zone)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)1 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)1 HostDao (com.cloud.host.dao.HostDao)1 AgentControlAnswer (com.cloud.legacymodel.communication.answer.AgentControlAnswer)1