Skip to content

Commit 94f9f89

Browse files
authored
server: Fix some cpuspeed issues while create service offering (#4376)
1 parent 9391fa9 commit 94f9f89

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,12 +2319,12 @@ public ServiceOffering createServiceOffering(final CreateServiceOfferingCmd cmd)
23192319
throw new InvalidParameterValueException("For creating a custom compute offering cpu and memory all should be null");
23202320
}
23212321
// if any of them is null, then all of them shoull be null
2322-
if (maxCPU == null || minCPU == null || maxMemory == null || minMemory == null) {
2323-
if (maxCPU != null || minCPU != null || maxMemory != null || minMemory != null) {
2324-
throw new InvalidParameterValueException("For creating a custom compute offering min/max cpu and min/max memory should all be specified");
2322+
if (maxCPU == null || minCPU == null || maxMemory == null || minMemory == null || cpuSpeed == null) {
2323+
if (maxCPU != null || minCPU != null || maxMemory != null || minMemory != null || cpuSpeed != null) {
2324+
throw new InvalidParameterValueException("For creating a custom compute offering min/max cpu and min/max memory/cpu speed should all be null or all specified");
23252325
}
23262326
} else {
2327-
if (cpuSpeed != null && (cpuSpeed.intValue() < 0 || cpuSpeed.longValue() > Integer.MAX_VALUE)) {
2327+
if (cpuSpeed.intValue() < 0 || cpuSpeed.longValue() > Integer.MAX_VALUE) {
23282328
throw new InvalidParameterValueException("Failed to create service offering " + offeringName + ": specify the cpu speed value between 1 and " + Integer.MAX_VALUE);
23292329
}
23302330
if ((maxCPU <= 0 || maxCPU.longValue() > Integer.MAX_VALUE) || (minCPU <= 0 || minCPU.longValue() > Integer.MAX_VALUE ) ) {
@@ -2343,7 +2343,7 @@ public ServiceOffering createServiceOffering(final CreateServiceOfferingCmd cmd)
23432343
if (cpuNumber != null && (cpuNumber.intValue() <= 0 || cpuNumber.longValue() > Integer.MAX_VALUE)) {
23442344
throw new InvalidParameterValueException("Failed to create service offering " + offeringName + ": specify the cpu number value between 1 and " + Integer.MAX_VALUE);
23452345
}
2346-
if (cpuSpeed != null && (cpuSpeed.intValue() < 0 || cpuSpeed.longValue() > Integer.MAX_VALUE)) {
2346+
if (cpuSpeed == null || (cpuSpeed.intValue() < 0 || cpuSpeed.longValue() > Integer.MAX_VALUE)) {
23472347
throw new InvalidParameterValueException("Failed to create service offering " + offeringName + ": specify the cpu speed value between 0 and " + Integer.MAX_VALUE);
23482348
}
23492349
if (memory != null && (memory.intValue() < 32 || memory.longValue() > Integer.MAX_VALUE)) {

0 commit comments

Comments
 (0)