From e7071ec1964a86b0bc508b21dd80b89257f3c3ed Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 8 Apr 2022 15:24:10 +0530 Subject: [PATCH] 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 --- .../org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java index 10a7ca74dcf..f13157632bf 100644 --- a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java @@ -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);