Skip to content

Commit 8daad16

Browse files
apply suggestion
1 parent 7cb7042 commit 8daad16

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,11 @@ public VMSnapshot allocVMSnapshot(Long vmId, String vsDisplayName, String vsDesc
400400
_accountMgr.checkAccess(caller, null, true, userVmVo);
401401

402402
// check max snapshot limit for per VM
403-
int vmSnapshotMax = VMSnapshotManager.VMSnapshotMax.valueIn(userVmVo.getAccountId());
404-
403+
boolean vmBelongsToProject = _accountMgr.getAccount(userVmVo.getAccountId()).getType() == Account.Type.PROJECT;
404+
long accountIdToRetrieveConfigurationValueFrom = vmBelongsToProject ? caller.getId() : userVmVo.getAccountId();
405+
int vmSnapshotMax = VMSnapshotManager.VMSnapshotMax.valueIn(accountIdToRetrieveConfigurationValueFrom);
405406
if (_vmSnapshotDao.findByVm(vmId).size() >= vmSnapshotMax) {
406-
throw new CloudRuntimeException("Creating vm snapshot failed due to a VM can just have : " + vmSnapshotMax + " VM snapshots. Please delete old ones");
407+
throw new CloudRuntimeException(String.format("Each VM can have at most [%s] VM snapshots.", vmSnapshotMax));
407408
}
408409

409410
// check if there are active volume snapshots tasks

0 commit comments

Comments
 (0)