diff --git a/api/src/com/cloud/api/commands/CreateSnapshotCmd.java b/api/src/com/cloud/api/commands/CreateSnapshotCmd.java old mode 100644 new mode 100755 index 1507d5fa770..fdae2afbdaf --- a/api/src/com/cloud/api/commands/CreateSnapshotCmd.java +++ b/api/src/com/cloud/api/commands/CreateSnapshotCmd.java @@ -53,7 +53,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd { @Parameter(name=ApiConstants.VOLUME_ID, type=CommandType.LONG, required=true, description="The ID of the disk volume") private Long volumeId; - @Parameter(name=ApiConstants.POLICY_ID, type=CommandType.LONG, description="polocy id of the snapshot, if this is null, then use MANUAL_POLICY.") + @Parameter(name=ApiConstants.POLICY_ID, type=CommandType.LONG, description="policy id of the snapshot, if this is null, then use MANUAL_POLICY.") private Long policyId; ///////////////////////////////////////////////////// diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 6ad35a2f824..caa1c0f614c 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -234,7 +234,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma } @Override - public SnapshotVO createSnapshotOnPrimary(VolumeVO volume, Long policyId, Long snapshotId) throws ResourceAllocationException { + public SnapshotVO createSnapshotOnPrimary(VolumeVO volume, Long policyId, Long snapshotId) { SnapshotVO snapshot = _snapshotDao.findById(snapshotId); if ( snapshot == null ) { throw new CloudRuntimeException("Can not find snapshot " + snapshotId); @@ -323,6 +323,13 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma @Override @DB public SnapshotVO createSnapshotImpl(Long volumeId, Long policyId, Long snapshotId) throws ResourceAllocationException { VolumeVO v = _volsDao.findById(volumeId); + AccountVO account = _accountDao.findById(v.getAccountId()); + if (_accountMgr.resourceLimitExceeded(account, ResourceType.snapshot)) { + ResourceAllocationException rae = new ResourceAllocationException("Maximum number of snapshots for account: " + account.getAccountName() + " has been exceeded."); + rae.setResourceType("snapshot"); + throw rae; + } + if ( v != null && _volsDao.getHypervisorType(v.getId()).equals(HypervisorType.KVM)) { /*KVM needs to lock on the vm of volume, because it takes snapshot on behalf of vm, not volume*/ UserVmVO uservm = _vmDao.findById(v.getInstanceId());