Search in sources :

Example 31 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class StartRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    CallContext.current().setEventDetails("Router Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
    VirtualRouter result = null;
    VirtualRouter router = _routerService.findRouter(getId());
    if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
        throw new InvalidParameterValueException("Can't find router by id");
    } else {
        result = _routerService.startRouter(getId());
    }
    if (result != null) {
        DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
        routerResponse.setResponseName(getCommandName());
        setResponseObject(routerResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start router");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) DomainRouterResponse(org.apache.cloudstack.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 32 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class UpgradeRouterCmd method execute.

@Override
public void execute() {
    VirtualRouter router = _routerService.upgradeRouter(this);
    if (router != null) {
        DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router);
        routerResponse.setResponseName(getCommandName());
        setResponseObject(routerResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade router");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) DomainRouterResponse(org.apache.cloudstack.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 33 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class StopRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
    CallContext.current().setEventDetails("Router Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
    VirtualRouter result = null;
    VirtualRouter router = _routerService.findRouter(getId());
    if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
        throw new InvalidParameterValueException("Can't find router by id");
    } else {
        result = _routerService.stopRouter(getId(), isForced());
    }
    if (result != null) {
        DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop router");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) DomainRouterResponse(org.apache.cloudstack.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 34 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class StartInternalLBVMCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    CallContext.current().setEventDetails("Internal Lb Vm Id: " + getId());
    VirtualRouter result = null;
    VirtualRouter router = _routerService.findRouter(getId());
    if (router == null || router.getRole() != Role.INTERNAL_LB_VM) {
        throw new InvalidParameterValueException("Can't find internal lb vm by id");
    } else {
        result = _internalLbSvc.startInternalLbVm(getId(), CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId());
    }
    if (result != null) {
        DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
        routerResponse.setResponseName(getCommandName());
        setResponseObject(routerResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start internal lb vm");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) DomainRouterResponse(org.apache.cloudstack.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 35 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.

the class InternalLoadBalancerElement method destroy.

@Override
public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
    List<? extends VirtualRouter> internalLbVms = _routerDao.listByNetworkAndRole(network.getId(), Role.INTERNAL_LB_VM);
    if (internalLbVms == null || internalLbVms.isEmpty()) {
        return true;
    }
    boolean result = true;
    for (VirtualRouter internalLbVm : internalLbVms) {
        result = result && (_internalLbMgr.destroyInternalLbVm(internalLbVm.getId(), context.getAccount(), context.getCaller().getId()));
    }
    return result;
}
Also used : 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