CLOUDSTACK-7305: hypervisor type parameter is mandatory when deploying VM using ISO

Signed-off-by: Koushik Das <koushik@apache.org>
This commit is contained in:
Harikrishna Patnala 2014-08-11 18:05:33 +05:30 committed by Koushik Das
parent ae207bea98
commit 6568e0bb31
2 changed files with 4 additions and 1 deletions

View File

@ -129,7 +129,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
private String group;
@Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, description = "the hypervisor on which to deploy the virtual machine. "
+ "The parameter is respected only when hypervisor info is not set on the ISO/Template passed to the call")
+ "The parameter is required and respected only when hypervisor info is not set on the ISO/Template passed to the call")
private String hypervisor;
@Parameter(name = ApiConstants.USER_DATA, type = CommandType.STRING, description = "an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding. Using HTTP POST(via POST body), you can send up to 32K of data after base64 encoding.", length = 32768)

View File

@ -2718,6 +2718,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
HypervisorType hypervisorType = null;
if (template.getHypervisorType() == null || template.getHypervisorType() == HypervisorType.None) {
if (hypervisor == null || hypervisor == HypervisorType.None) {
throw new InvalidParameterValueException("hypervisor parameter is needed to deploy VM or the hypervisor parameter value passed is invalid");
}
hypervisorType = hypervisor;
} else {
if (hypervisor != null && hypervisor != HypervisorType.None && hypervisor != template.getHypervisorType()) {