Search in sources :

Example 11 with StartupRoutingCommand

use of com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand 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 12 with StartupRoutingCommand

use of com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand 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)

Example 13 with StartupRoutingCommand

use of com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand 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)

Example 14 with StartupRoutingCommand

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

the class StoragePoolMonitor method processConnect.

@Override
public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException {
    for (final StartupCommand startupCommand : startupCommands) {
        if (startupCommand instanceof StartupRoutingCommand) {
            final StartupRoutingCommand scCmd = (StartupRoutingCommand) startupCommand;
            if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType() == HypervisorType.KVM) {
                final List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId(), ScopeType.CLUSTER);
                final List<StoragePoolVO> zoneStoragePoolsByTags = _poolDao.findZoneWideStoragePoolsByTags(host.getDataCenterId(), null);
                final List<StoragePoolVO> zoneStoragePoolsByHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), scCmd.getHypervisorType());
                zoneStoragePoolsByTags.retainAll(zoneStoragePoolsByHypervisor);
                pools.addAll(zoneStoragePoolsByTags);
                final List<StoragePoolVO> zoneStoragePoolsByAnyHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), HypervisorType.Any);
                pools.addAll(zoneStoragePoolsByAnyHypervisor);
                for (final StoragePoolVO pool : pools) {
                    if (pool.getStatus() != StoragePoolStatus.Up) {
                        continue;
                    }
                    if (!pool.isShared()) {
                        continue;
                    }
                    if (pool.getPoolType() == StoragePoolType.OCFS2 && !_ocfs2Mgr.prepareNodes(pool.getClusterId())) {
                        throw new ConnectionException(true, "Unable to prepare OCFS2 nodes for pool " + pool.getId());
                    }
                    final Long hostId = host.getId();
                    s_logger.debug("Host " + hostId + " connected, connecting host to shared pool id " + pool.getId() + " and sending storage pool information ...");
                    try {
                        _storageManager.connectHostToSharedPool(hostId, pool.getId());
                        _storageManager.createCapacityEntry(pool.getId());
                    } catch (final Exception e) {
                        throw new ConnectionException(true, "Unable to connect host " + hostId + " to storage pool id " + pool.getId() + " due to " + e.toString(), e);
                    }
                }
            }
        }
    }
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) ConnectionException(com.cloud.legacymodel.exceptions.ConnectionException) ConnectionException(com.cloud.legacymodel.exceptions.ConnectionException)

Example 15 with StartupRoutingCommand

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

the class VirtualMachineManagerImpl method processConnect.

@Override
public void processConnect(final Host agent, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException {
    for (final StartupCommand startupCommand : startupCommands) {
        if (!(startupCommand instanceof StartupRoutingCommand)) {
            return;
        }
        s_logger.debug("Received startup command from hypervisor host. host id: " + agent.getId());
        _syncMgr.resetHostSyncState(agent.getId());
        if (forRebalance) {
            s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process");
            return;
        }
        final Long clusterId = agent.getClusterId();
        final long agentId = agent.getId();
        if (agent.getHypervisorType() == HypervisorType.XenServer) {
            // only for Xen
            // initiate the cron job
            final ClusterVMMetaDataSyncCommand syncVMMetaDataCmd = new ClusterVMMetaDataSyncCommand(ClusterVMMetaDataSyncInterval.value(), clusterId);
            try {
                final long seq_no = _agentMgr.send(agentId, new Commands(syncVMMetaDataCmd), this);
                s_logger.debug("Cluster VM metadata sync started with jobid " + seq_no);
            } catch (final AgentUnavailableException e) {
                s_logger.error("The Cluster VM metadata sync process failed for cluster id " + clusterId + " with ", e);
            }
        }
    }
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) ClusterVMMetaDataSyncCommand(com.cloud.legacymodel.communication.command.ClusterVMMetaDataSyncCommand) AgentUnavailableException(com.cloud.legacymodel.exceptions.AgentUnavailableException) Commands(com.cloud.agent.manager.Commands) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)

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