server: increment deviceid while importing vm data volumes (#6123)

Fixes #6121

deviceId for a volume/disk is never used by CloudStack VMware hypervisor plugin. Still it would be correct to increment value for each data volume/disk, behaviour similar to adding data volumes/disks.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2022-04-08 15:24:10 +05:30 committed by GitHub
parent c61ea9f96d
commit e7071ec196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -1016,6 +1016,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
diskProfileStoragePoolList.add(importDisk(rootDisk, userVm, cluster, serviceOffering, Volume.Type.ROOT, String.format("ROOT-%d", userVm.getId()),
(rootDisk.getCapacity() / Resource.ResourceType.bytesToGiB), minIops, maxIops,
template, owner, null));
long deviceId = 1L;
for (UnmanagedInstanceTO.Disk disk : dataDisks) {
if (disk.getCapacity() == null || disk.getCapacity() == 0) {
throw new InvalidParameterValueException(String.format("Disk ID: %s size is invalid", rootDisk.getDiskId()));
@ -1023,7 +1024,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
DiskOffering offering = diskOfferingDao.findById(dataDiskOfferingMap.get(disk.getDiskId()));
diskProfileStoragePoolList.add(importDisk(disk, userVm, cluster, offering, Volume.Type.DATADISK, String.format("DATA-%d-%s", userVm.getId(), disk.getDiskId()),
(disk.getCapacity() / Resource.ResourceType.bytesToGiB), offering.getMinIops(), offering.getMaxIops(),
template, owner, null));
template, owner, deviceId));
deviceId++;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to import volumes while importing vm: %s", instanceName), e);