@@ -752,6 +752,20 @@ protected void runInContext() {
752752 }
753753 }
754754
755+ private void addVmUefiBootOptionsToParams (Map <VirtualMachineProfile .Param , Object > params , String bootType , String bootMode ) {
756+ if (s_logger .isTraceEnabled ()) {
757+ 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" ,
758+ VirtualMachineProfile .Param .UefiFlag .getName (),
759+ VirtualMachineProfile .Param .BootType .getName (),
760+ VirtualMachineProfile .Param .BootMode .getName (),
761+ bootType ,
762+ bootMode ));
763+ }
764+ params .put (VirtualMachineProfile .Param .UefiFlag , "Yes" );
765+ params .put (VirtualMachineProfile .Param .BootType , bootType );
766+ params .put (VirtualMachineProfile .Param .BootMode , bootMode );
767+ }
768+
755769 @ Override
756770 @ ActionEvent (eventType = EventTypes .EVENT_VM_RESETPASSWORD , eventDescription = "resetting Vm password" , async = true )
757771 public UserVm resetVMPassword (ResetVMPasswordCmd cmd , String password ) throws ResourceUnavailableException , InsufficientCapacityException {
@@ -3053,17 +3067,17 @@ protected boolean applyUserData(HypervisorType hyperVisorType, UserVm vm, Nic ni
30533067 @ Override
30543068 @ ActionEvent (eventType = EventTypes .EVENT_VM_START , eventDescription = "starting Vm" , async = true )
30553069 public UserVm startVirtualMachine (StartVMCmd cmd ) throws ExecutionException , ConcurrentOperationException , ResourceUnavailableException , InsufficientCapacityException , ResourceAllocationException {
3056- Map <VirtualMachineProfile .Param , Object > additonalParams = null ;
3070+ Map <VirtualMachineProfile .Param , Object > additonalParams = new HashMap <>() ;
30573071 if (cmd .getBootIntoSetup () != null ) {
3058- if (additonalParams == null ) {
3059- additonalParams = new HashMap <>();
3060- }
30613072 if (s_logger .isTraceEnabled ()) {
30623073 s_logger .trace (String .format ("Adding %s into the param map" , VirtualMachineProfile .Param .BootIntoSetup .getName ()));
30633074 }
3064-
30653075 additonalParams .put (VirtualMachineProfile .Param .BootIntoSetup , cmd .getBootIntoSetup ());
30663076 }
3077+ UserVmDetailVO uefiDetail = userVmDetailsDao .findDetail (cmd .getId (), ApiConstants .BootType .UEFI .toString ());
3078+ if (uefiDetail != null ) {
3079+ addVmUefiBootOptionsToParams (additonalParams , uefiDetail .getName (), uefiDetail .getValue ());
3080+ }
30673081
30683082 return startVirtualMachine (cmd .getId (), cmd .getPodId (), cmd .getClusterId (), cmd .getHostId (), additonalParams , cmd .getDeploymentPlanner ()).first ();
30693083 }
@@ -4637,23 +4651,21 @@ public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableExc
46374651 Long podId = null ;
46384652 Long clusterId = null ;
46394653 Long hostId = cmd .getHostId ();
4640- Map <VirtualMachineProfile .Param , Object > additonalParams = new HashMap <>();
4654+ Map <VirtualMachineProfile .Param , Object > additionalParams = new HashMap <>();
46414655 Map <Long , DiskOffering > diskOfferingMap = cmd .getDataDiskTemplateToDiskOfferingMap ();
4656+ Map <String , String > details = cmd .getDetails ();
46424657 if (cmd instanceof DeployVMCmdByAdmin ) {
46434658 DeployVMCmdByAdmin adminCmd = (DeployVMCmdByAdmin )cmd ;
46444659 podId = adminCmd .getPodId ();
46454660 clusterId = adminCmd .getClusterId ();
46464661 }
4647- if (MapUtils .isNotEmpty (cmd .getDetails ()) && cmd .getDetails ().containsKey (ApiConstants .BootType .UEFI .toString ())) {
4648- Map <String , String > map = cmd .getDetails ();
4649- additonalParams .put (VirtualMachineProfile .Param .UefiFlag , "Yes" );
4650- additonalParams .put (VirtualMachineProfile .Param .BootType , ApiConstants .BootType .UEFI .toString ());
4651- additonalParams .put (VirtualMachineProfile .Param .BootMode , map .get (ApiConstants .BootType .UEFI .toString ()));
4662+ if (MapUtils .isNotEmpty (details ) && details .containsKey (ApiConstants .BootType .UEFI .toString ())) {
4663+ addVmUefiBootOptionsToParams (additionalParams , ApiConstants .BootType .UEFI .toString (), details .get (ApiConstants .BootType .UEFI .toString ()));
46524664 }
46534665 if (cmd .getBootIntoSetup () != null ) {
4654- additonalParams .put (VirtualMachineProfile .Param .BootIntoSetup , cmd .getBootIntoSetup ());
4666+ additionalParams .put (VirtualMachineProfile .Param .BootIntoSetup , cmd .getBootIntoSetup ());
46554667 }
4656- return startVirtualMachine (vmId , podId , clusterId , hostId , diskOfferingMap , additonalParams , cmd .getDeploymentPlanner ());
4668+ return startVirtualMachine (vmId , podId , clusterId , hostId , diskOfferingMap , additionalParams , cmd .getDeploymentPlanner ());
46574669 }
46584670
46594671 private UserVm startVirtualMachine (long vmId , Long podId , Long clusterId , Long hostId , Map <Long , DiskOffering > diskOfferingMap
0 commit comments