Skip to content

Commit b59ef2d

Browse files
StephanJoaoJandre
authored andcommitted
Use max secondary storage defined on the account during the upload of volume, template, and ISOs.
1 parent 941cc83 commit b59ef2d

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
@@ -477,13 +477,12 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
477477
//using the existing max upload size configuration
478478
command.setProcessTimeout(NumbersUtil.parseLong(_configDao.getValue("vmware.package.ova.timeout"), 3600));
479479
command.setMaxUploadSize(_configDao.getValue(Config.MaxUploadVolumeSize.key()));
480-
command.setAccountId(vol.getAccountId());
481-
Account account = _accountDao.findById(vol.getAccountId());
482-
if (account.getType().equals(Account.Type.PROJECT)) {
483-
command.setDefaultMaxSecondaryStorageInGB(ResourceLimitService.MaxProjectSecondaryStorage.value());
484-
} else {
485-
command.setDefaultMaxSecondaryStorageInGB(ResourceLimitService.MaxAccountSecondaryStorage.value());
486-
}
480+
481+
Long accountId = vol.getAccountId();
482+
Account account = _accountDao.findById(accountId);
483+
484+
command.setDefaultMaxSecondaryStorageInGB(_resourceLimitMgr.findCorrectResourceLimitForAccount(account, ResourceType.secondary_storage));
485+
command.setAccountId(accountId);
487486
Gson gson = new GsonBuilder().create();
488487
String metadata = EncryptionUtil.encodeData(gson.toJson(command), key);
489488
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;
@@ -399,13 +398,12 @@ public List<TemplateOrVolumePostUploadCommand> doInTransaction(TransactionStatus
399398
templateOnStore.getDataStore().getRole().toString());
400399
//using the existing max template size configuration
401400
payload.setMaxUploadSize(_configDao.getValue(Config.MaxTemplateAndIsoSize.key()));
402-
payload.setAccountId(template.getAccountId());
403-
Account account = _accountDao.findById(template.getAccountId());
404-
if (account.getType().equals(Account.Type.PROJECT)) {
405-
payload.setDefaultMaxSecondaryStorageInGB(ResourceLimitService.MaxProjectSecondaryStorage.value());
406-
} else {
407-
payload.setDefaultMaxSecondaryStorageInGB(ResourceLimitService.MaxAccountSecondaryStorage.value());
408-
}
401+
402+
Long accountId = template.getAccountId();
403+
Account account = _accountDao.findById(accountId);
404+
405+
payload.setDefaultMaxSecondaryStorageInGB(_resourceLimitMgr.findCorrectResourceLimitForAccount(account, ResourceType.secondary_storage));
406+
payload.setAccountId(accountId);
409407
payload.setRemoteEndPoint(ep.getPublicAddr());
410408
payload.setRequiresHvm(template.requiresHvm());
411409
payload.setDescription(template.getDisplayText());

0 commit comments

Comments
 (0)