JoaoJandre commented on code in PR #7274:
URL: https://github.com/apache/cloudstack/pull/7274#discussion_r1154425755
##########
server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java:
##########
@@ -979,19 +990,66 @@ public long countCpusForAccount(long accountId) {
SearchCriteria<UserVmJoinVO> sc1 = userVmSearch.create();
sc1.setParameters("accountId", accountId);
if (VirtualMachineManager.ResourceCountRunningVMsonly.value())
- sc1.setParameters("state", new Object[] {State.Destroyed,
State.Error, State.Expunging, State.Stopped});
+ sc1.setParameters("state", State.Destroyed, State.Error,
State.Expunging, State.Stopped);
else
- sc1.setParameters("state", new Object[] {State.Destroyed,
State.Error, State.Expunging});
+ sc1.setParameters("state", State.Destroyed, State.Error,
State.Expunging);
sc1.setParameters("displayVm", 1);
List<UserVmJoinVO> userVms = _userVmJoinDao.search(sc1,null);
for (UserVmJoinVO vm : userVms) {
- cputotal += Long.valueOf(vm.getCpu());
+ cputotal += vm.getCpu();
+ }
+ ServiceOffering defaultRouterOffering = null;
+ String globalRouterOffering =
VirtualNetworkApplianceManager.VirtualRouterServiceOffering.value();
+ if (globalRouterOffering != null) {
+ defaultRouterOffering =
serviceOfferingDao.findByUuid(globalRouterOffering);
+ }
+ if (defaultRouterOffering == null) {
+ defaultRouterOffering =
serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+ }
Review Comment:
You implemented this method in `VirtualMachineManagerImpl`, therefore you
could use it instead of duplicating the code.
The `ResourceLimitManagerImpl` does not have a reference to
`VirtualMachineManagerImpl`, but the `VirtualMachineManagerImpl` has a
reference to `ResourceLimitManagerImpl`. You could move the method to this
class, and use it there. Or move it somewhere common to the two classes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]