From 1f7a818440b40659be8882e2d52a043d099940e0 Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Wed, 2 Jul 2014 13:12:49 -0700 Subject: [PATCH] CLOUDSTACK-7000: Fix bugs in ListSnapshotPolicy and updateSnapshotPolicy command (cherry picked from commit 63c4f028971f80a9dfa32125a3eed71468209497) --- .../com/cloud/storage/snapshot/SnapshotManagerImpl.java | 7 +++++-- .../com/cloud/storage/snapshot/SnapshotSchedulerImpl.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 11362e4f8c7..5c114c518b8 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -281,8 +281,11 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager, Boolean display = cmd.getDisplay(); SnapshotPolicyVO policyVO = _snapshotPolicyDao.findById(id); - if(display != null) + if(display != null){ + boolean previousDisplay = policyVO.isDisplay(); policyVO.setDisplay(display); + _snapSchedMgr.scheduleOrCancelNextSnapshotJobOnDisplayChange(policyVO, previousDisplay); + } if(customUUID != null) policyVO.setUuid(customUUID); @@ -752,7 +755,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager, result = _snapshotPolicyDao.listAndCountById(id, display, null); if(result != null && result.first() != null && !result.first().isEmpty()){ SnapshotPolicyVO snapshotPolicy = result.first().get(0); - volumeId = snapshotPolicy.getId(); + volumeId = snapshotPolicy.getVolumeId(); } } VolumeVO volume = _volsDao.findById(volumeId); diff --git a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java index b11d27b1bbd..ba3d63a55fa 100644 --- a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java @@ -305,9 +305,10 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu return null; } - // If display attribute is false then remove schedules if any. + // If display attribute is false then remove schedules if any and return. if(!policy.isDisplay()){ removeSchedule(policy.getVolumeId(), policy.getId()); + return null; } final long policyId = policy.getId();