Throwing error if boot type or boot mode specified while deploying VMs on VMware

This commit is contained in:
davidjumani 2020-10-16 18:09:38 +05:30 committed by Harikrishna Patnala
parent 38e119a099
commit 6b715ecb53
2 changed files with 7 additions and 4 deletions

View File

@ -116,10 +116,10 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
@Parameter(name = ApiConstants.NETWORK_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = NetworkResponse.class, description = "list of network ids used by virtual machine. Can't be specified with ipToNetworkList parameter")
private List<Long> networkIds;
@Parameter(name = ApiConstants.BOOT_TYPE, type = CommandType.STRING, required = false, description = "Guest VM Boot option either custom[UEFI] or default boot [BIOS]", since = "4.14.0.0")
@Parameter(name = ApiConstants.BOOT_TYPE, type = CommandType.STRING, required = false, description = "Guest VM Boot option either custom[UEFI] or default boot [BIOS]. Not applicable with VMware, as we honour what is defined in the template.", since = "4.14.0.0")
private String bootType;
@Parameter(name = ApiConstants.BOOT_MODE, type = CommandType.STRING, required = false, description = "Boot Mode [Legacy] or [Secure] Applicable when Boot Type Selected is UEFI, otherwise Legacy By default for BIOS", since = "4.14.0.0")
@Parameter(name = ApiConstants.BOOT_MODE, type = CommandType.STRING, required = false, description = "Boot Mode [Legacy] or [Secure] Applicable when Boot Type Selected is UEFI, otherwise Legacy only for BIOS. Not applicable with VMware, as we honour what is defined in the template.", since = "4.14.0.0")
private String bootMode;
@Parameter(name = ApiConstants.BOOT_INTO_SETUP, type = CommandType.BOOLEAN, required = false, description = "Boot into hardware setup or not (ignored if startVm = false, only valid for vmware)", since = "4.15.0.0")
@ -265,8 +265,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
return domainId;
}
private ApiConstants.BootType getBootType() {
public ApiConstants.BootType getBootType() {
if (StringUtils.isNotBlank(bootType)) {
try {
String type = bootType.trim().toUpperCase();

View File

@ -5184,6 +5184,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (template == null) {
throw new InvalidParameterValueException("Unable to use template " + templateId);
}
// Bootmode and boottype are not supported on VMWare
if (template.getHypervisorType() == HypervisorType.VMware && (cmd.getBootMode() != null || cmd.getBootType() != null)) {
throw new InvalidParameterValueException("Boot type and boot mode are not supported on VMware, as we honour what is defined in the template.");
}
Long diskOfferingId = cmd.getDiskOfferingId();
DiskOffering diskOffering = null;