Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
UEFI Support on CloudStack#3638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -17,6 +17,7 @@ | ||
| package org.apache.cloudstack.api.command.user.vm; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.HashMap; | ||
| import java.util.Iterator; | ||
| @@ -26,6 +27,8 @@ | ||
| import javax.annotation.Nonnull; | ||
| import com.cloud.utils.StringUtils; | ||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.affinity.AffinityGroupResponse; | ||
| import org.apache.cloudstack.api.ACL; | ||
| @@ -110,6 +113,12 @@ 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]") | ||
| 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") | ||
| private String bootMode; | ||
| //DataDisk information | ||
| @ACL | ||
| @Parameter(name = ApiConstants.DISK_OFFERING_ID, type = CommandType.UUID, entityType = DiskOfferingResponse.class, description = "the ID of the disk offering for the virtual machine. If the template is of ISO format," | ||
| @@ -244,6 +253,22 @@ public Long getDomainId() { | ||
| return domainId; | ||
| } | ||
| private ApiConstants.BootType getBootType() { | ||
| if (StringUtils.isNotBlank(bootType)) { | ||
| try { | ||
| String type = bootType.trim().toUpperCase(); | ||
| return ApiConstants.BootType.valueOf(type); | ||
| } catch (IllegalArgumentException e) { | ||
| String errMesg = "Invalid bootType " + bootType + "Specified for vm " + getName() | ||
| + " Valid values are: " + Arrays.toString(ApiConstants.BootType.values()); | ||
| s_logger.warn(errMesg); | ||
| throw new InvalidParameterValueException(errMesg); | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| public Map<String, String> getDetails() { | ||
| Map<String, String> customparameterMap = new HashMap<String, String>(); | ||
| if (details != null && details.size() != 0) { | ||
| @@ -256,12 +281,35 @@ public Map<String, String> getDetails() { | ||
| } | ||
| } | ||
| } | ||
| if(getBootType() != null){ // export to get | ||
| if(getBootType() == ApiConstants.BootType.UEFI) { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavanaravapalli cc @DaanHoogland@andrijapanicsb | ||
| customparameterMap.put(getBootType().toString(), getBootMode().toString()); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavanaravapalli cc @DaanHoogland@andrijapanicsb | ||
| } | ||
| } | ||
Comment on lines
+284
to
+288
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please extract to a method with a clear descriptive name? i.e. handleBootType(Map<String, String> customparameterMap) | ||
| if (rootdisksize != null && !customparameterMap.containsKey("rootdisksize")) { | ||
| customparameterMap.put("rootdisksize", rootdisksize.toString()); | ||
| } | ||
| return customparameterMap; | ||
| } | ||
| public ApiConstants.BootMode getBootMode() { | ||
| if (StringUtils.isNotBlank(bootMode)) { | ||
| try { | ||
| String mode = bootMode.trim().toUpperCase(); | ||
| return ApiConstants.BootMode.valueOf(mode); | ||
| } catch (IllegalArgumentException e) { | ||
| String errMesg = "Invalid bootMode " + bootMode + "Specified for vm " + getName() | ||
| + " Valid values are: "+ Arrays.toString(ApiConstants.BootMode.values()); | ||
| s_logger.warn(errMesg); | ||
| throw new InvalidParameterValueException(errMesg); | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| public Map<String, String> getVmOVFProperties() { | ||
| Map<String, String> map = new HashMap<>(); | ||
| if (MapUtils.isNotEmpty(vmOvfProperties)) { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -244,6 +244,10 @@ public class HostResponse extends BaseResponse { | ||
| @Param(description = "the admin that annotated this host", since = "4.11") | ||
| private String username; | ||
| @SerializedName("ueficapability") | ||
| @Param(description = "true if the host has capability to support UEFI boot") | ||
| private Boolean uefiCapabilty; | ||
| @Override | ||
| public String getObjectId() { | ||
| return this.getId(); | ||
| @@ -499,6 +503,14 @@ public void setDetails(Map details) { | ||
| detailsCopy.remove("username"); | ||
| detailsCopy.remove("password"); | ||
| if(detailsCopy.containsKey(Host.HOST_UEFI_ENABLE)) { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavanaravapalli space between | ||
| this.setUefiCapabilty(Boolean.parseBoolean((String) detailsCopy.get(Host.HOST_UEFI_ENABLE))); | ||
| detailsCopy.remove(Host.HOST_UEFI_ENABLE); | ||
| } else { | ||
| this.setUefiCapabilty(new Boolean(false)); // in case of existing host which is not scanned for UEFI capability | ||
pavanaravapalli marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
Comment on lines
+506
to
+511
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please extract to a method. i.e. determineUefiCapability() | ||
| this.details = detailsCopy; | ||
| } | ||
| @@ -668,4 +680,8 @@ public String getHypervisorVersion() { | ||
| public Boolean getHaHost() { | ||
| return haHost; | ||
| } | ||
| public void setUefiCapabilty(Boolean hostCapability) { | ||
| this.uefiCapabilty = hostCapability; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1064,6 +1064,10 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil | ||
| } | ||
| final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, template, offering, owner, params); | ||
| s_logger.info(" Uefi params " + "UefiFlag: " + params.get(VirtualMachineProfile.Param.UefiFlag) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this potentially cause any exception? Should this be only logged when custom params are passed; otherwise it may always log as null/null confuse admin/users cc @pavanaravapalli@DaanHoogland@andrijapanicsb | ||
| + " Boot Type: " + params.get(VirtualMachineProfile.Param.BootType) | ||
| + " Boot Mode: " + params.get(VirtualMachineProfile.Param.BootMode) | ||
| ); | ||
| DeployDestination dest = null; | ||
| try { | ||
| dest = _dpMgr.planDeployment(vmProfile, plan, avoids, planner); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -29,6 +29,7 @@ | ||
| import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao; | ||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; | ||
| import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; | ||
| import org.apache.commons.collections.MapUtils; | ||
| import org.apache.log4j.Logger; | ||
| import org.springframework.stereotype.Component; | ||
| @@ -148,6 +149,15 @@ public String reserveVirtualMachine(VMEntityVO vmEntityVO, DeploymentPlanner pla | ||
| VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid()); | ||
| VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm); | ||
| vmProfile.setServiceOffering(_serviceOfferingDao.findByIdIncludingRemoved(vm.getId(), vm.getServiceOfferingId())); | ||
| if (MapUtils.isNotEmpty(vmEntityVO.getDetails()) && | ||
| vmEntityVO.getDetails().containsKey(VirtualMachineProfile.Param.UefiFlag.getName()) && | ||
| "yes".equalsIgnoreCase(vmEntityVO.getDetails().get(VirtualMachineProfile.Param.UefiFlag.getName()))) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavanaravapalli | ||
| { | ||
| Map<String, String> details = vmEntityVO.getDetails(); | ||
| vmProfile.getParameters().put(VirtualMachineProfile.Param.BootType, details.get(VirtualMachineProfile.Param.BootType.getName())); | ||
| vmProfile.getParameters().put(VirtualMachineProfile.Param.BootMode, details.get(VirtualMachineProfile.Param.BootMode.getName())); | ||
| vmProfile.getParameters().put(VirtualMachineProfile.Param.UefiFlag, details.get(VirtualMachineProfile.Param.UefiFlag.getName())); | ||
| } | ||
Comment on lines
+152
to
+160
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. method: determineAndSetBootParametersOnVmProfile() ? | ||
| DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodIdToDeployIn(), null, null, null, null); | ||
| if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) { | ||
| plan = | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pavanaravapalli lint issue - add space between
if (...