Search in sources :

Example 1 with StoragePoolInfo

use of com.cloud.legacymodel.storage.StoragePoolInfo 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 StoragePoolInfo

use of com.cloud.legacymodel.storage.StoragePoolInfo in project cosmic by MissionCriticalCloud.

the class CitrixResourceBase method initializeLocalSR.

protected StartupStorageCommand initializeLocalSR(final Connection conn) {
    final SR lvmsr = getLocalLVMSR(conn);
    if (lvmsr != null) {
        try {
            this._host.setLocalSRuuid(lvmsr.getUuid(conn));
            final String lvmuuid = lvmsr.getUuid(conn);
            final long cap = lvmsr.getPhysicalSize(conn);
            if (cap > 0) {
                final long avail = cap - lvmsr.getPhysicalUtilisation(conn);
                lvmsr.setNameLabel(conn, lvmuuid);
                final String name = "Cloud Stack Local LVM Storage Pool for " + this._host.getUuid();
                lvmsr.setNameDescription(conn, name);
                final Host host = Host.getByUuid(conn, this._host.getUuid());
                final String address = host.getAddress(conn);
                final StoragePoolInfo pInfo = new StoragePoolInfo(lvmuuid, address, SRType.LVM.toString(), SRType.LVM.toString(), StoragePoolType.LVM, cap, avail);
                final StartupStorageCommand cmd = new StartupStorageCommand();
                cmd.setPoolInfo(pInfo);
                cmd.setGuid(this._host.getUuid());
                cmd.setDataCenter(Long.toString(this._dcId));
                cmd.setResourceType(StorageResourceType.STORAGE_POOL);
                return cmd;
            }
        } catch (final XenAPIException e) {
            final String msg = "build local LVM info err in host:" + this._host.getUuid() + e.toString();
            s_logger.warn(msg);
        } catch (final XmlRpcException e) {
            final String msg = "build local LVM info err in host:" + this._host.getUuid() + e.getMessage();
            s_logger.warn(msg);
        }
    }
    final SR extsr = getLocalEXTSR(conn);
    if (extsr != null) {
        try {
            final String extuuid = extsr.getUuid(conn);
            this._host.setLocalSRuuid(extuuid);
            final long cap = extsr.getPhysicalSize(conn);
            if (cap > 0) {
                final long avail = cap - extsr.getPhysicalUtilisation(conn);
                extsr.setNameLabel(conn, extuuid);
                final String name = "Cloud Stack Local EXT Storage Pool for " + this._host.getUuid();
                extsr.setNameDescription(conn, name);
                final Host host = Host.getByUuid(conn, this._host.getUuid());
                final String address = host.getAddress(conn);
                final StoragePoolInfo pInfo = new StoragePoolInfo(extuuid, address, SRType.EXT.toString(), SRType.EXT.toString(), StoragePoolType.EXT, cap, avail);
                final StartupStorageCommand cmd = new StartupStorageCommand();
                cmd.setPoolInfo(pInfo);
                cmd.setGuid(this._host.getUuid());
                cmd.setDataCenter(Long.toString(this._dcId));
                cmd.setResourceType(StorageResourceType.STORAGE_POOL);
                return cmd;
            }
        } catch (final XenAPIException e) {
            final String msg = "build local EXT info err in host:" + this._host.getUuid() + e.toString();
            s_logger.warn(msg);
        } catch (final XmlRpcException e) {
            final String msg = "build local EXT info err in host:" + this._host.getUuid() + e.getMessage();
            s_logger.warn(msg);
        }
    }
    return null;
}
Also used : StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) StoragePoolInfo(com.cloud.legacymodel.storage.StoragePoolInfo) XenAPIException(com.xensource.xenapi.Types.XenAPIException) Host(com.xensource.xenapi.Host) XmlRpcException(org.apache.xmlrpc.XmlRpcException) SR(com.xensource.xenapi.SR)

Example 3 with StoragePoolInfo

use of com.cloud.legacymodel.storage.StoragePoolInfo 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

StoragePoolInfo (com.cloud.legacymodel.storage.StoragePoolInfo)3 StartupLocalstorageCommand (com.cloud.legacymodel.communication.command.startup.StartupLocalstorageCommand)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 StartupStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupStorageCommand)1 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)1 StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)1 DB (com.cloud.utils.db.DB)1 Host (com.xensource.xenapi.Host)1 SR (com.xensource.xenapi.SR)1 XenAPIException (com.xensource.xenapi.Types.XenAPIException)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1