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());
}
}
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);
}
}
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());
}
}
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);
}
}
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;
}
Aggregations