Search in sources :

Example 56 with InsufficientCapacityException

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

the class VpcVirtualNetworkApplianceManagerImpl method addVpcRouterToGuestNetwork.

@Override
public boolean addVpcRouterToGuestNetwork(final VirtualRouter router, final Network network, final Map<VirtualMachineProfile.Param, Object> params) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    if (network.getTrafficType() != TrafficType.Guest) {
        s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
        return false;
    }
    // Add router to the Guest network
    boolean result = true;
    try {
        // 1) add nic to the router
        _routerDao.addRouterToGuestNetwork(router, network);
        final NicProfile guestNic = _itMgr.addVmToNetwork(router, network, null);
        // 2) setup guest network
        if (guestNic != null) {
            result = setupVpcGuestNetwork(network, router, true, guestNic);
        } else {
            s_logger.warn("Failed to add router " + router + " to guest network " + network);
            result = false;
        }
        // 3) apply networking rules
        if (result && params.get(Param.ReProgramGuestNetworks) != null && (Boolean) params.get(Param.ReProgramGuestNetworks) == true) {
            sendNetworkRulesToRouter(router.getId(), network.getId());
        }
    } catch (final Exception ex) {
        s_logger.warn("Failed to add router " + router + " to network " + network + " due to ", ex);
        result = false;
    } finally {
        if (!result) {
            s_logger.debug("Removing the router " + router + " from network " + network + " as a part of cleanup");
            if (removeVpcRouterFromGuestNetwork(router, network)) {
                s_logger.debug("Removed the router " + router + " from network " + network + " as a part of cleanup");
            } else {
                s_logger.warn("Failed to remove the router " + router + " from network " + network + " as a part of cleanup");
            }
        } else {
            s_logger.debug("Succesfully added router " + router + " to guest network " + network);
        }
    }
    return result;
}
Also used : NicProfile(com.cloud.vm.NicProfile) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 57 with InsufficientCapacityException

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

the class AutoScaleManagerImpl method startNewVM.

private boolean startNewVM(long vmId) {
    try {
        CallContext.current().setEventDetails("Vm Id: " + vmId);
        _userVmManager.startVirtualMachine(vmId, null, null, null);
    } catch (final ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (InsufficientCapacityException ex) {
        StringBuilder message = new StringBuilder(ex.getMessage());
        if (ex instanceof InsufficientServerCapacityException) {
            if (((InsufficientServerCapacityException) ex).isAffinityApplied()) {
                message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them");
            }
        }
        s_logger.info(ex);
        s_logger.info(message.toString(), ex);
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString());
    }
    return true;
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientServerCapacityException(com.cloud.exception.InsufficientServerCapacityException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 58 with InsufficientCapacityException

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

the class BaremetalProvisionDoneNotificationCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        bmMgr.notifyProvisionDone(this);
        this.setResponseObject(new SuccessResponse(getCommandName()));
    } catch (Exception e) {
        s_logger.warn(String.format("unable to notify baremetal provision done[mac:%s]", mac), e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

Example 59 with InsufficientCapacityException

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

the class AddBaremetalDhcpCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        BaremetalDhcpVO vo = mgr.addDchpServer(this);
        BaremetalDhcpResponse response = mgr.generateApiResponse(vo);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (Exception e) {
        s_logger.warn("Unable to add external dhcp server with url: " + getUrl(), e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : BaremetalDhcpVO(com.cloud.baremetal.database.BaremetalDhcpVO) BaremetalDhcpResponse(com.cloud.baremetal.networkservice.BaremetalDhcpResponse) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 60 with InsufficientCapacityException

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

the class AddUcsManagerCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        UcsManagerResponse rsp = mgr.addUcsManager(this);
        rsp.setObjectName("ucsmanager");
        rsp.setResponseName(getCommandName());
        this.setResponseObject(rsp);
    } catch (Exception e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : UcsManagerResponse(org.apache.cloudstack.api.response.UcsManagerResponse) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

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