Search in sources :

Example 36 with VirtualRouter

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());
    }
}
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 37 with VirtualRouter

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);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 38 with VirtualRouter

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");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 39 with VirtualRouter

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");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 40 with VirtualRouter

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");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Aggregations

VirtualRouter (com.cloud.network.router.VirtualRouter)72 Commands (com.cloud.agent.manager.Commands)34 DomainRouterResponse (com.cloud.api.response.DomainRouterResponse)11 NicVO (com.cloud.vm.NicVO)11 ServerApiException (com.cloud.api.ServerApiException)10 UserVmVO (com.cloud.vm.UserVmVO)10 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)10 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)9 ArrayList (java.util.ArrayList)9 ServerApiException (org.apache.cloudstack.api.ServerApiException)9 DataCenter (com.cloud.dc.DataCenter)8 Network (com.cloud.network.Network)8 DomainRouterResponse (org.apache.cloudstack.api.response.DomainRouterResponse)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)6 UpdateVmOverviewCommand (com.cloud.agent.api.UpdateVmOverviewCommand)5 VMOverviewTO (com.cloud.agent.api.to.overviews.VMOverviewTO)5 UpdateNetworkOverviewCommand (com.cloud.agent.api.UpdateNetworkOverviewCommand)4 NetworkOverviewTO (com.cloud.agent.api.to.overviews.NetworkOverviewTO)4 DeployDestination (com.cloud.deploy.DeployDestination)4 PvlanSetupCommand (com.cloud.agent.api.PvlanSetupCommand)2