diff --git a/api/src/com/cloud/api/commands/CreateSnapshotCmd.java b/api/src/com/cloud/api/commands/CreateSnapshotCmd.java index b04f6ed126c..c1ab23c18d9 100644 --- a/api/src/com/cloud/api/commands/CreateSnapshotCmd.java +++ b/api/src/com/cloud/api/commands/CreateSnapshotCmd.java @@ -120,13 +120,18 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd { @Override public void create(){ - long id = _snapshotService.getNextInSequence(this); + Long id = _snapshotService.getNextInSequence(this); this.setEntityId(id); } @Override public void execute(){ try { + if (this.getEntityId() == null) { + Long id = _snapshotService.getNextInSequence(this); + this.setEntityId(id); + } + Snapshot snapshot = _snapshotService.createSnapshot(this); if (snapshot != null) { SnapshotResponse response = _responseGenerator.createSnapshotResponse(snapshot); diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index ac2f40571b8..313b518e0ee 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -382,7 +382,9 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma throw new CloudRuntimeException("Creating snapshot failed due to " + e.toString()); } finally { // Cleanup jobs to do after the snapshot has been created. - postCreateSnapshot(volumeId, snapshotId, policyId, backedUp); + if( snapshotId != null) { + postCreateSnapshot(volumeId, snapshotId, policyId, backedUp); + } _volsDao.releaseFromLockTable(volumeId); } diff --git a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java index d6f7bf7410d..a7f39858a69 100644 --- a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java @@ -223,6 +223,9 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler { Map params = new HashMap(); params.put("volumeid", ""+volumeId); params.put("policyid", ""+policyId); + params.put("ctxUserId", "1"); + params.put("ctxAccountId", "1"); + AsyncJobVO job = new AsyncJobVO(); job.setUserId(userId); // Just have SYSTEM own the job for now. Users won't be able to see this job, but