Skip to content

Commit 84dcaf6

Browse files
StephanJoaoJandre
authored andcommitted
Use max secondary storage defined on the account during the upload of volume, template, and ISOs.
1 parent 981d748 commit 84dcaf6

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,12 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
486486
//using the existing max upload size configuration
487487
command.setProcessTimeout(NumbersUtil.parseLong(_configDao.getValue("vmware.package.ova.timeout"), 3600));
488488
command.setMaxUploadSize(_configDao.getValue(Config.MaxUploadVolumeSize.key()));
489-
command.setAccountId(vol.getAccountId());
490-
Account account = _accountDao.findById(vol.getAccountId());
491-
if (account.getType().equals(Account.Type.PROJECT)) {
492-
command.setDefaultMaxSecondaryStorageInGB(ResourceLimitService.MaxProjectSecondaryStorage.value());
493-
} else {
494-
command.setDefaultMaxSecondaryStorageInGB(ResourceLimitService.MaxAccountSecondaryStorage.value());
495-
}
489+
490+
Long accountId = vol.getAccountId();
491+
Account account = _accountDao.findById(accountId);
492+
493+
command.setDefaultMaxSecondaryStorageInGB(_resourceLimitMgr.findCorrectResourceLimitForAccount(account, ResourceType.secondary_storage));
494+
command.setAccountId(accountId);
496495
Gson gson = new GsonBuilder().create();
497496
String metadata = EncryptionUtil.encodeData(gson.toJson(command), key);
498497
response.setMetadata(metadata);

server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
import com.cloud.storage.download.DownloadMonitor;
9494
import com.cloud.template.VirtualMachineTemplate.State;
9595
import com.cloud.user.Account;
96-
import com.cloud.user.ResourceLimitService;
9796
import com.cloud.utils.Pair;
9897
import com.cloud.utils.UriUtils;
9998
import com.cloud.utils.db.DB;
@@ -402,13 +401,12 @@ public List<TemplateOrVolumePostUploadCommand> doInTransaction(TransactionStatus
402401
templateOnStore.getDataStore().getRole().toString());
403402
//using the existing max template size configuration
404403
payload.setMaxUploadSize(_configDao.getValue(Config.MaxTemplateAndIsoSize.key()));
405-
payload.setAccountId(template.getAccountId());
406-
Account account = _accountDao.findById(template.getAccountId());
407-
if (account.getType().equals(Account.Type.PROJECT)) {
408-
payload.setDefaultMaxSecondaryStorageInGB(ResourceLimitService.MaxProjectSecondaryStorage.value());
409-
} else {
410-
payload.setDefaultMaxSecondaryStorageInGB(ResourceLimitService.MaxAccountSecondaryStorage.value());
411-
}
404+
405+
Long accountId = template.getAccountId();
406+
Account account = _accountDao.findById(accountId);
407+
408+
payload.setDefaultMaxSecondaryStorageInGB(_resourceLimitMgr.findCorrectResourceLimitForAccount(account, ResourceType.secondary_storage));
409+
payload.setAccountId(accountId);
412410
payload.setRemoteEndPoint(ep.getPublicAddr());
413411
payload.setRequiresHvm(template.requiresHvm());
414412
payload.setDescription(template.getDisplayText());

0 commit comments

Comments
 (0)