mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Don't update resource count for system account
This commit is contained in:
parent
de9856f1c4
commit
45c595d558
@ -2950,10 +2950,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
if (ip.getState() != State.Releasing) {
|
if (ip.getState() != State.Releasing) {
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
Account owner = _accountMgr.getAccount(ip.getAccountId());
|
|
||||||
|
|
||||||
// Save usage event
|
|
||||||
if (owner.getAccountId() != Account.ACCOUNT_ID_SYSTEM) {
|
|
||||||
// don't decrement resource count for direct ips
|
// don't decrement resource count for direct ips
|
||||||
if (ip.getAssociatedWithNetworkId() != null) {
|
if (ip.getAssociatedWithNetworkId() != null) {
|
||||||
_accountMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAccountId(), ResourceType.public_ip);
|
_accountMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAccountId(), ResourceType.public_ip);
|
||||||
@ -2961,6 +2957,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
|
|
||||||
long isSourceNat = (ip.isSourceNat()) ? 1 : 0;
|
long isSourceNat = (ip.isSourceNat()) ? 1 : 0;
|
||||||
|
|
||||||
|
// Save usage event
|
||||||
if (ip.getAccountId() != Account.ACCOUNT_ID_SYSTEM) {
|
if (ip.getAccountId() != Account.ACCOUNT_ID_SYSTEM) {
|
||||||
NetworkVO network = _networksDao.findByIdIncludingRemoved(ip.getSourceNetworkId());
|
NetworkVO network = _networksDao.findByIdIncludingRemoved(ip.getSourceNetworkId());
|
||||||
String guestType = "";
|
String guestType = "";
|
||||||
@ -2972,8 +2969,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
_usageEventDao.persist(usageEvent);
|
_usageEventDao.persist(usageEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ip = _ipAddressDao.markAsUnavailable(addrId);
|
ip = _ipAddressDao.markAsUnavailable(addrId);
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|||||||
@ -258,6 +258,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incrementResourceCount(long accountId, ResourceType type, Long... delta) {
|
public void incrementResourceCount(long accountId, ResourceType type, Long... delta) {
|
||||||
|
//don't upgrade resource count for system account
|
||||||
|
if (accountId == Account.ACCOUNT_ID_SYSTEM) {
|
||||||
|
s_logger.trace("Not incrementing resource count for system accounts, returning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
long numToIncrement = (delta.length == 0) ? 1 : delta[0].longValue();
|
long numToIncrement = (delta.length == 0) ? 1 : delta[0].longValue();
|
||||||
|
|
||||||
if (!updateResourceCount(accountId, type, true, numToIncrement)) {
|
if (!updateResourceCount(accountId, type, true, numToIncrement)) {
|
||||||
@ -268,6 +273,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decrementResourceCount(long accountId, ResourceType type, Long... delta) {
|
public void decrementResourceCount(long accountId, ResourceType type, Long... delta) {
|
||||||
|
//don't upgrade resource count for system account
|
||||||
|
if (accountId == Account.ACCOUNT_ID_SYSTEM) {
|
||||||
|
s_logger.trace("Not decrementing resource count for system accounts, returning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
long numToDecrement = (delta.length == 0) ? 1 : delta[0].longValue();
|
long numToDecrement = (delta.length == 0) ? 1 : delta[0].longValue();
|
||||||
|
|
||||||
if (!updateResourceCount(accountId, type, false, numToDecrement)) {
|
if (!updateResourceCount(accountId, type, false, numToDecrement)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user