sureshanaparti commented on code in PR #10560:
URL: https://github.com/apache/cloudstack/pull/10560#discussion_r1998183115


##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -6251,9 +6267,115 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) 
throws InsufficientCapacityE
                 }
             }
         }
+
+        applyLeaseOnCreateInstance(vm, leaseDuration, leaseExpiryAction, 
svcOffering);
         return vm;
     }
 
+    protected void validateLeaseProperties(Long leaseDuration, String 
leaseExpiryAction) {
+        if (!VMLeaseManagerImpl.InstanceLeaseEnabled.value()
+                || (leaseDuration == null && 
StringUtils.isEmpty(leaseExpiryAction))) { // if both are null
+            return;
+        }
+
+        boolean bothValuesSet = true;
+        if (leaseDuration != null) {
+            if (leaseDuration == -1) {   // special condition used to disable 
lease for instance
+                return;
+            }
+            // both params have value
+            if (leaseDuration < -1) {

Review Comment:
   what if `leaseDuration` is 0, better consider zero or less than zero as 
lease disabled (update the cmd description if required).



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