mirror of https://github.com/apache/cloudstack.git
bug 7989: fixing this regression
status 7989: resolved fixed
This commit is contained in:
parent
13630923ab
commit
7c2fffe67a
|
|
@ -20,6 +20,8 @@ package com.cloud.api.commands;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.InsufficientResourcesException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
|
|
@ -34,6 +36,7 @@ import com.cloud.event.EventTypes;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ package com.cloud.vm;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.InsufficientResourcesException;
|
||||
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.commands.AttachVolumeCmd;
|
||||
import com.cloud.api.commands.CreateTemplateCmd;
|
||||
|
|
@ -121,10 +123,11 @@ public interface UserVmService {
|
|||
* @throws InsufficientCapacityException if there is insufficient capacity to deploy the VM.
|
||||
* @throws ConcurrentOperationException if there are multiple users working on the same VM or in the same environment.
|
||||
* @throws ResourceUnavailableException if the resources required to deploy the VM is not currently available.
|
||||
* @throws InsufficientResourcesException
|
||||
* @throws PermissionDeniedException if the caller doesn't have any access rights to the VM.
|
||||
* @throws InvalidParameterValueException if the parameters are incorrect.
|
||||
*/
|
||||
UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException;
|
||||
|
||||
/**
|
||||
* Starts the virtual machine created from createVirtualMachine.
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class ApiDispatcher {
|
|||
} else if (t instanceof ServerApiException) {
|
||||
s_logger.warn(t.getClass() + " : " + ((ServerApiException) t).getDescription());
|
||||
if (UserContext.current().getCaller().getType() == Account.ACCOUNT_TYPE_ADMIN) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, errorMsg);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, errorMsg.length() > 0 ? errorMsg : ((ServerApiException) t).getDescription());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, BaseCmd.USER_ERROR_MESSAGE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.naming.InsufficientResourcesException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -2114,7 +2115,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
@Override @DB
|
||||
public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
|
||||
public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
String accountName = cmd.getAccountName();
|
||||
|
|
@ -2143,6 +2144,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
_accountMgr.checkAccess(caller, domain);
|
||||
_accountMgr.checkAccess(owner, domain);
|
||||
}
|
||||
//check if we have available pools for vm deployment
|
||||
List<StoragePoolVO> availablePools = _storagePoolDao.listPoolsByStatus(com.cloud.host.Status.Up);
|
||||
|
||||
if( availablePools == null || availablePools.size() < 1) {
|
||||
throw new StorageUnavailableException("There are no available pools in the UP state for vm deployment",-1);
|
||||
}
|
||||
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(cmd.getServiceOfferingId());
|
||||
if (offering == null || offering.getRemoved() != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue