Skip to content

Commit 49dadc5

Browse files
committed
CLOUDSTACK-9752: [Vmware] Optimization of volume attachness to vm
1 parent e02003d commit 49dadc5

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,11 +1577,15 @@ public Answer createVolume(CreateObjectCommand cmd) {
15771577
}
15781578

15791579
synchronized (this) {
1580-
// s_logger.info("Delete file if exists in datastore to clear the way for creating the volume. file: " + volumeDatastorePath);
1581-
VmwareStorageLayoutHelper.deleteVolumeVmdkFiles(dsMo, volumeUuid.toString(), dcMo);
1582-
1583-
vmMo.createDisk(volumeDatastorePath, (int)(volume.getSize() / (1024L * 1024L)), morDatastore, vmMo.getScsiDeviceControllerKey());
1584-
vmMo.detachDisk(volumeDatastorePath, false);
1580+
try {
1581+
vmMo.createDisk(volumeDatastorePath, (int)(volume.getSize() / (1024L * 1024L)), morDatastore, vmMo.getScsiDeviceControllerKey());
1582+
vmMo.detachDisk(volumeDatastorePath, false);
1583+
}
1584+
catch (Exception e) {
1585+
s_logger.error("Deleting file " + volumeDatastorePath + " due to error: " + e.getMessage());
1586+
VmwareStorageLayoutHelper.deleteVolumeVmdkFiles(dsMo, volumeUuid.toString(), dcMo);
1587+
throw new CloudRuntimeException("Unable to create volume due to: " + e.getMessage());
1588+
}
15851589
}
15861590

15871591
VolumeObjectTO newVol = new VolumeObjectTO();

0 commit comments

Comments
 (0)