Search in sources :

Example 1 with StartupSecondaryStorageCommand

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

the class NfsSecondaryStorageResource method initialize.

@Override
public StartupCommand[] initialize() {
    final StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand();
    fillNetworkInformation(cmd);
    cmd.setVersion(NfsSecondaryStorageResource.class.getPackage().getImplementationVersion());
    if (this._publicIp != null) {
        cmd.setPublicIpAddress(this._publicIp);
    }
    if (this._inSystemVM) {
        final Script command = new Script("/bin/bash", s_logger);
        command.add("-c");
        command.add("ln -sf " + this._parent + " /var/www/html/copy");
        final String result = command.execute();
        if (result != null) {
            s_logger.warn("Error in linking  err=" + result);
            return null;
        }
    }
    return new StartupCommand[] { cmd };
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) Script(com.cloud.utils.script.Script) StartupSecondaryStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand)

Example 2 with StartupSecondaryStorageCommand

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

the class AgentManagerImpl method connectAgent.

protected void connectAgent(final Link link, final Command[] cmds, final Request request) {
    // send startupanswer to agent in the very beginning, so agent can move on without waiting for the answer for an undetermined time, if we put this logic into another
    // thread pool.
    final StartupAnswer[] answers = new StartupAnswer[cmds.length];
    Command cmd;
    for (int i = 0; i < cmds.length; i++) {
        cmd = cmds[i];
        if (cmd instanceof StartupRoutingCommand || cmd instanceof StartupProxyCommand || cmd instanceof StartupSecondaryStorageCommand || cmd instanceof StartupStorageCommand) {
            answers[i] = new StartupAnswer((StartupCommand) cmds[i], 0, getPingInterval());
            break;
        }
    }
    Response response = null;
    response = new Response(request, answers[0], this._nodeId, -1);
    try {
        link.send(response.toBytes());
    } catch (final ClosedChannelException e) {
        s_logger.debug("Failed to send startupanswer: " + e.toString());
    }
    this._connectExecutor.execute(new HandleAgentConnectTask(link, cmds, request));
}
Also used : StartupAnswer(com.cloud.legacymodel.communication.answer.StartupAnswer) StartupProxyCommand(com.cloud.legacymodel.communication.command.startup.StartupProxyCommand) StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) Response(com.cloud.common.transport.Response) ClosedChannelException(java.nio.channels.ClosedChannelException) ReadyCommand(com.cloud.legacymodel.communication.command.ReadyCommand) PingCommand(com.cloud.legacymodel.communication.command.PingCommand) StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) Command(com.cloud.legacymodel.communication.command.Command) AgentControlCommand(com.cloud.legacymodel.communication.command.agentcontrol.AgentControlCommand) StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) StartupSecondaryStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) CheckHealthCommand(com.cloud.legacymodel.communication.command.CheckHealthCommand) PingRoutingCommand(com.cloud.legacymodel.communication.command.PingRoutingCommand) ShutdownCommand(com.cloud.legacymodel.communication.command.ShutdownCommand) StartupProxyCommand(com.cloud.legacymodel.communication.command.startup.StartupProxyCommand) StartupSecondaryStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand) StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)

Example 3 with StartupSecondaryStorageCommand

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

the class SecondaryStorageManagerImpl method createHostVOForConnectedAgent.

@Override
public HostVO createHostVOForConnectedAgent(final HostVO host, final StartupCommand[] cmd) {
    /* Called when Secondary Storage VM connected */
    final StartupCommand firstCmd = cmd[0];
    if (!(firstCmd instanceof StartupSecondaryStorageCommand)) {
        return null;
    }
    host.setType(HostType.SecondaryStorageVM);
    return host;
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StartupSecondaryStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand)

Example 4 with StartupSecondaryStorageCommand

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

the class DownloadListener method processConnect.

@Override
public void processConnect(final Host agent, final StartupCommand[] startupCommands, final boolean forRebalance) {
    for (final StartupCommand startupCommand : startupCommands) {
        if (startupCommand instanceof StartupRoutingCommand) {
            final List<HypervisorType> hypers = this._resourceMgr.listAvailHypervisorInZone(agent.getId(), agent.getDataCenterId());
            final HypervisorType hostHyper = agent.getHypervisorType();
            if (hypers.contains(hostHyper)) {
                return;
            }
            this._imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
            // update template_zone_ref for cross-zone templates
            this._imageSrv.associateCrosszoneTemplatesToZone(agent.getDataCenterId());
        } else if (startupCommand instanceof StartupSecondaryStorageCommand) {
            try {
                final List<DataStore> imageStores = this._storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
                for (final DataStore store : imageStores) {
                    this._volumeSrv.handleVolumeSync(store);
                    this._imageSrv.handleTemplateSync(store);
                }
            } catch (final Exception e) {
                s_logger.error("Caught exception while doing template/volume sync ", e);
            }
        }
    }
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) HypervisorType(com.cloud.model.enumeration.HypervisorType) ZoneScope(com.cloud.engine.subsystem.api.storage.ZoneScope) StartupSecondaryStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) List(java.util.List) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException)

Aggregations

StartupCommand (com.cloud.legacymodel.communication.command.startup.StartupCommand)4 StartupSecondaryStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand)4 StartupRoutingCommand (com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)2 Response (com.cloud.common.transport.Response)1 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)1 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)1 StartupAnswer (com.cloud.legacymodel.communication.answer.StartupAnswer)1 CheckHealthCommand (com.cloud.legacymodel.communication.command.CheckHealthCommand)1 Command (com.cloud.legacymodel.communication.command.Command)1 PingCommand (com.cloud.legacymodel.communication.command.PingCommand)1 PingRoutingCommand (com.cloud.legacymodel.communication.command.PingRoutingCommand)1 ReadyCommand (com.cloud.legacymodel.communication.command.ReadyCommand)1 ShutdownCommand (com.cloud.legacymodel.communication.command.ShutdownCommand)1 AgentControlCommand (com.cloud.legacymodel.communication.command.agentcontrol.AgentControlCommand)1 StartupProxyCommand (com.cloud.legacymodel.communication.command.startup.StartupProxyCommand)1 StartupStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupStorageCommand)1 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)1 HypervisorType (com.cloud.model.enumeration.HypervisorType)1 Script (com.cloud.utils.script.Script)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1