From 149f6c05147a07abe845b53ed4d9bc159b68b0ff Mon Sep 17 00:00:00 2001 From: Anshul Gangwar Date: Wed, 23 Dec 2015 12:12:44 +0530 Subject: [PATCH] CLOUDSTACK-9199: Fixed deployVirtualMachine API does not throw an error when cpunumber is specified for static compute offering --- .../cloudstack/api/command/user/vm/DeployVMCmd.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java index 82c281dad46..cfd26275858 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java @@ -553,6 +553,14 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId); } + if(!serviceOffering.isDynamic()) { + for(String detail: getDetails().keySet()) { + if(detail.equalsIgnoreCase("cpuNumber") || detail.equalsIgnoreCase("cpuSpeed") || detail.equalsIgnoreCase("memory")) { + throw new InvalidParameterValueException("cpuNumber or cpuSpeed or memory should not be specified for static service offering"); + } + } + } + VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, templateId); // Make sure a valid template ID was specified if (template == null) {