Addressed review comments on code refactor

This commit is contained in:
Harikrishna Patnala 2021-10-04 17:44:46 +05:30
parent e51a689f69
commit 5c26f0a6d3
1 changed files with 26 additions and 23 deletions

View File

@ -424,29 +424,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
vol.setSize(finalSize);
vol.update();
VolumeVO volumeVO = volumeDao.findById(vol.getId());
String datastoreUUID = answer.getContextParam("datastoreUUID");
if (datastoreUUID != null) {
StoragePoolVO storagePoolVO = primaryStoreDao.findByUuid(datastoreUUID);
if (storagePoolVO != null) {
volumeVO.setPoolId(storagePoolVO.getId());
} else {
s_logger.warn(String.format("Unable to find datastore %s while updating the new datastore of the volume %d", datastoreUUID, vol.getId()));
}
}
String volumePath = answer.getContextParam("volumePath");
if (volumePath != null) {
volumeVO.setPath(volumePath);
}
String chainInfo = answer.getContextParam("chainInfo");
if (chainInfo != null) {
volumeVO.setChainInfo(chainInfo);
}
volumeDao.update(volumeVO.getId(), volumeVO);
updateVolumePathDetails(vol, answer);
} else if (answer != null) {
result.setResult(answer.getDetails());
} else {
@ -462,6 +440,31 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
callback.complete(result);
}
private void updateVolumePathDetails(VolumeObject vol, ResizeVolumeAnswer answer) {
VolumeVO volumeVO = volumeDao.findById(vol.getId());
String datastoreUUID = answer.getContextParam("datastoreUUID");
if (datastoreUUID != null) {
StoragePoolVO storagePoolVO = primaryStoreDao.findByUuid(datastoreUUID);
if (storagePoolVO != null) {
volumeVO.setPoolId(storagePoolVO.getId());
} else {
s_logger.warn(String.format("Unable to find datastore %s while updating the new datastore of the volume %d", datastoreUUID, vol.getId()));
}
}
String volumePath = answer.getContextParam("volumePath");
if (volumePath != null) {
volumeVO.setPath(volumePath);
}
String chainInfo = answer.getContextParam("chainInfo");
if (chainInfo != null) {
volumeVO.setChainInfo(chainInfo);
}
volumeDao.update(volumeVO.getId(), volumeVO);
}
@Override
public void handleQualityOfServiceForVolumeMigration(VolumeInfo volumeInfo, QualityOfServiceState qualityOfServiceState) {}