use of com.cloud.network.router.VirtualRouter 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.network.router.VirtualRouter in project CloudStack-archive by CloudStack-extras.
the class ListRoutersCmd method execute.
@Override
public void execute() {
List<? extends VirtualRouter> result = _mgr.searchForRouters(this);
ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>();
List<DomainRouterResponse> routerResponses = new ArrayList<DomainRouterResponse>();
for (VirtualRouter router : result) {
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router);
routerResponse.setObjectName("router");
routerResponses.add(routerResponse);
}
response.setResponses(routerResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.network.router.VirtualRouter in project CloudStack-archive by CloudStack-extras.
the class StartRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
UserContext.current().setEventDetails("Router Id: " + getId());
VirtualRouter result = _routerService.startRouter(id);
if (result != null) {
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
routerResponse.setResponseName(getCommandName());
this.setResponseObject(routerResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start router");
}
}
use of com.cloud.network.router.VirtualRouter in project CloudStack-archive by CloudStack-extras.
the class RebootRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
UserContext.current().setEventDetails("Router Id: " + getId());
VirtualRouter result = _routerService.rebootRouter(this.getId(), true);
if (result != null) {
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName("router");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reboot router");
}
}
use of com.cloud.network.router.VirtualRouter in project CloudStack-archive by CloudStack-extras.
the class DestroyRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
UserContext.current().setEventDetails("Router Id: " + getId());
VirtualRouter result = _routerService.destroyRouter(getId());
if (result != null) {
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy router");
}
}
Aggregations