@@ -724,6 +724,20 @@ protected void runInContext() {
724724 }
725725 }
726726
727+ private void addVmUefiBootOptionsToParams (Map <VirtualMachineProfile .Param , Object > params , String bootType , String bootMode ) {
728+ if (s_logger .isTraceEnabled ()) {
729+ s_logger .trace (String .format ("Adding boot options (%s, %s, %s) into the param map for VM start as UEFI detail(%s=%s) found for the VM" ,
730+ VirtualMachineProfile .Param .UefiFlag .getName (),
731+ VirtualMachineProfile .Param .BootType .getName (),
732+ VirtualMachineProfile .Param .BootMode .getName (),
733+ bootType ,
734+ bootMode ));
735+ }
736+ params .put (VirtualMachineProfile .Param .UefiFlag , "Yes" );
737+ params .put (VirtualMachineProfile .Param .BootType , bootType );
738+ params .put (VirtualMachineProfile .Param .BootMode , bootMode );
739+ }
740+
727741 @ Override
728742 @ ActionEvent (eventType = EventTypes .EVENT_VM_RESETPASSWORD , eventDescription = "resetting Vm password" , async = true )
729743 public UserVm resetVMPassword (ResetVMPasswordCmd cmd , String password ) throws ResourceUnavailableException , InsufficientCapacityException {
@@ -2882,17 +2896,17 @@ protected boolean applyUserData(HypervisorType hyperVisorType, UserVm vm, Nic ni
28822896 @ Override
28832897 @ ActionEvent (eventType = EventTypes .EVENT_VM_START , eventDescription = "starting Vm" , async = true )
28842898 public UserVm startVirtualMachine (StartVMCmd cmd ) throws ExecutionException , ConcurrentOperationException , ResourceUnavailableException , InsufficientCapacityException , ResourceAllocationException {
2885- Map <VirtualMachineProfile .Param , Object > additonalParams = null ;
2899+ Map <VirtualMachineProfile .Param , Object > additonalParams = new HashMap <>() ;
28862900 if (cmd .getBootIntoSetup () != null ) {
2887- if (additonalParams == null ) {
2888- additonalParams = new HashMap <>();
2889- }
28902901 if (s_logger .isTraceEnabled ()) {
28912902 s_logger .trace (String .format ("Adding %s into the param map" , VirtualMachineProfile .Param .BootIntoSetup .getName ()));
28922903 }
2893-
28942904 additonalParams .put (VirtualMachineProfile .Param .BootIntoSetup , cmd .getBootIntoSetup ());
28952905 }
2906+ UserVmDetailVO uefiDetail = userVmDetailsDao .findDetail (cmd .getId (), ApiConstants .BootType .UEFI .toString ());
2907+ if (uefiDetail != null ) {
2908+ addVmUefiBootOptionsToParams (additonalParams , uefiDetail .getName (), uefiDetail .getValue ());
2909+ }
28962910
28972911 return startVirtualMachine (cmd .getId (), cmd .getPodId (), cmd .getClusterId (), cmd .getHostId (), additonalParams , cmd .getDeploymentPlanner ()).first ();
28982912 }
@@ -4434,23 +4448,21 @@ public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableExc
44344448 Long podId = null ;
44354449 Long clusterId = null ;
44364450 Long hostId = cmd .getHostId ();
4437- Map <VirtualMachineProfile .Param , Object > additonalParams = new HashMap <>();
4451+ Map <VirtualMachineProfile .Param , Object > additionalParams = new HashMap <>();
44384452 Map <Long , DiskOffering > diskOfferingMap = cmd .getDataDiskTemplateToDiskOfferingMap ();
4453+ Map <String , String > details = cmd .getDetails ();
44394454 if (cmd instanceof DeployVMCmdByAdmin ) {
44404455 DeployVMCmdByAdmin adminCmd = (DeployVMCmdByAdmin )cmd ;
44414456 podId = adminCmd .getPodId ();
44424457 clusterId = adminCmd .getClusterId ();
44434458 }
4444- if (MapUtils .isNotEmpty (cmd .getDetails ()) && cmd .getDetails ().containsKey (ApiConstants .BootType .UEFI .toString ())) {
4445- Map <String , String > map = cmd .getDetails ();
4446- additonalParams .put (VirtualMachineProfile .Param .UefiFlag , "Yes" );
4447- additonalParams .put (VirtualMachineProfile .Param .BootType , ApiConstants .BootType .UEFI .toString ());
4448- additonalParams .put (VirtualMachineProfile .Param .BootMode , map .get (ApiConstants .BootType .UEFI .toString ()));
4459+ if (MapUtils .isNotEmpty (details ) && details .containsKey (ApiConstants .BootType .UEFI .toString ())) {
4460+ addVmUefiBootOptionsToParams (additionalParams , ApiConstants .BootType .UEFI .toString (), details .get (ApiConstants .BootType .UEFI .toString ()));
44494461 }
44504462 if (cmd .getBootIntoSetup () != null ) {
4451- additonalParams .put (VirtualMachineProfile .Param .BootIntoSetup , cmd .getBootIntoSetup ());
4463+ additionalParams .put (VirtualMachineProfile .Param .BootIntoSetup , cmd .getBootIntoSetup ());
44524464 }
4453- return startVirtualMachine (vmId , podId , clusterId , hostId , diskOfferingMap , additonalParams , cmd .getDeploymentPlanner ());
4465+ return startVirtualMachine (vmId , podId , clusterId , hostId , diskOfferingMap , additionalParams , cmd .getDeploymentPlanner ());
44544466 }
44554467
44564468 private UserVm startVirtualMachine (long vmId , Long podId , Long clusterId , Long hostId , Map <Long , DiskOffering > diskOfferingMap
0 commit comments