fix bug vmware create volume from snapshot will missing data

This commit is contained in:
hongtu_zang 2013-03-16 09:54:09 +08:00 committed by Chip Childers
parent ba69ce0c89
commit 13691048fb
1 changed files with 8 additions and 5 deletions

View File

@ -684,13 +684,16 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
String srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
+ backupName + "." + ImageFormat.OVA.getFileExtension();
String snapshotDir = "";
if (backupName.contains("/")){
snapshotDir = backupName.split("/")[0];
}
String srcFileName = getOVFFilePath(srcOVAFileName);
if(srcFileName == null) {
Script command = new Script("tar", 0, s_logger);
command.add("--no-same-owner");
command.add("-xf", srcOVAFileName);
command.setWorkDir(secondaryMountPoint + "/" + secStorageDir);
command.setWorkDir(secondaryMountPoint + "/" + secStorageDir + "/" + snapshotDir);
s_logger.info("Executing command: " + command.toString());
String result = command.execute();
if(result != null) {
@ -731,7 +734,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
String backupUuid = UUID.randomUUID().toString();
exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl,
getSnapshotRelativeDirInSecStorage(accountId, volumeId), backupUuid, workerVmName);
return backupUuid;
return backupUuid + "/" + backupUuid;
}
private void exportVolumeToSecondaryStroage(VirtualMachineMO vmMo, String volumePath,
@ -739,8 +742,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
String workerVmName) throws Exception {
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
String exportPath = secondaryMountPoint + "/" + secStorageDir;
String exportPath = secondaryMountPoint + "/" + secStorageDir + "/" + exportName;
synchronized(exportPath.intern()) {
if(!new File(exportPath).exists()) {
Script command = new Script(false, "mkdir", _timeout, s_logger);