@@ -1078,7 +1078,7 @@ private UserVm forceRebootVirtualMachine(long vmId, long hostId, boolean enterSe
10781078 params = new HashMap ();
10791079 params .put (VirtualMachineProfile .Param .BootIntoSetup , Boolean .TRUE );
10801080 }
1081- return startVirtualMachine (vmId , null , null , hostId , params , null ).first ();
1081+ return startVirtualMachine (vmId , null , null , hostId , params , null , false ).first ();
10821082 }
10831083 } catch (ResourceUnavailableException e ) {
10841084 throw new CloudRuntimeException ("Unable to reboot the VM: " + vmId , e );
@@ -5063,6 +5063,13 @@ public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMach
50635063 public Pair <UserVmVO , Map <VirtualMachineProfile .Param , Object >> startVirtualMachine (long vmId , Long podId , Long clusterId , Long hostId ,
50645064 Map <VirtualMachineProfile .Param , Object > additionalParams , String deploymentPlannerToUse )
50655065 throws ConcurrentOperationException , ResourceUnavailableException , InsufficientCapacityException , ResourceAllocationException {
5066+ return startVirtualMachine (vmId , podId , clusterId , hostId , additionalParams , deploymentPlannerToUse , true );
5067+ }
5068+
5069+ @ Override
5070+ public Pair <UserVmVO , Map <VirtualMachineProfile .Param , Object >> startVirtualMachine (long vmId , Long podId , Long clusterId , Long hostId ,
5071+ Map <VirtualMachineProfile .Param , Object > additionalParams , String deploymentPlannerToUse , boolean isExplicitHost )
5072+ throws ConcurrentOperationException , ResourceUnavailableException , InsufficientCapacityException , ResourceAllocationException {
50665073 // Input validation
50675074 final Account callerAccount = CallContext .current ().getCallingAccount ();
50685075 UserVO callerUser = _userDao .findById (CallContext .current ().getCallingUserId ());
@@ -5118,7 +5125,7 @@ public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMach
51185125 boolean isRootAdmin = _accountService .isRootAdmin (callerAccount .getId ());
51195126 Pod destinationPod = getDestinationPod (podId , isRootAdmin );
51205127 Cluster destinationCluster = getDestinationCluster (clusterId , isRootAdmin );
5121- Host destinationHost = getDestinationHost (hostId , isRootAdmin );
5128+ Host destinationHost = getDestinationHost (hostId , isRootAdmin , isExplicitHost );
51225129 DataCenterDeployment plan = null ;
51235130 boolean deployOnGivenHost = false ;
51245131 if (destinationHost != null ) {
@@ -5271,10 +5278,10 @@ private Cluster getDestinationCluster(Long clusterId, boolean isRootAdmin) {
52715278 return destinationCluster ;
52725279 }
52735280
5274- private Host getDestinationHost (Long hostId , boolean isRootAdmin ) {
5281+ private Host getDestinationHost (Long hostId , boolean isRootAdmin , boolean isExplicitHost ) {
52755282 Host destinationHost = null ;
52765283 if (hostId != null ) {
5277- if (!isRootAdmin ) {
5284+ if (isExplicitHost && !isRootAdmin ) {
52785285 throw new PermissionDeniedException (
52795286 "Parameter " + ApiConstants .HOST_ID + " can only be specified by a Root Admin, permission denied" );
52805287 }
@@ -5615,7 +5622,7 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
56155622 boolean isRootAdmin = _accountService .isRootAdmin (callerId );
56165623
56175624 Long hostId = cmd .getHostId ();
5618- getDestinationHost (hostId , isRootAdmin );
5625+ getDestinationHost (hostId , isRootAdmin , true );
56195626
56205627 String ipAddress = cmd .getIpAddress ();
56215628 String ip6Address = cmd .getIp6Address ();
0 commit comments