bug 7158:

this is not a bug, the policy is not delete but in inactive status.
anyway, now the policy is delete,

status 7158: resolved fixed
This commit is contained in:
anthony 2010-11-12 18:00:49 -08:00
parent 0a4dbd91e1
commit bfed53ab3a
2 changed files with 15 additions and 16 deletions

View File

@ -1200,24 +1200,23 @@ public class SnapshotManagerImpl implements SnapshotManager {
@Override
public boolean deletePolicy(long userId, long policyId) {
SnapshotPolicyVO snapshotPolicy = _snapshotPolicyDao.findById(policyId);
VolumeVO volume = _volsDao.findById(snapshotPolicy.getVolumeId());
snapshotPolicy.setActive(false);
_snapSchedMgr.removeSchedule(snapshotPolicy.getVolumeId(), snapshotPolicy.getId());
EventVO event = new EventVO();
event.setAccountId(volume.getAccountId());
event.setUserId(userId);
event.setType(EventTypes.EVENT_SNAPSHOT_POLICY_DELETE);
boolean success = _snapshotPolicyDao.update(policyId, snapshotPolicy);
if(success){
try{
SnapshotPolicyVO snapshotPolicy = _snapshotPolicyDao.findById(policyId);
_snapshotPolicyDao.delete(policyId);
VolumeVO volume = _volsDao.findById(snapshotPolicy.getVolumeId());
_snapSchedMgr.removeSchedule(snapshotPolicy.getVolumeId(), snapshotPolicy.getId());
EventVO event = new EventVO();
event.setAccountId(volume.getAccountId());
event.setUserId(userId);
event.setType(EventTypes.EVENT_SNAPSHOT_POLICY_DELETE);
event.setLevel(EventVO.LEVEL_INFO);
event.setDescription("Successfully deleted snapshot policy with Id: "+policyId);
} else {
event.setLevel(EventVO.LEVEL_ERROR);
event.setDescription("Failed to delete snapshot policy with Id: "+policyId);
_eventDao.persist(event);
return true;
} catch (Exception e) {
s_logger.warn("Unable to delete policy: " + policyId + " due to " + e.toString(), e);
}
_eventDao.persist(event);
return success;
return false;
}
@Override

View File

@ -392,7 +392,7 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
for (SnapshotScheduleVO snapshotSchedule : snapshotSchedules) {
_snapshotScheduleDao.delete(snapshotSchedule.getId());
}
List<SnapshotPolicyVO> policyInstances = _snapshotPolicyDao.listAll();
List<SnapshotPolicyVO> policyInstances = _snapshotPolicyDao.listActivePolicies();
for (SnapshotPolicyVO policyInstance : policyInstances) {
if (policyInstance.getId() != Snapshot.MANUAL_POLICY_ID) {
scheduleNextSnapshotJob(policyInstance);