mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Allow force reboot VM from user account, to start VM on the same host (#5791)
This commit is contained in:
parent
936ebbb90f
commit
39e41f6b6e
@ -110,6 +110,9 @@ public interface UserVmManager extends UserVmService {
|
||||
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String deploymentPlannerToUse)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException;
|
||||
|
||||
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String deploymentPlannerToUse, boolean isExplicitHost)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException;
|
||||
|
||||
boolean upgradeVirtualMachine(Long id, Long serviceOfferingId, Map<String, String> customParameters) throws ResourceUnavailableException,
|
||||
ConcurrentOperationException, ManagementServerException,
|
||||
VirtualMachineMigrationException;
|
||||
|
||||
@ -1078,7 +1078,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
params = new HashMap();
|
||||
params.put(VirtualMachineProfile.Param.BootIntoSetup, Boolean.TRUE);
|
||||
}
|
||||
return startVirtualMachine(vmId, null, null, hostId, params, null).first();
|
||||
return startVirtualMachine(vmId, null, null, hostId, params, null, false).first();
|
||||
}
|
||||
} catch (ResourceUnavailableException e) {
|
||||
throw new CloudRuntimeException("Unable to reboot the VM: " + vmId, e);
|
||||
@ -5063,6 +5063,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId,
|
||||
Map<VirtualMachineProfile.Param, Object> additionalParams, String deploymentPlannerToUse)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException {
|
||||
return startVirtualMachine(vmId, podId, clusterId, hostId, additionalParams, deploymentPlannerToUse, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId,
|
||||
Map<VirtualMachineProfile.Param, Object> additionalParams, String deploymentPlannerToUse, boolean isExplicitHost)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException {
|
||||
// Input validation
|
||||
final Account callerAccount = CallContext.current().getCallingAccount();
|
||||
UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId());
|
||||
@ -5118,7 +5125,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
boolean isRootAdmin = _accountService.isRootAdmin(callerAccount.getId());
|
||||
Pod destinationPod = getDestinationPod(podId, isRootAdmin);
|
||||
Cluster destinationCluster = getDestinationCluster(clusterId, isRootAdmin);
|
||||
Host destinationHost = getDestinationHost(hostId, isRootAdmin);
|
||||
Host destinationHost = getDestinationHost(hostId, isRootAdmin, isExplicitHost);
|
||||
DataCenterDeployment plan = null;
|
||||
boolean deployOnGivenHost = false;
|
||||
if (destinationHost != null) {
|
||||
@ -5271,10 +5278,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
return destinationCluster;
|
||||
}
|
||||
|
||||
private Host getDestinationHost(Long hostId, boolean isRootAdmin) {
|
||||
private Host getDestinationHost(Long hostId, boolean isRootAdmin, boolean isExplicitHost) {
|
||||
Host destinationHost = null;
|
||||
if (hostId != null) {
|
||||
if (!isRootAdmin) {
|
||||
if (isExplicitHost && !isRootAdmin) {
|
||||
throw new PermissionDeniedException(
|
||||
"Parameter " + ApiConstants.HOST_ID + " can only be specified by a Root Admin, permission denied");
|
||||
}
|
||||
@ -5615,7 +5622,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
boolean isRootAdmin = _accountService.isRootAdmin(callerId);
|
||||
|
||||
Long hostId = cmd.getHostId();
|
||||
getDestinationHost(hostId, isRootAdmin);
|
||||
getDestinationHost(hostId, isRootAdmin, true);
|
||||
|
||||
String ipAddress = cmd.getIpAddress();
|
||||
String ip6Address = cmd.getIp6Address();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user