Skip to content

Commit c01e162

Browse files
committed
vm-import: fix volume size when lesser than 1GiB
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 1a1ef27 commit c01e162

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ List<DiskProfile> allocateTemplatedVolumes(Type type, String name, DiskOffering
153153
* @param type Type of the volume - ROOT, DATADISK, etc
154154
* @param name Name of the volume
155155
* @param offering DiskOffering for the volume
156-
* @param size DiskOffering for the volume
156+
* @param sizeInBytes size of the volume in bytes
157157
* @param minIops minimum IOPS for the disk, if not passed DiskOffering value will be used
158158
* @param maxIops maximum IOPS for the disk, if not passed DiskOffering value will be used
159159
* @param vm VirtualMachine this volume is attached to
@@ -165,7 +165,7 @@ List<DiskProfile> allocateTemplatedVolumes(Type type, String name, DiskOffering
165165
* @param chainInfo chain info for the volume. Hypervisor specific.
166166
* @return DiskProfile of imported volume
167167
*/
168-
DiskProfile importVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops, VirtualMachine vm, VirtualMachineTemplate template,
168+
DiskProfile importVolume(Type type, String name, DiskOffering offering, Long sizeInBytes, Long minIops, Long maxIops, VirtualMachine vm, VirtualMachineTemplate template,
169169
Account owner, Long deviceId, Long poolId, String path, String chainInfo);
170170

171171
DiskProfile updateImportedVolume(Type type, DiskOffering offering, VirtualMachine vm, VirtualMachineTemplate template,

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,19 +2172,17 @@ public void updateVolumeDiskChain(long volumeId, String path, String chainInfo,
21722172
}
21732173

21742174
@Override
2175-
public DiskProfile importVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops,
2175+
public DiskProfile importVolume(Type type, String name, DiskOffering offering, Long sizeInBytes, Long minIops, Long maxIops,
21762176
VirtualMachine vm, VirtualMachineTemplate template, Account owner,
21772177
Long deviceId, Long poolId, String path, String chainInfo) {
2178-
if (size == null) {
2179-
size = offering.getDiskSize();
2180-
} else {
2181-
size = (size * 1024 * 1024 * 1024);
2178+
if (sizeInBytes == null) {
2179+
sizeInBytes = offering.getDiskSize();
21822180
}
21832181

21842182
minIops = minIops != null ? minIops : offering.getMinIops();
21852183
maxIops = maxIops != null ? maxIops : offering.getMaxIops();
21862184

2187-
VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), offering.getProvisioningType(), size, minIops, maxIops, null);
2185+
VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), offering.getProvisioningType(), sizeInBytes, minIops, maxIops, null);
21882186
if (vm != null) {
21892187
vol.setInstanceId(vm.getId());
21902188
}

server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ private UserVm importVirtualMachineInternal(final UnmanagedInstanceTO unmanagedI
11721172
}
11731173
DiskOfferingVO diskOffering = diskOfferingDao.findById(serviceOffering.getDiskOfferingId());
11741174
diskProfileStoragePoolList.add(importDisk(rootDisk, userVm, cluster, diskOffering, Volume.Type.ROOT, String.format("ROOT-%d", userVm.getId()),
1175-
(rootDisk.getCapacity() / Resource.ResourceType.bytesToGiB), minIops, maxIops,
1175+
rootDisk.getCapacity(), minIops, maxIops,
11761176
template, owner, null));
11771177
long deviceId = 1L;
11781178
for (UnmanagedInstanceTO.Disk disk : dataDisks) {
@@ -1181,7 +1181,7 @@ private UserVm importVirtualMachineInternal(final UnmanagedInstanceTO unmanagedI
11811181
}
11821182
DiskOffering offering = diskOfferingDao.findById(dataDiskOfferingMap.get(disk.getDiskId()));
11831183
diskProfileStoragePoolList.add(importDisk(disk, userVm, cluster, offering, Volume.Type.DATADISK, String.format("DATA-%d-%s", userVm.getId(), disk.getDiskId()),
1184-
(disk.getCapacity() / Resource.ResourceType.bytesToGiB), offering.getMinIops(), offering.getMaxIops(),
1184+
disk.getCapacity(), offering.getMinIops(), offering.getMaxIops(),
11851185
template, owner, deviceId));
11861186
deviceId++;
11871187
}

0 commit comments

Comments
 (0)