mirror of https://github.com/apache/cloudstack.git
bug 8491: remove corresponding record from resource_limits table when limit is updated with -1 value
status 8491: resolved fixed
This commit is contained in:
parent
68b50d04b0
commit
ebdd7a68fa
|
|
@ -87,7 +87,7 @@ public class UpdateResourceLimitCmd extends BaseCmd {
|
|||
@Override
|
||||
public void execute(){
|
||||
ResourceLimit result = _accountService.updateResourceLimit(this);
|
||||
if (result != null){
|
||||
if (result != null || (result == null && max != null && max.longValue() == -1L)){
|
||||
ResourceLimitResponse response = _responseGenerator.createResourceLimitResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -645,10 +645,19 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
|
||||
List<ResourceLimitVO> limits = _resourceLimitDao.search(sc, searchFilter);
|
||||
if (limits.size() == 1) {
|
||||
// Update the existing limit
|
||||
ResourceLimitVO limit = limits.get(0);
|
||||
_resourceLimitDao.update(limit.getId(), max);
|
||||
return _resourceLimitDao.findById(limit.getId());
|
||||
//if limit is set to -1, remove the record
|
||||
if (max != null && max.longValue() == -1L) {
|
||||
//this parameter is needed by API as it expects the object to be returned and updates the UI with the object's new "max" parameter
|
||||
ResourceLimitVO limitToReturn = limit;
|
||||
limitToReturn.setMax(-1L);
|
||||
_resourceLimitDao.remove(limit.getId());
|
||||
return limitToReturn;
|
||||
} else {
|
||||
// Update the existing limit
|
||||
_resourceLimitDao.update(limit.getId(), max);
|
||||
return _resourceLimitDao.findById(limit.getId());
|
||||
}
|
||||
} else {
|
||||
// Persist the new Limit
|
||||
return _resourceLimitDao.persist(new ResourceLimitVO(domainId, accountId, resourceType, max));
|
||||
|
|
|
|||
Loading…
Reference in New Issue