CLOUDSTACK-4106: fix volume related operations on vmware&s3

This commit is contained in:
Edison Su 2013-08-08 12:34:24 -07:00
parent 6999fca4d7
commit 784a9d45d0
3 changed files with 25 additions and 19 deletions

View File

@ -437,19 +437,18 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
EndPoint ep = selector.select(srcData, destData);
answer = ep.sendMessage(cmd);
}
// clean up cache entry in case of failure
if (answer == null || !answer.getResult()) {
if (cacheData != null) {
cacheMgr.deleteCacheObject(cacheData);
}
}
return answer;
} catch (Exception e) {
s_logger.debug("copy snasphot failed: " + e.toString());
if (cacheData != null) {
cacheMgr.deleteCacheObject(cacheData);
}
throw new CloudRuntimeException(e.toString());
return answer;
} catch (Exception e) {
s_logger.debug("copy snasphot failed: ", e);
if (cacheData != null) {
cacheMgr.deleteCacheObject(cacheData);
}
throw new CloudRuntimeException(e);
}
}

View File

@ -1040,13 +1040,16 @@ public class VmwareStorageProcessor implements StorageProcessor {
morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStore.getUuid());
try {
vmMo = hyperHost.findVmOnHyperHost(vmName);
if (vmName != null) {
vmMo = hyperHost.findVmOnHyperHost(vmName);
}
if (vmMo == null) {
if(s_logger.isDebugEnabled()) {
s_logger.debug("Unable to find owner VM for BackupSnapshotCommand on host " + hyperHost.getHyperHostName() + ", will try within datacenter");
}
vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
if (vmName != null) {
vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
}
if(vmMo == null) {
dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
@ -1489,17 +1492,21 @@ public class VmwareStorageProcessor implements StorageProcessor {
String secondaryMountPoint = mountService.getMountPoint(secStorageUrl);
String srcOVAFileName = null;
String srcOVFFileName = null;
srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
if (backupName.endsWith(".ova")) {
srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
+ backupName;
srcOVFFileName = secondaryMountPoint + "/" + secStorageDir + "/"
+ backupName.replace(".ova", ".ovf");
} else {
srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
+ backupName + "." + ImageFormat.OVA.getFileExtension();
srcOVFFileName = secondaryMountPoint + "/" + secStorageDir + "/"
srcOVFFileName = secondaryMountPoint + "/" + secStorageDir + "/"
+ backupName + ".ovf";
}
String snapshotDir = "";
if (backupName.contains("/")){
snapshotDir = backupName.split("/")[0];
}
File ovafile = new File(srcOVAFileName);
File ovfFile = new File(srcOVFFileName);

View File

@ -1386,7 +1386,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
//getting the prent volume
long parentVolumeId=_snapshotDao.findById(snapshotId).getVolumeId();
VolumeVO parentVolume = _volumeDao.findById(parentVolumeId);
if (parentVolume.getIsoId() != null) {
if (parentVolume != null && parentVolume.getIsoId() != null) {
privateTemplate.setSourceTemplateId(parentVolume.getIsoId());
_tmpltDao.update(privateTemplate.getId(), privateTemplate);
}