Search in sources :

Example 71 with ResourceUnavailableException

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

the class AssociateUcsProfileToBladeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        UcsBladeResponse rsp = mgr.associateProfileToBlade(this);
        rsp.setResponseName(getCommandName());
        this.setResponseObject(rsp);
    } catch (Exception e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : UcsBladeResponse(org.apache.cloudstack.api.response.UcsBladeResponse) 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 72 with ResourceUnavailableException

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

the class DeleteUcsManagerCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        mgr.deleteUcsManager(ucsManagerId);
        SuccessResponse rsp = new SuccessResponse();
        rsp.setResponseName(getCommandName());
        rsp.setObjectName("success");
        this.setResponseObject(rsp);
    } catch (Exception e) {
        logger.debug(e.getMessage(), e);
        throw new CloudRuntimeException(e);
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) 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 73 with ResourceUnavailableException

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

the class InternalLoadBalancerVMManagerImpl method applyLoadBalancingRules.

@Override
public boolean applyLoadBalancingRules(final Network network, final List<LoadBalancingRule> rules, final List<? extends VirtualRouter> internalLbVms) throws ResourceUnavailableException {
    if (rules == null || rules.isEmpty()) {
        s_logger.debug("No lb rules to be applied for network " + network);
        return true;
    }
    s_logger.info("lb rules to be applied for network ");
    // only one internal lb vm is supported per ip address at this time
    if (internalLbVms == null || internalLbVms.isEmpty()) {
        throw new CloudRuntimeException("Can't apply the lb rules on network " + network + " as the list of internal lb vms is empty");
    }
    final VirtualRouter lbVm = internalLbVms.get(0);
    if (lbVm.getState() == State.Running) {
        return sendLBRules(lbVm, rules, network.getId());
    } else if (lbVm.getState() == State.Stopped || lbVm.getState() == State.Stopping) {
        s_logger.debug("Internal LB VM " + lbVm.getInstanceName() + " is in " + lbVm.getState() + ", so not sending apply lb rules commands to the backend");
        return true;
    } else {
        s_logger.warn("Unable to apply lb rules, Internal LB VM is not in the right state " + lbVm.getState());
        throw new ResourceUnavailableException("Unable to apply lb rules; Internal LB VM is not in the right state", DataCenter.class, lbVm.getDataCenterId());
    }
}
Also used : DataCenter(com.cloud.dc.DataCenter) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 74 with ResourceUnavailableException

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

the class InternalLBVMManagerTest method applyWithEmptyVmsSet.

@Test(expected = CloudRuntimeException.class)
public void applyWithEmptyVmsSet() {
    boolean result = false;
    final List<DomainRouterVO> vms = new ArrayList<DomainRouterVO>();
    final List<LoadBalancingRule> rules = new ArrayList<LoadBalancingRule>();
    final LoadBalancingRule rule = new LoadBalancingRule(null, null, null, null, null, null, null);
    rules.add(rule);
    try {
        result = _lbVmMgr.applyLoadBalancingRules(new NetworkVO(), rules, vms);
    } catch (final ResourceUnavailableException e) {
    } finally {
        assertFalse("Got success when tried to apply with the empty internal lb vm list", result);
    }
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) LoadBalancingRule(com.cloud.network.lb.LoadBalancingRule) ArrayList(java.util.ArrayList) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) DomainRouterVO(com.cloud.vm.DomainRouterVO) Test(org.junit.Test)

Example 75 with ResourceUnavailableException

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

the class InternalLoadBalancerElement method applyLBRules.

@Override
public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
    // 1) Get Internal LB VMs to destroy
    Set<Ip> vmsToDestroy = getVmsToDestroy(network, rules);
    // 2) Get rules to apply
    Map<Ip, List<LoadBalancingRule>> rulesToApply = getLbRulesToApply(rules);
    s_logger.debug("Applying " + rulesToApply.size() + " on element " + getName());
    for (Ip sourceIp : vmsToDestroy) {
        // 2.1 Destroy internal lb vm
        List<? extends VirtualRouter> vms = _internalLbMgr.findInternalLbVms(network.getId(), sourceIp);
        if (vms.size() > 0) {
            // only one internal lb per IP exists
            try {
                s_logger.debug(String.format("Destroying internal lb vm for ip %s as all the rules for this vm are in Revoke state", sourceIp.addr()));
                return _internalLbMgr.destroyInternalLbVm(vms.get(0).getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM), _accountMgr.getUserIncludingRemoved(User.UID_SYSTEM).getId());
            } catch (ConcurrentOperationException e) {
                s_logger.warn(String.format("Failed to apply lb rule(s) for ip %s on the element %s due to: ", sourceIp.addr(), getName()), e);
                return false;
            }
        }
        rulesToApply.remove(sourceIp);
    }
    for (Map.Entry<Ip, List<LoadBalancingRule>> entry : rulesToApply.entrySet()) {
        Ip sourceIp = entry.getKey();
        // 2.2 Start Internal LB vm per IP address
        List<? extends VirtualRouter> internalLbVms;
        try {
            DeployDestination dest = new DeployDestination(_entityMgr.findById(DataCenter.class, network.getDataCenterId()), null, null, null);
            internalLbVms = _internalLbMgr.deployInternalLbVm(network, sourceIp, dest, _accountMgr.getAccount(network.getAccountId()), null);
        } catch (InsufficientCapacityException e) {
            s_logger.warn(String.format("Failed to apply lb rule(s) for ip %s on the element %s due to: ", sourceIp.addr(), getName()), e);
            return false;
        } catch (ConcurrentOperationException e) {
            s_logger.warn(String.format("Failed to apply lb rule(s) for ip %s on the element %s due to: ", sourceIp.addr(), getName()), e);
            return false;
        }
        if (internalLbVms == null || internalLbVms.isEmpty()) {
            throw new ResourceUnavailableException("Can't find/deploy internal lb vm to handle LB rules", DataCenter.class, network.getDataCenterId());
        }
        // 2.3 Apply Internal LB rules on the VM
        if (!_internalLbMgr.applyLoadBalancingRules(network, entry.getValue(), internalLbVms)) {
            throw new CloudRuntimeException("Failed to apply load balancing rules for ip " + sourceIp.addr() + " in network " + network.getId() + " on element " + getName());
        }
    }
    return true;
}
Also used : Ip(com.cloud.utils.net.Ip) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) DataCenter(com.cloud.dc.DataCenter) DeployDestination(com.cloud.deploy.DeployDestination) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) List(java.util.List) ArrayList(java.util.ArrayList) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)446 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)191 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)175 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)153 ArrayList (java.util.ArrayList)99 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)91 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)74 Account (com.cloud.user.Account)62 DomainRouterVO (com.cloud.vm.DomainRouterVO)60 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)59 ConfigurationException (javax.naming.ConfigurationException)53 DB (com.cloud.utils.db.DB)52 ServerApiException (org.apache.cloudstack.api.ServerApiException)51 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)47 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)47 ActionEvent (com.cloud.event.ActionEvent)46 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)46 DataCenter (com.cloud.dc.DataCenter)45 ServerApiException (com.cloud.api.ServerApiException)43 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)42