Skip to content

Commit 0ef082d

Browse files
Applu Mike's suggestion to improve "createMappingVolumeAndStoragePool" method
1 parent d60b713 commit 0ef082d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,8 +2283,7 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
22832283
* If the user did not enter a complete mapping, the volumes that were left behind will be auto mapped using {@link #createStoragePoolMappingsForVolumes(VirtualMachineProfile, Host, Map, List)}
22842284
*/
22852285
protected Map<Volume, StoragePool> createMappingVolumeAndStoragePool(VirtualMachineProfile profile, Host targetHost, Map<Long, Long> userDefinedMapOfVolumesAndStoragePools) {
2286-
Map<Volume, StoragePool> volumeToPoolObjectMap = new HashMap<>();
2287-
buildMapUsingUserInformation(profile, targetHost, userDefinedMapOfVolumesAndStoragePools, volumeToPoolObjectMap);
2286+
Map<Volume, StoragePool> volumeToPoolObjectMap = buildMapUsingUserInformation(profile, targetHost, userDefinedMapOfVolumesAndStoragePools);
22882287

22892288
List<Volume> volumesNotMapped = findVolumesThatWereNotMappedByTheUser(profile, volumeToPoolObjectMap);
22902289
createStoragePoolMappingsForVolumes(profile, targetHost, volumeToPoolObjectMap, volumesNotMapped);
@@ -2309,9 +2308,10 @@ private List<Volume> findVolumesThatWereNotMappedByTheUser(VirtualMachineProfile
23092308
/**
23102309
* Builds the map of storage pools and volumes with the information entered by the user. Before creating the an entry we validate if the migration is feasible checking if the migration is allowed and if the target host can access the defined target storage pool.
23112310
*/
2312-
private void buildMapUsingUserInformation(VirtualMachineProfile profile, Host targetHost, Map<Long, Long> userDefinedVolumeToStoragePoolMap, Map<Volume, StoragePool> volumeToPoolObjectMap) {
2311+
private Map<Volume, StoragePool> buildMapUsingUserInformation(VirtualMachineProfile profile, Host targetHost, Map<Long, Long> userDefinedVolumeToStoragePoolMap) {
2312+
Map<Volume, StoragePool> volumeToPoolObjectMap = new HashMap<>();
23132313
if (MapUtils.isEmpty(userDefinedVolumeToStoragePoolMap)) {
2314-
return;
2314+
return volumeToPoolObjectMap;
23152315
}
23162316
for(Long volumeId: userDefinedVolumeToStoragePoolMap.keySet()) {
23172317
VolumeVO volume = _volsDao.findById(volumeId);
@@ -2331,6 +2331,7 @@ private void buildMapUsingUserInformation(VirtualMachineProfile profile, Host ta
23312331
}
23322332
volumeToPoolObjectMap.put(volume, targetPool);
23332333
}
2334+
return volumeToPoolObjectMap;
23342335
}
23352336

23362337
/**

0 commit comments

Comments
 (0)