Package org.apache.cloudstack.storage.datastore.db

Examples of org.apache.cloudstack.storage.datastore.db.StoragePoolVO


        VolumeVO volume = listVolumes.get(0);
        Long poolId = volume.getPoolId();
        if (poolId == null) {
            throw new InvalidParameterValueException("pool id is not found");
        }
        StoragePoolVO storagePool = _storagePoolDao.findById(poolId);
        if (storagePool == null) {
            throw new InvalidParameterValueException("storage pool is not found");
        }
        List<HostVO> listHost = _hostDao.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, storagePool.getClusterId(), storagePool.getPodId(),
                storagePool.getDataCenterId(), null);
        if (listHost == null || listHost.size() == 0) {
            throw new InvalidParameterValueException("no host in up state is found");
        }
        return listHost.get(0).getId();
    }
View Full Code Here


             * DataStore store = lifeCycle.initialize(params); ClusterScope
             * scope = new ClusterScope(clusterId, podId, dcId);
             * lifeCycle.attachCluster(store, scope);
             */

            StoragePoolVO pool = new StoragePoolVO();
            pool.setClusterId(clusterId);
            pool.setDataCenterId(dcId);
            URI uri = new URI(this.getPrimaryStorageUrl());
            pool.setHostAddress(uri.getHost());
            pool.setPath(uri.getPath());
            pool.setPort(0);
            pool.setName(this.primaryName);
            pool.setUuid(this.getPrimaryStorageUuid());
            pool.setStatus(StoragePoolStatus.Up);
            pool.setPoolType(StoragePoolType.NetworkFilesystem);
            pool.setPodId(podId);
            pool.setScope(ScopeType.CLUSTER);
            pool.setStorageProviderName(DataStoreProvider.DEFAULT_PRIMARY);
            pool = this.primaryStoreDao.persist(pool);
            DataStore store = this.dataStoreMgr.getPrimaryDataStore(pool.getId());
            return store;
        } catch (Exception e) {
            return null;
        }
    }
View Full Code Here

        }
    }

    @Override
    public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
        StoragePoolVO dataStoreVO = dataStoreDao.findById(dataStore.getId());
        dataStoreVO.setDataCenterId(scope.getZoneId());
        dataStoreVO.setPodId(scope.getPodId());
        dataStoreVO.setClusterId(scope.getScopeId());
        dataStoreVO.setStatus(StoragePoolStatus.Attaching);
        dataStoreVO.setScope(scope.getScopeType());
        dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);

        attachCluster(dataStore);

        dataStoreVO = dataStoreDao.findById(dataStore.getId());
        dataStoreVO.setStatus(StoragePoolStatus.Up);
        dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);

        return true;
    }
View Full Code Here

            } else if (srcdata.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.VOLUME) {
                //For CLVM, we need to pass template on secondary storage to hypervisor
                String value = configDao.getValue(Config.PrimaryStorageDownloadWait.toString());
                int _primaryStorageDownloadWait = NumbersUtil.parseInt(value,
                        Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue()));
                StoragePoolVO storagePoolVO = primaryStoreDao.findById(store.getId());
                DataStore imageStore = templateManager.getImageStore(storagePoolVO.getDataCenterId(), srcdata.getId());
                DataObject srcData = templateDataFactory.getTemplate(srcdata.getId(), imageStore);

                CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _primaryStorageDownloadWait, true);
                EndPoint ep = epSelector.select(srcData, destData);
                Answer answer = ep.sendMessage(cmd);
View Full Code Here

        //BUG fix for CLOUDSTACK-4618
        DataStore store = destData.getDataStore();
        if (store.getRole() == DataStoreRole.Primary) {
            if ((srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.TEMPLATE) ||
                    (srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.VOLUME)) {
                StoragePoolVO storagePoolVO = primaryStoreDao.findById(store.getId());
                if (storagePoolVO != null && storagePoolVO.getPoolType() == Storage.StoragePoolType.CLVM) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

            volume.setPoolType(StoragePoolType.IscsiLUN);
            volume.setPoolId(storagePoolId);

            _volumeDao.update(volume.getId(), volume);

            StoragePoolVO storagePool = _storagePoolDao.findById(dataStore.getId());

            long capacityBytes = storagePool.getCapacityBytes();
            long usedBytes = storagePool.getUsedBytes();

            usedBytes += volumeInfo.getSize();

            storagePool.setUsedBytes(usedBytes > capacityBytes ? capacityBytes : usedBytes);

            _storagePoolDao.update(storagePoolId, storagePool);
        }
        else {
            errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to createAsync";
View Full Code Here

//                // delete the info in the account_details table
//                // that's related to the SolidFire account
//                _accountDetailsDao.deleteDetails(account.getAccountId());
//            }

            StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);

            long usedBytes = storagePool.getUsedBytes();

            usedBytes -= volumeInfo.getSize();

            storagePool.setUsedBytes(usedBytes < 0 ? 0 : usedBytes);

            _storagePoolDao.update(storagePoolId, storagePool);
        }
        else {
            errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to deleteAsync";
View Full Code Here

    // @Test(priority=3)
    public void tearDown() {
        List<StoragePoolVO> ds = primaryStoreDao.findPoolByName(this.primaryName);
        for (int i = 0; i < ds.size(); i++) {
            StoragePoolVO store = ds.get(i);
            store.setUuid(null);
            primaryStoreDao.remove(ds.get(i).getId());
            primaryStoreDao.expunge(ds.get(i).getId());
        }
    }
View Full Code Here

        // data disk and host identified from deploying vm (attach volume case)
        if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) {
            List<StoragePoolHostVO> hostPools = _poolHostDao.listByHostId(plan.getHostId());
            for (StoragePoolHostVO hostPool : hostPools) {
                StoragePoolVO pool = _storagePoolDao.findById(hostPool.getPoolId());
                if (pool != null && pool.isLocal()) {
                    StoragePool pol = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
                    if (filter(avoid, pol, dskCh, plan)) {
                        s_logger.debug("Found suitable local storage pool " + pool.getId() + ", adding to list");
                        suitablePools.add(pol);
                    } else {
                        avoid.addPool(pool.getId());
                    }
                }

                if (suitablePools.size() == returnUpTo) {
                    break;
                }
            }
        } else {
            if (plan.getPodId() == null) {
                // zone wide primary storage deployment
                return null;
            }
            List<StoragePoolVO> availablePools = _storagePoolDao.findLocalStoragePoolsByTags(plan.getDataCenterId(),
                    plan.getPodId(), plan.getClusterId(), dskCh.getTags());
            for (StoragePoolVO pool : availablePools) {
                if (suitablePools.size() == returnUpTo) {
                    break;
                }
                StoragePool pol = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
                if (filter(avoid, pol, dskCh, plan)) {
                    suitablePools.add(pol);
                } else {
                    avoid.addPool(pool.getId());
                }
            }

            // add remaining pools in cluster, that did not match tags, to avoid
            // set
            List<StoragePoolVO> allPools = _storagePoolDao.findLocalStoragePoolsByTags(plan.getDataCenterId(),
                    plan.getPodId(), plan.getClusterId(), null);
            allPools.removeAll(availablePools);
            for (StoragePoolVO pool : allPools) {
                avoid.addPool(pool.getId());
            }
        }

        if (s_logger.isDebugEnabled()) {
            s_logger.debug("LocalStoragePoolAllocator returning " + suitablePools.size() + " suitable storage pools");
View Full Code Here

        volumeInfo.stateTransit(Volume.Event.CreateRequested);
        volumeInfo.stateTransit(Volume.Event.OperationSucceeded);
        return volumeInfo;
    }
    private DataStore createDataStore() throws URISyntaxException {
        StoragePoolVO pool = new StoragePoolVO();
        pool.setClusterId(clusterId);
        pool.setDataCenterId(dcId);
        URI uri = new URI("nfs://jfkdkf/fjdkfj");
        pool.setHostAddress(uri.getHost());
        pool.setPath(uri.getPath());
        pool.setPort(0);
        pool.setName(UUID.randomUUID().toString());
        pool.setUuid(UUID.randomUUID().toString());
        pool.setStatus(StoragePoolStatus.Up);
        pool.setPoolType(Storage.StoragePoolType.NetworkFilesystem);
        pool.setPodId(podId);
        pool.setScope(ScopeType.CLUSTER);
        pool.setStorageProviderName(DataStoreProvider.DEFAULT_PRIMARY);
        pool = this.primaryDataStoreDao.persist(pool);
        DataStore store = this.dataStoreManager.getPrimaryDataStore(pool.getId());
        return store;
    }
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.storage.datastore.db.StoragePoolVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.