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);
}
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());
}
}
}
}
}
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);
}
}
}
}
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);
}
}
}
}
}
}
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);
}
}
}
}
Aggregations