use of com.cloud.legacymodel.communication.command.startup.StartupCommand in project cosmic by MissionCriticalCloud.
the class LocalStoragePoolListener method processConnect.
@Override
@DB
public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException {
final List<StoragePoolVO> registeredStoragePoolsForHost = this._storagePoolDao.listHostScopedPoolsByStorageHost(host.getName());
final List<StoragePoolVO> liveStoragePools = new ArrayList<>();
for (final StartupCommand startupCommand : startupCommands) {
if (startupCommand instanceof StartupLocalstorageCommand) {
final StartupLocalstorageCommand ssCmd = (StartupLocalstorageCommand) startupCommand;
final StoragePoolInfo pInfo = ssCmd.getPoolInfo();
if (pInfo == null) {
return;
}
s_logger.info("Found storage pool in StartupCommand creating it now: " + pInfo.getUuid());
liveStoragePools.add((StoragePoolVO) this._storageMgr.createLocalStorage(host, pInfo));
}
}
registeredStoragePoolsForHost.removeAll(liveStoragePools);
registeredStoragePoolsForHost.forEach(storagePoolVO -> {
// Disable all storage pools not live right now!
s_logger.info("Disabling storage pool because it is not in the StartupCommand: " + storagePoolVO.getName());
storagePoolVO.setStatus(StoragePoolStatus.Disabled);
this._storagePoolDao.persist(storagePoolVO);
});
}
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());
}
}
}
}
}
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 };
}
use of com.cloud.legacymodel.communication.command.startup.StartupCommand 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;
}
use of com.cloud.legacymodel.communication.command.startup.StartupCommand 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);
}
}
}
}
}
}
Aggregations