sureshanaparti commented on code in PR #10560:
URL: https://github.com/apache/cloudstack/pull/10560#discussion_r1998295605
##########
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) {
+ throw new InvalidParameterValueException("Invalid value given
for leaseduration, lesser than -1 is not supported ");
+ }
+
+ if (StringUtils.isEmpty(leaseExpiryAction)) {
+ bothValuesSet = false;
+ }
+ } else {
+ bothValuesSet = false;
+ }
+
+ if (!bothValuesSet) {
+ throw new InvalidParameterValueException("Provide values for both:
leaseduration and leaseexpiryaction");
Review Comment:
can pick any value from configuration if not specified? user will simply
enable lease for the instance.
--
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]