Skip to content

Commit bcfbc6d

Browse files
author
Mike Tutkowski
committed
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)
1 parent a5e563a commit bcfbc6d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,18 @@ public long getUsedBytes(StoragePool storagePool) {
307307

308308
usedSpace += volumeSize;
309309
}
310+
else {
311+
SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePool.getId(), _storagePoolDetailsDao);
312+
long lVolumeId = Long.valueOf(volume.getFolder());
313+
314+
SolidFireUtil.SolidFireVolume sfVolume = SolidFireUtil.getSolidFireVolume(sfConnection, lVolumeId);
315+
316+
// SolidFireUtil.VOLUME_SIZE was introduced in 4.5.
317+
// To be backward compatible with releases prior to 4.5, call updateVolumeDetails here.
318+
// That way if SolidFireUtil.VOLUME_SIZE wasn't put in the volume_details table when the
319+
// volume was initially created, it can be placed in volume_details here.
320+
updateVolumeDetails(volume.getId(), sfVolume.getTotalSize());
321+
}
310322
}
311323
}
312324

@@ -417,8 +429,6 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
417429

418430
if (dataObject.getType() == DataObjectType.VOLUME) {
419431
VolumeInfo volumeInfo = (VolumeInfo)dataObject;
420-
AccountVO account = _accountDao.findById(volumeInfo.getAccountId());
421-
String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId());
422432

423433
long storagePoolId = dataStore.getId();
424434

@@ -427,6 +437,8 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
427437
AccountDetailVO accountDetail = SolidFireUtil.getAccountDetail(volumeInfo.getAccountId(), storagePoolId, _accountDetailsDao);
428438

429439
if (accountDetail == null || accountDetail.getValue() == null) {
440+
AccountVO account = _accountDao.findById(volumeInfo.getAccountId());
441+
String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId());
430442
SolidFireUtil.SolidFireAccount sfAccount = SolidFireUtil.getSolidFireAccount(sfConnection, sfAccountName);
431443

432444
if (sfAccount == null) {

0 commit comments

Comments
 (0)