sureshanaparti commented on a change in pull request #5428:
URL: https://github.com/apache/cloudstack/pull/5428#discussion_r710953967



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -2584,6 +2585,53 @@ protected void runInContext() {
         }
     }
 
+    private void verifyVmLimits(UserVmVO vmInstance, Map<String,String> 
details) {
+        if (VirtualMachineManager.ResoureCountRunningVMsonly.value()) {
+            return;
+        }
+
+        long newCpu = 
NumberUtils.toLong(details.get(VmDetailConstants.CPU_NUMBER));
+        long newMemory = 
NumberUtils.toLong(details.get(VmDetailConstants.MEMORY));
+        ServiceOfferingVO currentServiceOffering = 
_serviceOfferingDao.findByIdIncludingRemoved(vmInstance.getId(), 
vmInstance.getServiceOfferingId());
+        ServiceOfferingVO svcOffering = 
_serviceOfferingDao.findById(vmInstance.getServiceOfferingId());
+        boolean isDynamic = currentServiceOffering.isDynamic();
+        if (isDynamic) {
+            Map<String, String> customParameters = new HashMap<>();
+            customParameters.put(VmDetailConstants.CPU_NUMBER, 
String.valueOf(newCpu));
+            customParameters.put(VmDetailConstants.MEMORY, 
String.valueOf(newMemory));
+            validateCustomParameters(svcOffering, customParameters);
+        }
+        long currentCpu = currentServiceOffering.getCpu();
+        long currentMemory = currentServiceOffering.getRamSize();
+
+        Account owner = _accountDao.findById(vmInstance.getAccountId());
+        if (owner == null) {
+            throw new InvalidParameterValueException("The owner of " + 
vmInstance + " does not exist: " + vmInstance.getAccountId());

Review comment:
       can you move this check to the method beginning, this is the first check 
to be done before proceeding with verifying limits.




-- 
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]


Reply via email to