Skip to content

Commit 784a9d4

Browse files
committed
CLOUDSTACK-4106: fix volume related operations on vmware&s3
1 parent 6999fca commit 784a9d4

3 files changed

Lines changed: 22 additions & 16 deletions

File tree

‎engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,19 +437,18 @@ protected Answer copySnapshot(DataObject srcData, DataObject destData) {
437437
EndPoint ep = selector.select(srcData, destData);
438438
answer = ep.sendMessage(cmd);
439439
}
440-
// clean up cache entry in case of failure
441-
if (answer == null || !answer.getResult()) {
442-
if (cacheData != null) {
443-
cacheMgr.deleteCacheObject(cacheData);
444-
}
440+
441+
if (cacheData != null) {
442+
cacheMgr.deleteCacheObject(cacheData);
445443
}
444+
446445
return answer;
447446
} catch (Exception e) {
448-
s_logger.debug("copy snasphot failed: " + e.toString());
447+
s_logger.debug("copy snasphot failed: ", e);
449448
if (cacheData != null) {
450449
cacheMgr.deleteCacheObject(cacheData);
451450
}
452-
throw new CloudRuntimeException(e.toString());
451+
throw new CloudRuntimeException(e);
453452
}
454453

455454
}

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,13 +1040,16 @@ public Answer backupSnapshot(CopyCommand cmd) {
10401040
morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStore.getUuid());
10411041

10421042
try {
1043-
vmMo = hyperHost.findVmOnHyperHost(vmName);
1043+
if (vmName != null) {
1044+
vmMo = hyperHost.findVmOnHyperHost(vmName);
1045+
}
10441046
if (vmMo == null) {
10451047
if(s_logger.isDebugEnabled()) {
10461048
s_logger.debug("Unable to find owner VM for BackupSnapshotCommand on host " + hyperHost.getHyperHostName() + ", will try within datacenter");
10471049
}
1048-
1049-
vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
1050+
if (vmName != null) {
1051+
vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
1052+
}
10501053
if(vmMo == null) {
10511054
dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
10521055

@@ -1489,17 +1492,21 @@ private Long restoreVolumeFromSecStorage(VmwareHypervisorHost hyperHost, Datasto
14891492
String secondaryMountPoint = mountService.getMountPoint(secStorageUrl);
14901493
String srcOVAFileName = null;
14911494
String srcOVFFileName = null;
1492-
1493-
srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
1495+
if (backupName.endsWith(".ova")) {
1496+
srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
1497+
+ backupName;
1498+
srcOVFFileName = secondaryMountPoint + "/" + secStorageDir + "/"
1499+
+ backupName.replace(".ova", ".ovf");
1500+
} else {
1501+
srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
14941502
+ backupName + "." + ImageFormat.OVA.getFileExtension();
1495-
srcOVFFileName = secondaryMountPoint + "/" + secStorageDir + "/"
1503+
srcOVFFileName = secondaryMountPoint + "/" + secStorageDir + "/"
14961504
+ backupName + ".ovf";
1497-
1505+
}
14981506
String snapshotDir = "";
14991507
if (backupName.contains("/")){
15001508
snapshotDir = backupName.split("/")[0];
15011509
}
1502-
15031510
File ovafile = new File(srcOVAFileName);
15041511

15051512
File ovfFile = new File(srcOVFFileName);

‎server/src/com/cloud/template/TemplateManagerImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) t
13861386
//getting the prent volume
13871387
long parentVolumeId=_snapshotDao.findById(snapshotId).getVolumeId();
13881388
VolumeVO parentVolume = _volumeDao.findById(parentVolumeId);
1389-
if (parentVolume.getIsoId() != null) {
1389+
if (parentVolume != null && parentVolume.getIsoId() != null) {
13901390
privateTemplate.setSourceTemplateId(parentVolume.getIsoId());
13911391
_tmpltDao.update(privateTemplate.getId(), privateTemplate);
13921392
}

0 commit comments

Comments
 (0)