Fix get upload params NPE (#6079)

This commit is contained in:
Nicolas Vazquez 2022-03-10 09:33:50 -03:00 committed by GitHub
parent 3a456f1b31
commit 067c1de080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -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");
}
}