@@ -654,15 +654,10 @@ private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vm
654654 }
655655
656656 // 4 MB is the minimum requirement for VM memory in VMware
657- vmMo .cloneFromCurrentSnapshot (workerVmName , 0 , 4 , volumeDeviceInfo .second (),
657+ Pair < VirtualMachineMO , String []> cloneResult = vmMo .cloneFromCurrentSnapshot (workerVmName , 0 , 4 , volumeDeviceInfo .second (),
658658 VmwareHelper .getDiskDeviceDatastore (volumeDeviceInfo .first ()));
659- clonedVm = vmMo .getRunningHost ().findVmOnHyperHost (workerVmName );
660- if (clonedVm == null ) {
661- String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath ;
662- s_logger .error (msg );
663- throw new Exception (msg );
664- }
665-
659+ clonedVm = cloneResult .first ();
660+
666661 clonedVm .exportVm (secondaryMountPoint + "/" + installPath , templateUniqueName , true , false );
667662
668663 long physicalSize = new File (installFullPath + "/" + templateUniqueName + ".ova" ).length ();
@@ -978,17 +973,12 @@ private Pair<String, String[]> exportVolumeToSecondaryStroage(VirtualMachineMO v
978973 }
979974
980975 // 4 MB is the minimum requirement for VM memory in VMware
981- String disks [] = vmMo .cloneFromCurrentSnapshot (workerVmName , 0 , 4 , volumeDeviceInfo .second (),
982- VmwareHelper .getDiskDeviceDatastore (volumeDeviceInfo .first ()));
983- clonedVm = vmMo .getRunningHost ().findVmOnHyperHost (workerVmName );
984- if (clonedVm == null ) {
985- String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath ;
986- s_logger .error (msg );
987- throw new Exception (msg );
988- }
976+ Pair <VirtualMachineMO , String []> cloneResult = vmMo .cloneFromCurrentSnapshot (workerVmName , 0 , 4 , volumeDeviceInfo .second (),
977+ VmwareHelper .getDiskDeviceDatastore (volumeDeviceInfo .first ()));
978+ clonedVm = cloneResult .first ();
979+ String disks [] = cloneResult .second ();
989980
990981 clonedVm .exportVm (exportPath , exportName , false , false );
991-
992982 return new Pair <String , String []>(volumeDeviceInfo .second (), disks );
993983 } finally {
994984 if (clonedVm != null ) {
0 commit comments