Updated Branches: refs/heads/4.1 06e7fc111 -> e942df93e
CLOUDSTACK-1541 NPE while deleting snapshots Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/e942df93 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/e942df93 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/e942df93 Branch: refs/heads/4.1 Commit: e942df93e6915d103f80efa014295d040fb23ba6 Parents: 06e7fc1 Author: Deepti Dohare <[email protected]> Authored: Thu Mar 7 18:26:39 2013 +0530 Committer: Chip Childers <[email protected]> Committed: Thu Mar 7 14:13:48 2013 -0500 ---------------------------------------------------------------------- .../agent/api/DeleteSnapshotBackupCommand.java | 6 ++++-- .../storage/snapshot/SnapshotManagerImpl.java | 15 +++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e942df93/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java b/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java index 6114148..128df84 100644 --- a/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java +++ b/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java @@ -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); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e942df93/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index c7beff0..b0d63d6 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -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);
