@@ -1081,7 +1081,7 @@ private UserVm forceRebootVirtualMachine(long vmId, long hostId, boolean enterSe
10811081 params = new HashMap ();
10821082 params .put (VirtualMachineProfile .Param .BootIntoSetup , Boolean .TRUE );
10831083 }
1084- return startVirtualMachine (vmId , null , null , hostId , params , null ).first ();
1084+ return startVirtualMachine (vmId , null , null , hostId , params , null , false ).first ();
10851085 }
10861086 } catch (ResourceUnavailableException e ) {
10871087 throw new CloudRuntimeException ("Unable to reboot the VM: " + vmId , e );
@@ -5068,6 +5068,13 @@ public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMach
50685068 public Pair <UserVmVO , Map <VirtualMachineProfile .Param , Object >> startVirtualMachine (long vmId , Long podId , Long clusterId , Long hostId ,
50695069 Map <VirtualMachineProfile .Param , Object > additionalParams , String deploymentPlannerToUse )
50705070 throws ConcurrentOperationException , ResourceUnavailableException , InsufficientCapacityException , ResourceAllocationException {
5071+ return startVirtualMachine (vmId , podId , clusterId , hostId , additionalParams , deploymentPlannerToUse , true );
5072+ }
5073+
5074+ @ Override
5075+ public Pair <UserVmVO , Map <VirtualMachineProfile .Param , Object >> startVirtualMachine (long vmId , Long podId , Long clusterId , Long hostId ,
5076+ Map <VirtualMachineProfile .Param , Object > additionalParams , String deploymentPlannerToUse , boolean isExplicitHost )
5077+ throws ConcurrentOperationException , ResourceUnavailableException , InsufficientCapacityException , ResourceAllocationException {
50715078 // Input validation
50725079 final Account callerAccount = CallContext .current ().getCallingAccount ();
50735080 UserVO callerUser = _userDao .findById (CallContext .current ().getCallingUserId ());
@@ -5123,7 +5130,7 @@ public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMach
51235130 boolean isRootAdmin = _accountService .isRootAdmin (callerAccount .getId ());
51245131 Pod destinationPod = getDestinationPod (podId , isRootAdmin );
51255132 Cluster destinationCluster = getDestinationCluster (clusterId , isRootAdmin );
5126- Host destinationHost = getDestinationHost (hostId , isRootAdmin );
5133+ Host destinationHost = getDestinationHost (hostId , isRootAdmin , isExplicitHost );
51275134 DataCenterDeployment plan = null ;
51285135 boolean deployOnGivenHost = false ;
51295136 if (destinationHost != null ) {
@@ -5276,10 +5283,10 @@ private Cluster getDestinationCluster(Long clusterId, boolean isRootAdmin) {
52765283 return destinationCluster ;
52775284 }
52785285
5279- private Host getDestinationHost (Long hostId , boolean isRootAdmin ) {
5286+ private Host getDestinationHost (Long hostId , boolean isRootAdmin , boolean isExplicitHost ) {
52805287 Host destinationHost = null ;
52815288 if (hostId != null ) {
5282- if (!isRootAdmin ) {
5289+ if (isExplicitHost && !isRootAdmin ) {
52835290 throw new PermissionDeniedException (
52845291 "Parameter " + ApiConstants .HOST_ID + " can only be specified by a Root Admin, permission denied" );
52855292 }
@@ -5622,7 +5629,7 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
56225629 boolean isRootAdmin = _accountService .isRootAdmin (callerId );
56235630
56245631 Long hostId = cmd .getHostId ();
5625- getDestinationHost (hostId , isRootAdmin );
5632+ getDestinationHost (hostId , isRootAdmin , true );
56265633
56275634 String ipAddress = cmd .getIpAddress ();
56285635 String ip6Address = cmd .getIp6Address ();
0 commit comments