Search in sources :

Example 1 with StartupLocalstorageCommand

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

the class LibvirtComputingResource method initializeLocalstorage.

private List<StartupLocalstorageCommand> initializeLocalstorage() {
    final List<StartupLocalstorageCommand> startupLocalstorageCommandList = new ArrayList<>();
    for (final AgentConfiguration.Localstorage localstorage : this.agentConfiguration.getLocalstorages()) {
        if (localstorage.getType() == StoragePoolType.LVM) {
            try {
                logger.debug("Found local LVM storage pool: " + localstorage.getPath() + ", with uuid: " + localstorage.getUuid() + ", in the agent configuration");
                final KvmStoragePool localStoragePool = this.storagePoolMgr.createStoragePool(localstorage.getUuid(), "localhost", -1, localstorage.getPath(), "", StoragePoolType.LVM);
                final StoragePoolInfo storagePoolInfo = new StoragePoolInfo();
                storagePoolInfo.setUuid(localstorage.getUuid());
                storagePoolInfo.setHost(getName());
                storagePoolInfo.setLocalPath(localstorage.getPath());
                storagePoolInfo.setPoolType(StoragePoolType.LVM);
                storagePoolInfo.setCapacityBytes(localStoragePool.getCapacity());
                storagePoolInfo.setAvailableBytes(localStoragePool.getAvailable());
                final StartupLocalstorageCommand startupLocalstorageCommand = new StartupLocalstorageCommand();
                startupLocalstorageCommand.setPoolInfo(storagePoolInfo);
                startupLocalstorageCommandList.add(startupLocalstorageCommand);
            } catch (final CloudRuntimeException e) {
                logger.debug("Unable to initialize local storage pool: " + e);
            }
        }
    }
    return startupLocalstorageCommandList;
}
Also used : KvmStoragePool(com.cloud.agent.resource.kvm.storage.KvmStoragePool) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) StoragePoolInfo(com.cloud.legacymodel.storage.StoragePoolInfo) ArrayList(java.util.ArrayList) AgentConfiguration(com.cloud.agent.service.AgentConfiguration) StartupLocalstorageCommand(com.cloud.legacymodel.communication.command.startup.StartupLocalstorageCommand)

Example 2 with StartupLocalstorageCommand

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

Aggregations

StartupLocalstorageCommand (com.cloud.legacymodel.communication.command.startup.StartupLocalstorageCommand)2 StoragePoolInfo (com.cloud.legacymodel.storage.StoragePoolInfo)2 ArrayList (java.util.ArrayList)2 KvmStoragePool (com.cloud.agent.resource.kvm.storage.KvmStoragePool)1 AgentConfiguration (com.cloud.agent.service.AgentConfiguration)1 StartupCommand (com.cloud.legacymodel.communication.command.startup.StartupCommand)1 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)1 StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)1 DB (com.cloud.utils.db.DB)1