From 34b24895eb2576f5e6b8b17368c091bd6ea28005 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Thu, 24 Nov 2011 10:33:11 -0800 Subject: [PATCH] bug 12176: fixed NPE in resource limit calculation for snapshots status 12176: resolved fixed --- .../src/com/cloud/storage/snapshot/SnapshotManagerImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 188915b8125..7381f52188f 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -96,6 +96,7 @@ import com.cloud.storage.swift.SwiftManager; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; +import com.cloud.user.DomainManager; import com.cloud.user.ResourceLimitService; import com.cloud.user.User; import com.cloud.user.UserContext; @@ -178,6 +179,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma private SecondaryStorageVmManager _ssvmMgr; @Inject private ResourceManager _resourceMgr; + @Inject + private DomainManager _domainMgr; String _name; private int _totalRetries; private int _pauseInterval; @@ -1191,7 +1194,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma // Verify that max doesn't exceed domain and account snapshot limits long accountLimit = _resourceLimitMgr.findCorrectResourceLimitForAccount(owner, ResourceType.snapshot); - long domainLimit = _resourceLimitMgr.findCorrectResourceLimitForDomain(null, ResourceType.snapshot); + long domainLimit = _resourceLimitMgr.findCorrectResourceLimitForDomain(_domainMgr.getDomain(owner.getDomainId()), ResourceType.snapshot); int max = cmd.getMaxSnaps().intValue(); if (owner.getType() != Account.ACCOUNT_TYPE_ADMIN && ((accountLimit != -1 && max > accountLimit) || (domainLimit != -1 && max > domainLimit))) { throw new InvalidParameterValueException("Max number of snapshots shouldn't exceed the domain/account level snapshot limit");