From 067c1de080a8e3e4b9a088e470382b30172c258f Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Thu, 10 Mar 2022 09:33:50 -0300 Subject: [PATCH] Fix get upload params NPE (#6079) --- .../user/template/GetUploadParamsForTemplateCmd.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java index 6dbaddb4d4f..3a9e1c8b429 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java @@ -180,11 +180,12 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd { if (getZoneId() <= 0) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "invalid zoneid"); } - if (!hypervisor.equalsIgnoreCase(Hypervisor.HypervisorType.VMware.toString()) && osTypeId == null) { + if (!isDeployAsIs() && osTypeId == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Missing parameter ostypeid"); } - if (hypervisor.equalsIgnoreCase(Hypervisor.HypervisorType.VMware.toString()) && deployAsIs && osTypeId != null) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid parameter ostypeid, not applicable for VMware"); + if (isDeployAsIs() && osTypeId != null) { + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid parameter ostypeid, not applicable for" + + "VMware when deploy-as-is is set to true"); } }