From bcfbc6d73c39213b65334bfd5e2cac1a235462f5 Mon Sep 17 00:00:00 2001 From: Mike Tutkowski Date: Thu, 6 Aug 2015 11:59:30 -0600 Subject: [PATCH] getUsedBytes should query the SolidFire cluster to acquire the size of the given volume if there is no volume_details info for that volume (and then create a volume_details row for this volume so we don't have to make that cluster call for this purpose again) --- .../driver/SolidFirePrimaryDataStoreDriver.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java index 46ecd6945f6..b545931ad43 100644 --- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java +++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java @@ -307,6 +307,18 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { usedSpace += volumeSize; } + else { + SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePool.getId(), _storagePoolDetailsDao); + long lVolumeId = Long.valueOf(volume.getFolder()); + + SolidFireUtil.SolidFireVolume sfVolume = SolidFireUtil.getSolidFireVolume(sfConnection, lVolumeId); + + // SolidFireUtil.VOLUME_SIZE was introduced in 4.5. + // To be backward compatible with releases prior to 4.5, call updateVolumeDetails here. + // That way if SolidFireUtil.VOLUME_SIZE wasn't put in the volume_details table when the + // volume was initially created, it can be placed in volume_details here. + updateVolumeDetails(volume.getId(), sfVolume.getTotalSize()); + } } } @@ -417,8 +429,6 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { if (dataObject.getType() == DataObjectType.VOLUME) { VolumeInfo volumeInfo = (VolumeInfo)dataObject; - AccountVO account = _accountDao.findById(volumeInfo.getAccountId()); - String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId()); long storagePoolId = dataStore.getId(); @@ -427,6 +437,8 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { AccountDetailVO accountDetail = SolidFireUtil.getAccountDetail(volumeInfo.getAccountId(), storagePoolId, _accountDetailsDao); if (accountDetail == null || accountDetail.getValue() == null) { + AccountVO account = _accountDao.findById(volumeInfo.getAccountId()); + String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId()); SolidFireUtil.SolidFireAccount sfAccount = SolidFireUtil.getSolidFireAccount(sfConnection, sfAccountName); if (sfAccount == null) {