Search in sources :

Example 21 with StartupCommand

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);
    });
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StoragePoolInfo(com.cloud.legacymodel.storage.StoragePoolInfo) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) ArrayList(java.util.ArrayList) StartupLocalstorageCommand(com.cloud.legacymodel.communication.command.startup.StartupLocalstorageCommand) DB(com.cloud.utils.db.DB)

Example 22 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)

Example 23 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 24 with StartupCommand

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;
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StartupSecondaryStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand)

Example 25 with StartupCommand

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

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