Search in sources :

Example 21 with StartupRoutingCommand

use of com.cloud.agent.api.StartupRoutingCommand in project cloudstack by apache.

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.agent.api.StartupRoutingCommand) HostVO(com.cloud.host.HostVO) HostDao(com.cloud.host.dao.HostDao) Before(org.junit.Before)

Example 22 with StartupRoutingCommand

use of com.cloud.agent.api.StartupRoutingCommand in project cloudstack by apache.

the class XcpServerDiscoverer method createHostVOForDirectConnectAgent.

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

Example 23 with StartupRoutingCommand

use of com.cloud.agent.api.StartupRoutingCommand in project cloudstack by apache.

the class OvmDiscoverer method createHostVOForDirectConnectAgent.

@Override
public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) {
    StartupCommand firstCmd = startup[0];
    if (!(firstCmd instanceof StartupRoutingCommand)) {
        return null;
    }
    StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
    if (ssCmd.getHypervisorType() != HypervisorType.Ovm) {
        return null;
    }
    return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Ovm, details, hostTags);
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Example 24 with StartupRoutingCommand

use of com.cloud.agent.api.StartupRoutingCommand in project cloudstack by apache.

the class DownloadListener method processConnect.

@Override
public void processConnect(Host agent, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
    if (cmd instanceof StartupRoutingCommand) {
        List<HypervisorType> hypers = _resourceMgr.listAvailHypervisorInZone(agent.getId(), agent.getDataCenterId());
        HypervisorType hostHyper = agent.getHypervisorType();
        if (hypers.contains(hostHyper)) {
            return;
        }
        _imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
        // update template_zone_ref for cross-zone templates
        _imageSrv.associateCrosszoneTemplatesToZone(agent.getDataCenterId());
    } else /* This can be removed
        else if ( cmd instanceof StartupStorageCommand) {
            StartupStorageCommand storage = (StartupStorageCommand)cmd;
            if( storage.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE ||
                    storage.getResourceType() == Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE  ) {
                downloadMonitor.addSystemVMTemplatesToHost(agent, storage.getTemplateInfo());
                downloadMonitor.handleTemplateSync(agent);
                downloadMonitor.handleVolumeSync(agent);
            }
        }*/
    if (cmd instanceof StartupSecondaryStorageCommand) {
        try {
            List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
            for (DataStore store : imageStores) {
                _volumeSrv.handleVolumeSync(store);
                _imageSrv.handleTemplateSync(store);
            }
        } catch (Exception e) {
            s_logger.error("Caught exception while doing template/volume sync ", e);
        }
    }
}
Also used : HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) StartupSecondaryStorageCommand(com.cloud.agent.api.StartupSecondaryStorageCommand) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) List(java.util.List) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) ConnectionException(com.cloud.exception.ConnectionException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 25 with StartupRoutingCommand

use of com.cloud.agent.api.StartupRoutingCommand in project cloudstack by apache.

the class BareMetalDiscoverer method createHostVOForDirectConnectAgent.

@Override
public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) {
    StartupCommand firstCmd = startup[0];
    if (!(firstCmd instanceof StartupRoutingCommand)) {
        return null;
    }
    StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
    if (ssCmd.getHypervisorType() != HypervisorType.BareMetal) {
        return null;
    }
    return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.BareMetal, details, hostTags);
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Aggregations

StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)40 StartupCommand (com.cloud.agent.api.StartupCommand)27 StartupStorageCommand (com.cloud.agent.api.StartupStorageCommand)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)9 ClusterVO (com.cloud.dc.ClusterVO)6 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)6 ConnectionException (com.cloud.exception.ConnectionException)6 HostVO (com.cloud.host.HostVO)6 DataCenterVO (com.cloud.dc.DataCenterVO)5 ConfigurationException (javax.naming.ConfigurationException)5 HostPodVO (com.cloud.dc.HostPodVO)4 Command (com.cloud.agent.api.Command)3 Commands (com.cloud.agent.manager.Commands)3 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)3 PingCommand (com.cloud.agent.api.PingCommand)2 PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)2 SetupAnswer (com.cloud.agent.api.SetupAnswer)2 SetupCommand (com.cloud.agent.api.SetupCommand)2 StartCommand (com.cloud.agent.api.StartCommand)2 StoragePoolInfo (com.cloud.agent.api.StoragePoolInfo)2