Search in sources :

Example 16 with StartupCommand

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

the class Agent method sendStartup.

public void sendStartup(final Link link) {
    final StartupCommand[] startup = this.resource.initialize();
    if (startup != null) {
        final Command[] commands = new Command[startup.length];
        for (int i = 0; i < startup.length; i++) {
            setupStartupCommand(startup[i]);
            commands[i] = startup[i];
        }
        final Request request = new Request(this._id != null ? this._id : -1, -1, commands, false, false);
        request.setSequence(getNextSequence());
        if (logger.isDebugEnabled()) {
            logger.debug("Sending Startup: " + request.toString());
        }
        lockStartupTask(link);
        try {
            link.send(request.toBytes());
        } catch (final ClosedChannelException e) {
            logger.warn("Unable to send request: " + request.toString());
        }
    }
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) ClosedChannelException(java.nio.channels.ClosedChannelException) MaintainCommand(com.cloud.legacymodel.communication.command.MaintainCommand) ReadyCommand(com.cloud.legacymodel.communication.command.ReadyCommand) CronCommand(com.cloud.legacymodel.communication.command.CronCommand) 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) ShutdownCommand(com.cloud.legacymodel.communication.command.ShutdownCommand) Request(com.cloud.common.transport.Request)

Example 17 with StartupCommand

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

the class LibvirtComputingResource method initialize.

@Override
public StartupCommand[] initialize() {
    final List<StartupCommand> startupCommandList = new ArrayList<>();
    final List<Object> info = getHostInfo();
    this.totalMemory = (Long) info.get(1);
    final StartupRoutingCommand cmd = new StartupRoutingCommand((Integer) info.get(0), (Long) info.get(1), (Long) info.get(3), (String) info.get(2), getHypervisorType(), RouterPrivateIpStrategy.HostLocal);
    cmd.setCpuSockets((Integer) info.get(4));
    fillNetworkInformation(cmd);
    this.privateIp = cmd.getPrivateIpAddress();
    cmd.getHostDetails().putAll(getVersionStrings());
    cmd.setPool(getPool());
    cmd.setCluster(getCluster());
    cmd.setGatewayIpAddress(this.localGateway);
    cmd.setIqn(getIqn());
    cmd.setVersion(LibvirtComputingResource.class.getPackage().getImplementationVersion());
    startupCommandList.add(cmd);
    startupCommandList.addAll(initializeLocalstorage());
    return startupCommandList.toArray(new StartupCommand[startupCommandList.size()]);
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) ArrayList(java.util.ArrayList) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)

Example 18 with StartupCommand

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

the class NiciraNvpResource method initialize.

@Override
public StartupCommand[] initialize() {
    final StartupNiciraNvpCommand sc = new StartupNiciraNvpCommand();
    sc.setGuid(this.guid);
    sc.setName(this.name);
    sc.setDataCenter(this.zoneId);
    sc.setPod("");
    sc.setPrivateIpAddress("");
    sc.setStorageIpAddress("");
    sc.setVersion(NiciraNvpResource.class.getPackage().getImplementationVersion());
    return new StartupCommand[] { sc };
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StartupNiciraNvpCommand(com.cloud.legacymodel.communication.command.startup.StartupNiciraNvpCommand)

Example 19 with StartupCommand

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

the class XcpServerDiscoverer method createHostVOForDirectConnectAgent.

@Override
public HostVO createHostVOForDirectConnectAgent(final HostVO host, final StartupCommand[] startup, final ServerResource resource, final Map<String, String> details, final List<String> hostTags) {
    final StartupCommand firstCmd = startup[0];
    if (!(firstCmd instanceof StartupRoutingCommand)) {
        return null;
    }
    final StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
    if (ssCmd.getHypervisorType() != HypervisorType.XenServer) {
        return null;
    }
    final HostPodVO pod = this._podDao.findById(host.getPodId());
    final Zone zone = this.zoneRepository.findById(host.getDataCenterId()).orElse(null);
    s_logger.info("Host: " + host.getName() + " connected with hypervisor type: " + HypervisorType.XenServer + ". Checking CIDR...");
    this._resourceMgr.checkCIDR(pod, zone, ssCmd.getPrivateIpAddress(), ssCmd.getPrivateNetmask());
    return this._resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.XenServer, details, hostTags);
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) Zone(com.cloud.model.Zone) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) HostPodVO(com.cloud.dc.HostPodVO)

Example 20 with StartupCommand

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

the class SshKeysDistriMonitor method processConnect.

@Override
public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) {
    for (final StartupCommand startupCommand : startupCommands) {
        if (startupCommand instanceof StartupRoutingCommand) {
            if (((StartupRoutingCommand) startupCommand).getHypervisorType() == HypervisorType.KVM || ((StartupRoutingCommand) startupCommand).getHypervisorType() == HypervisorType.XenServer) {
                /*TODO: Get the private/public keys here*/
                final String pubKey = _configDao.getValue("ssh.publickey");
                final String prvKey = _configDao.getValue("ssh.privatekey");
                try {
                    final ModifySshKeysCommand cmds = new ModifySshKeysCommand(pubKey, prvKey);
                    final Commands c = new Commands(cmds);
                    _agentMgr.send(host.getId(), c, this);
                } catch (final AgentUnavailableException e) {
                    s_logger.debug("Failed to send keys to agent: " + host.getId());
                }
            }
        }
    }
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) AgentUnavailableException(com.cloud.legacymodel.exceptions.AgentUnavailableException) ModifySshKeysCommand(com.cloud.legacymodel.communication.command.ModifySshKeysCommand) Commands(com.cloud.agent.manager.Commands) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)

Aggregations

StartupCommand (com.cloud.legacymodel.communication.command.startup.StartupCommand)27 StartupRoutingCommand (com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)14 AgentUnavailableException (com.cloud.legacymodel.exceptions.AgentUnavailableException)6 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)6 StartupStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupStorageCommand)5 HostVO (com.cloud.host.HostVO)4 StartupSecondaryStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand)4 Request (com.cloud.common.transport.Request)3 ClusterVO (com.cloud.dc.ClusterVO)3 ConnectionException (com.cloud.legacymodel.exceptions.ConnectionException)3 DiscoveryException (com.cloud.legacymodel.exceptions.DiscoveryException)3 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)3 NoTransitionException (com.cloud.legacymodel.exceptions.NoTransitionException)3 ResourceInUseException (com.cloud.legacymodel.exceptions.ResourceInUseException)3 UnableDeleteHostException (com.cloud.legacymodel.exceptions.UnableDeleteHostException)3 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)3 SshException (com.cloud.utils.ssh.SshException)3 URISyntaxException (java.net.URISyntaxException)3 ConfigurationException (javax.naming.ConfigurationException)3 Commands (com.cloud.agent.manager.Commands)2