Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions server/src/main/java/com/cloud/storage/StorageManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1260,10 +1260,18 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I
boolean changes = false;
Long updatedCapacityBytes = null;
Long capacityBytes = cmd.getCapacityBytes();
// retrieve current details and merge/overlay input to capture changes
Map<String, String> details = null;
details = _storagePoolDetailsDao.listDetailsKeyPairs(id);
if (inputDetails != null) {
details.putAll(inputDetails);
changes = true;
}

if (capacityBytes != null) {
if (capacityBytes != pool.getCapacityBytes()) {
updatedCapacityBytes = capacityBytes;
details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, String.valueOf(updatedCapacityBytes));
changes = true;
}
}
Expand All @@ -1273,40 +1281,29 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I
if (capacityIops != null) {
if (!capacityIops.equals(pool.getCapacityIops())) {
updatedCapacityIops = capacityIops;
details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, String.valueOf(updatedCapacityIops));
changes = true;
}
}

// retrieve current details and merge/overlay input to capture changes
Map<String, String> details = null;
details = _storagePoolDetailsDao.listDetailsKeyPairs(id);
if (inputDetails != null) {
details.putAll(inputDetails);
changes = true;
}

if (changes) {
StoragePoolVO storagePool = _storagePoolDao.findById(id);
DataStoreProvider dataStoreProvider = _dataStoreProviderMgr.getDataStoreProvider(storagePool.getStorageProviderName());
DataStoreProvider dataStoreProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
DataStoreLifeCycle dataStoreLifeCycle = dataStoreProvider.getDataStoreLifeCycle();

if (dataStoreLifeCycle instanceof PrimaryDataStoreLifeCycle) {
if (cmd.getUrl() != null) {
details.put("url", cmd.getUrl());
}
((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).updateStoragePool(pool, details);
if (updatedCapacityBytes != null) {
details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, updatedCapacityBytes != null ? String.valueOf(updatedCapacityBytes) : null);
_storagePoolDao.updateCapacityBytes(id, updatedCapacityBytes);
pool.setCapacityBytes(updatedCapacityBytes);
}
if (updatedCapacityIops != null) {
details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, updatedCapacityIops != null ? String.valueOf(updatedCapacityIops) : null);
_storagePoolDao.updateCapacityIops(id, updatedCapacityIops);
pool.setCapacityIops(updatedCapacityIops);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why to set this value before making lifecycle call?
bcz updateStoragePool will receive same bytes.

}
if (cmd.getUrl() != null) {
details.put("url", cmd.getUrl());
}
_storagePoolDao.update(id, storagePool);
_storagePoolDao.update(id, pool);
_storagePoolDao.updateDetails(id, details);
}
}

return (PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
}

Expand Down
Loading