mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-1541 NPE while deleting snapshots
This commit is contained in:
parent
06e7fc1117
commit
e942df93e6
|
|
@ -19,6 +19,7 @@ package com.cloud.agent.api;
|
|||
import com.cloud.agent.api.LogLevel.Log4jLevel;
|
||||
import com.cloud.agent.api.to.S3TO;
|
||||
import com.cloud.agent.api.to.SwiftTO;
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
||||
/**
|
||||
* This command encapsulates a primitive operation which enables coalescing the backed up VHD snapshots on the secondary server
|
||||
|
|
@ -78,7 +79,8 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand {
|
|||
* @param backupUUID The VHD which has to be deleted
|
||||
* @param childUUID The child VHD file of the backup whose parent is reset to its grandparent.
|
||||
*/
|
||||
public DeleteSnapshotBackupCommand(SwiftTO swift,
|
||||
public DeleteSnapshotBackupCommand(StoragePool pool,
|
||||
SwiftTO swift,
|
||||
S3TO s3,
|
||||
String secondaryStoragePoolURL,
|
||||
Long dcId,
|
||||
|
|
@ -86,7 +88,7 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand {
|
|||
Long volumeId,
|
||||
String backupUUID, Boolean all)
|
||||
{
|
||||
super(null, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
|
||||
super(pool, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
|
||||
setSwift(swift);
|
||||
this.s3 = s3;
|
||||
setAll(all);
|
||||
|
|
|
|||
|
|
@ -482,11 +482,13 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
public void deleteSnapshotsForVolume (String secondaryStoragePoolUrl, Long dcId, Long accountId, Long volumeId ){
|
||||
SwiftTO swift = _swiftMgr.getSwiftTO();
|
||||
S3TO s3 = _s3Mgr.getS3TO();
|
||||
VolumeVO volume = _volumeDao.findById(volumeId);
|
||||
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
|
||||
|
||||
checkObjectStorageConfiguration(swift, s3);
|
||||
|
||||
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
|
||||
swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
|
||||
pool, swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
|
||||
null, true);
|
||||
try {
|
||||
Answer ans = _agentMgr.sendToSSVM(dcId, cmd);
|
||||
|
|
@ -909,8 +911,11 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
|
||||
checkObjectStorageConfiguration(swift, s3);
|
||||
|
||||
VolumeVO volume = _volumeDao.findById(volumeId);
|
||||
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
|
||||
|
||||
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
|
||||
swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
|
||||
pool, swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
|
||||
backupOfSnapshot, false);
|
||||
Answer answer = _agentMgr.sendToSSVM(dcId, cmd);
|
||||
|
||||
|
|
@ -1062,10 +1067,12 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
|
||||
checkObjectStorageConfiguration(swift, s3);
|
||||
|
||||
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
|
||||
|
||||
if (swift == null && s3 == null) {
|
||||
for (HostVO ssHost : ssHosts) {
|
||||
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
|
||||
null, null, ssHost.getStorageUrl(), dcId,
|
||||
pool, null, null, ssHost.getStorageUrl(), dcId,
|
||||
accountId, volumeId, "", true);
|
||||
Answer answer = null;
|
||||
try {
|
||||
|
|
@ -1084,7 +1091,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
}
|
||||
} else {
|
||||
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
|
||||
swift, s3, "", dcId, accountId, volumeId, "", true);
|
||||
pool, swift, s3, "", dcId, accountId, volumeId, "", true);
|
||||
Answer answer = null;
|
||||
try {
|
||||
answer = _agentMgr.sendToSSVM(dcId, cmd);
|
||||
|
|
|
|||
Loading…
Reference in New Issue