Search in sources :

Example 6 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project CloudStack-archive by CloudStack-extras.

the class CreateVlanIpRangeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
    try {
        Vlan result = _configService.createVlanAndPublicIpRange(this);
        if (result != null) {
            VlanIpRangeResponse response = _responseGenerator.createVlanIpRangeResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create vlan ip range");
        }
    } catch (ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
    } catch (InsufficientCapacityException ex) {
        s_logger.info(ex);
        throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
    }
}
Also used : VlanIpRangeResponse(com.cloud.api.response.VlanIpRangeResponse) ServerApiException(com.cloud.api.ServerApiException) Vlan(com.cloud.dc.Vlan) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 7 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class ListVmwareDcsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    List<? extends VmwareDatacenter> vmwareDcList = null;
    try {
        vmwareDcList = _vmwareDatacenterService.listVmwareDatacenters(this);
    } catch (InvalidParameterValueException ie) {
        throw new InvalidParameterValueException("Invalid zone id " + getZoneId());
    } catch (Exception e) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to find associated VMware DCs associated with zone " + getZoneId());
    }
    ListResponse<VmwareDatacenterResponse> response = new ListResponse<VmwareDatacenterResponse>();
    List<VmwareDatacenterResponse> vmwareDcResponses = new ArrayList<VmwareDatacenterResponse>();
    if (vmwareDcList != null && vmwareDcList.size() > 0) {
        for (VmwareDatacenter vmwareDc : vmwareDcList) {
            VmwareDatacenterResponse vmwareDcResponse = new VmwareDatacenterResponse();
            vmwareDcResponse.setId(vmwareDc.getUuid());
            vmwareDcResponse.setVcenter(vmwareDc.getVcenterHost());
            vmwareDcResponse.setName(vmwareDc.getVmwareDatacenterName());
            vmwareDcResponse.setZoneId(getZoneId());
            vmwareDcResponse.setObjectName("VMwareDC");
            vmwareDcResponses.add(vmwareDcResponse);
        }
    }
    response.setResponses(vmwareDcResponses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : VmwareDatacenterResponse(org.apache.cloudstack.api.response.VmwareDatacenterResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ListResponse(org.apache.cloudstack.api.response.ListResponse) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) VmwareDatacenter(com.cloud.hypervisor.vmware.VmwareDatacenter) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 8 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class VpcVirtualRouterElement method getRouters.

@Override
protected List<DomainRouterVO> getRouters(final Network network, final DeployDestination dest) {
    //1st time it runs the domain router of the VM shall be returned
    List<DomainRouterVO> routers = super.getRouters(network, dest);
    if (routers.size() > 0) {
        return routers;
    }
    //For the 2nd time it returns the VPC routers.
    final Long vpcId = network.getVpcId();
    if (vpcId == null) {
        s_logger.error("Network " + network + " is not associated with any VPC");
        return routers;
    }
    final Vpc vpc = _vpcMgr.getActiveVpc(vpcId);
    if (vpc == null) {
        s_logger.warn("Unable to find Enabled VPC by id " + vpcId);
        return routers;
    }
    final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setGuestNetwork(network).setVpc(vpc).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).build();
    try {
        routers = routerDeploymentDefinition.deployVirtualRouter();
    } catch (final ConcurrentOperationException e) {
        s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e);
    } catch (final InsufficientCapacityException e) {
        s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e);
    } catch (final ResourceUnavailableException e) {
        s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e);
    }
    return routers;
}
Also used : RouterDeploymentDefinition(org.cloud.network.router.deployment.RouterDeploymentDefinition) Vpc(com.cloud.network.vpc.Vpc) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 9 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class NetworkOrchestrator method restartNetwork.

@Override
public boolean restartNetwork(final Long networkId, final Account callerAccount, final User callerUser, final boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    final NetworkVO network = _networksDao.findById(networkId);
    s_logger.debug("Restarting network " + networkId + "...");
    final ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
    if (cleanup) {
        // shutdown the network
        s_logger.debug("Shutting down the network id=" + networkId + " as a part of network restart");
        if (!shutdownNetworkElementsAndResources(context, true, network)) {
            s_logger.debug("Failed to shutdown the network elements and resources as a part of network restart: " + network.getState());
            setRestartRequired(network, true);
            return false;
        }
    } else {
        s_logger.debug("Skip the shutting down of network id=" + networkId);
    }
    // implement the network elements and rules again
    final DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null);
    s_logger.debug("Implementing the network " + network + " elements and resources as a part of network restart");
    final NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
    try {
        implementNetworkElementsAndResources(dest, context, network, offering);
        setRestartRequired(network, true);
        return true;
    } catch (final Exception ex) {
        s_logger.warn("Failed to implement network " + network + " elements and resources as a part of network restart due to ", ex);
        return false;
    }
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) DeployDestination(com.cloud.deploy.DeployDestination) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) ReservationContextImpl(com.cloud.vm.ReservationContextImpl) ConnectionException(com.cloud.exception.ConnectionException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientVirtualNetworkCapacityException(com.cloud.exception.InsufficientVirtualNetworkCapacityException) ConfigurationException(javax.naming.ConfigurationException) ReservationContext(com.cloud.vm.ReservationContext)

Example 10 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class NetworkOrchestrator method reallocate.

@DB
@Override
public boolean reallocate(final VirtualMachineProfile vm, final DataCenterDeployment dest) throws InsufficientCapacityException, ConcurrentOperationException {
    final VMInstanceVO vmInstance = _vmDao.findById(vm.getId());
    final DataCenterVO dc = _dcDao.findById(vmInstance.getDataCenterId());
    if (dc.getNetworkType() == NetworkType.Basic) {
        final List<NicVO> nics = _nicDao.listByVmId(vmInstance.getId());
        final NetworkVO network = _networksDao.findById(nics.get(0).getNetworkId());
        final LinkedHashMap<Network, List<? extends NicProfile>> profiles = new LinkedHashMap<Network, List<? extends NicProfile>>();
        profiles.put(network, new ArrayList<NicProfile>());
        Transaction.execute(new TransactionCallbackWithExceptionNoReturn<InsufficientCapacityException>() {

            @Override
            public void doInTransactionWithoutResult(final TransactionStatus status) throws InsufficientCapacityException {
                cleanupNics(vm);
                allocate(vm, profiles);
            }
        });
    }
    return true;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) VMInstanceVO(com.cloud.vm.VMInstanceVO) TransactionStatus(com.cloud.utils.db.TransactionStatus) NicProfile(com.cloud.vm.NicProfile) LinkedHashMap(java.util.LinkedHashMap) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) List(java.util.List) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NicVO(com.cloud.vm.NicVO) DB(com.cloud.utils.db.DB)

Aggregations

InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)85 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)77 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)70 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)41 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)36 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)23 ServerApiException (org.apache.cloudstack.api.ServerApiException)23 Account (com.cloud.user.Account)18 ConfigurationException (javax.naming.ConfigurationException)17 ArrayList (java.util.ArrayList)15 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)14 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)14 TransactionCallbackWithException (com.cloud.utils.db.TransactionCallbackWithException)12 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)11 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)11 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)10 NetworkVO (com.cloud.network.dao.NetworkVO)10 DB (com.cloud.utils.db.DB)10 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)9 Network (com.cloud.network.Network)9