diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 0abb6298534..22c801f454c 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1303,7 +1303,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw new InvalidParameterValueException("The specified VM already has the maximum number of data disks (" + maxDataVolumesSupported + "). Please specify another VM."); } } - deviceId = getDeviceId(vmId, deviceId); // If local storage is disabled then attaching a volume with local disk // offering not allowed @@ -2300,6 +2299,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } DataTO volTO = volFactory.getVolume(volumeToAttach.getId()).getTO(); + + deviceId = getDeviceId(vm.getId(), deviceId); + DiskTO disk = new DiskTO(volTO, deviceId, volumeToAttach.getPath(), volumeToAttach.getVolumeType()); AttachCommand cmd = new AttachCommand(disk, vm.getInstanceName());