@Override public long getCapacityBytes() { return pdsv.getCapacityBytes(); }
private void verifySufficientBytesForStoragePool(long requestedBytes, long storagePoolId) { StoragePoolVO storagePool = storagePoolDao.findById(storagePoolId); long capacityBytes = storagePool.getCapacityBytes(); long usedBytes = getUsedBytes(storagePool); usedBytes += requestedBytes; if (usedBytes > capacityBytes) { throw new CloudRuntimeException("Insufficient amount of space remains in this primary storage"); } }
private void verifySufficientBytesForStoragePool(long storagePoolId, long volumeId, long newSize, Integer newHypervisorSnapshotReserve) { DataStore primaryDataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); VolumeInfo volumeInfo = volumeFactory.getVolume(volumeId, primaryDataStore); StoragePoolVO storagePool = storagePoolDao.findById(storagePoolId); long currentSizeWithHsr = getDataObjectSizeIncludingHypervisorSnapshotReserve(volumeInfo, storagePool); newHypervisorSnapshotReserve = newHypervisorSnapshotReserve == null ? LOWEST_HYPERVISOR_SNAPSHOT_RESERVE : Math.max(newHypervisorSnapshotReserve, LOWEST_HYPERVISOR_SNAPSHOT_RESERVE); long newSizeWithHsr = (long)(newSize + newSize * (newHypervisorSnapshotReserve / 100f)); if (newSizeWithHsr < currentSizeWithHsr) { throw new CloudRuntimeException("Storage pool " + storagePoolId + " does not support shrinking a volume."); } long availableBytes = storagePool.getCapacityBytes() - getUsedBytes(storagePool); if ((newSizeWithHsr - currentSizeWithHsr) > availableBytes) { throw new CloudRuntimeException("Storage pool " + storagePoolId + " does not have enough space to expand the volume."); } }
if (capacityBytes != pool.getCapacityBytes()) { updatedCapacityBytes = capacityBytes;
totalOverProvCapacity = overProvFactor.multiply(new BigDecimal(storagePool.getCapacityBytes())).longValue(); s_logger.debug("Found storage pool " + storagePool.getName() + " of type " + storagePool.getPoolType().toString() + " with overprovisioning factor " + overProvFactor.toString()); s_logger.debug("Total over provisioned capacity calculated is " + overProvFactor + " * " + storagePool.getCapacityBytes()); } else { s_logger.debug("Found storage pool " + storagePool.getName() + " of type " + storagePool.getPoolType().toString()); totalOverProvCapacity = storagePool.getCapacityBytes();
private String createTemplateVolume(TemplateInfo templateInfo, long storagePoolId) { verifySufficientBytesForStoragePool(templateInfo, storagePoolId); SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, storagePoolDetailsDao); long sfAccountId = getCreateSolidFireAccountId(sfConnection, templateInfo.getAccountId(), storagePoolId); SolidFireUtil.SolidFireVolume sfVolume = createSolidFireVolume(sfConnection, templateInfo, storagePoolId, sfAccountId); String iqn = sfVolume.getIqn(); VMTemplateStoragePoolVO templatePoolRef = tmpltPoolDao.findByPoolTemplate(storagePoolId, templateInfo.getId()); templatePoolRef.setInstallPath(iqn); templatePoolRef.setLocalDownloadPath(Long.toString(sfVolume.getId())); templatePoolRef.setTemplateSize(sfVolume.getTotalSize()); tmpltPoolDao.update(templatePoolRef.getId(), templatePoolRef); StoragePoolVO storagePool = storagePoolDao.findById(storagePoolId); long capacityBytes = storagePool.getCapacityBytes(); // getUsedBytes(StoragePool) will include the bytes of the newly created template volume because // _tmpltPoolDao.update(Long, VMTemplateStoragePoolVO) has already been invoked long usedBytes = getUsedBytes(storagePool); storagePool.setUsedBytes(usedBytes > capacityBytes ? capacityBytes : usedBytes); storagePoolDao.update(storagePoolId, storagePool); return iqn; }
long capacityBytes = storagePool.getCapacityBytes(); long usedBytes = storagePool.getUsedBytes();
long capacityBytes = storagePool.getCapacityBytes();
@Override public void createAsync(DataStore dataStore, DataObject dataObject, AsyncCompletionCallback<CreateCmdResult> callback) { String iqn = null; String errorMessage = null; if (dataObject.getType() != DataObjectType.VOLUME) { errorMessage = "Invalid DataObjectType (" + dataObject.getType() + ") passed to createAsync"; } else { VolumeInfo volumeInfo = (VolumeInfo) dataObject; long storagePoolId = dataStore.getId(); NexentaStorAppliance appliance = getNexentaStorAppliance(storagePoolId); // TODO: maybe we should use md5(volume name) as volume name NexentaStorZvol zvol = (NexentaStorZvol) appliance.createVolume(volumeInfo.getName(), volumeInfo.getSize()); iqn = zvol.getIqn(); VolumeVO volume = this._volumeDao.findById(volumeInfo.getId()); volume.set_iScsiName(iqn); volume.setFolder(zvol.getName()); volume.setPoolType(Storage.StoragePoolType.IscsiLUN); volume.setPoolId(storagePoolId); _volumeDao.update(volume.getId(), volume); StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId); long capacityBytes = storagePool.getCapacityBytes(); long usedBytes = storagePool.getUsedBytes(); usedBytes += volumeInfo.getSize(); storagePool.setUsedBytes(usedBytes > capacityBytes ? capacityBytes : usedBytes); _storagePoolDao.update(storagePoolId, storagePool); } CreateCmdResult result = new CreateCmdResult(iqn, new Answer(null, errorMessage == null, errorMessage)); result.setResult(errorMessage); callback.complete(result); }
long capacityBytes = storagePool.getCapacityBytes();