CLOUDSTACK-9752: [Vmware] Optimization of volume attachness to vm

(cherry picked from commit 49dadc5505)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
nvazquez 2017-01-20 13:20:37 -03:00 committed by Rohit Yadav
parent 120ac33d7a
commit 1d25582ed6
1 changed files with 9 additions and 5 deletions

View File

@ -1571,11 +1571,15 @@ public class VmwareStorageProcessor implements StorageProcessor {
}
synchronized (this) {
// s_logger.info("Delete file if exists in datastore to clear the way for creating the volume. file: " + volumeDatastorePath);
VmwareStorageLayoutHelper.deleteVolumeVmdkFiles(dsMo, volumeUuid.toString(), dcMo);
vmMo.createDisk(volumeDatastorePath, (int)(volume.getSize() / (1024L * 1024L)), morDatastore, vmMo.getScsiDeviceControllerKey());
vmMo.detachDisk(volumeDatastorePath, false);
try {
vmMo.createDisk(volumeDatastorePath, (int)(volume.getSize() / (1024L * 1024L)), morDatastore, vmMo.getScsiDeviceControllerKey());
vmMo.detachDisk(volumeDatastorePath, false);
}
catch (Exception e) {
s_logger.error("Deleting file " + volumeDatastorePath + " due to error: " + e.getMessage());
VmwareStorageLayoutHelper.deleteVolumeVmdkFiles(dsMo, volumeUuid.toString(), dcMo);
throw new CloudRuntimeException("Unable to create volume due to: " + e.getMessage());
}
}
VolumeObjectTO newVol = new VolumeObjectTO();