GabrielBrascher commented on a change in pull request #3133: feature: add
libvirt / qemu io bursting
URL: https://github.com/apache/cloudstack/pull/3133#discussion_r248749646
##########
File path:
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
##########
@@ -2368,54 +2376,69 @@ protected ServiceOfferingVO
createServiceOffering(final long userId, final boole
limitResourceUse, volatileVm, displayText,
typedProvisioningType, localStorageRequired, false, tags, isSystem, vmType,
domainId, hostTag, deploymentPlanner);
- if (isCustomizedIops != null) {
- bytesReadRate = null;
- bytesWriteRate = null;
- iopsReadRate = null;
- iopsWriteRate = null;
-
- if (isCustomizedIops) {
+ if (Boolean.TRUE.equals(isCustomizedIops)) {
minIops = null;
maxIops = null;
+ } else {
+ if (minIops == null && maxIops == null) {
+ minIops = 0L;
+ maxIops = 0L;
} else {
- if (minIops == null && maxIops == null) {
- minIops = 0L;
- maxIops = 0L;
- } else {
- if (minIops == null || minIops <= 0) {
- throw new InvalidParameterValueException("The min IOPS
must be greater than 0.");
- }
+ if (minIops == null || minIops <= 0) {
+ throw new InvalidParameterValueException("The min IOPS
must be greater than 0.");
+ }
- if (maxIops == null) {
- maxIops = 0L;
- }
+ if (maxIops == null) {
+ maxIops = 0L;
+ }
- if (minIops > maxIops) {
- throw new InvalidParameterValueException("The min IOPS
must be less than or equal to the max IOPS.");
- }
+ if (minIops > maxIops) {
+ throw new InvalidParameterValueException("The min IOPS
must be less than or equal to the max IOPS.");
}
}
- } else {
- minIops = null;
- maxIops = null;
}
+
offering.setCustomizedIops(isCustomizedIops);
offering.setMinIops(minIops);
offering.setMaxIops(maxIops);
if (bytesReadRate != null && bytesReadRate > 0) {
offering.setBytesReadRate(bytesReadRate);
}
+ if (bytesReadRateMax != null && bytesReadRateMax > 0) {
Review comment:
I see some duplicated lines. Could you please extract the lines 2406 - 2441
into a method?
This method would work for setting the objects of `ServiceOfferingVO` and
`DiskOfferingVO`.
```
/**
* Documentation
*/
private void setIOpsOffering(DiskOfferingVO diskOffering) {
if (bytesReadRate != null && bytesReadRate > 0) {
diskOffering.setBytesReadRate(bytesReadRate);
}
if (bytesReadRateMax != null && bytesReadRateMax > 0) {
diskOffering.setBytesReadRateMax(bytesReadRateMax);
}
if (bytesReadRateMaxLength != null && bytesReadRateMaxLength > 0) {
diskOffering.setBytesReadRateMaxLength(bytesReadRateMaxLength);
}
if (bytesWriteRate != null && bytesWriteRate > 0) {
diskOffering.setBytesWriteRate(bytesWriteRate);
}
if (bytesWriteRateMax != null && bytesWriteRateMax > 0) {
diskOffering.setBytesWriteRateMax(bytesWriteRateMax);
}
if (bytesWriteRateMaxLength != null && bytesWriteRateMaxLength > 0) {
diskOffering.setBytesWriteRateMaxLength(bytesWriteRateMaxLength);
}
if (iopsReadRate != null && iopsReadRate > 0) {
diskOffering.setIopsReadRate(iopsReadRate);
}
if (iopsReadRateMax != null && iopsReadRateMax > 0) {
diskOffering.setIopsReadRateMax(iopsReadRateMax);
}
if (iopsReadRateMaxLength != null && iopsReadRateMaxLength > 0) {
diskOffering.setIopsReadRateMaxLength(iopsReadRateMaxLength);
}
if (iopsWriteRate != null && iopsWriteRate > 0) {
diskOffering.setIopsWriteRate(iopsWriteRate);
}
if (iopsWriteRateMax != null && iopsWriteRateMax > 0) {
diskOffering.setIopsWriteRateMax(iopsWriteRateMax);
}
if (iopsWriteRateMaxLength != null && iopsWriteRateMaxLength > 0) {
diskOffering.setIopsWriteRateMaxLength(iopsWriteRateMaxLength);
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services