Search in sources :

Example 1 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project CloudStack-archive by CloudStack-extras.

the class StopRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
    UserContext.current().setEventDetails("Router Id: " + getId());
    VirtualRouter result = _routerService.stopRouter(getId(), isForced());
    if (result != null) {
        DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop router");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 2 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class StartRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    CallContext.current().setEventDetails("Router Id: " + getId());
    VirtualRouter result = null;
    final 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) {
        final DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
        routerResponse.setResponseName(getCommandName());
        setResponseObject(routerResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start router");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 3 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class StopRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
    CallContext.current().setEventDetails("Router Id: " + getId());
    VirtualRouter result = null;
    final 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) {
        final DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop router");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 4 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class UpgradeRouterCmd method execute.

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

Example 5 with VirtualRouter

use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method destroy.

@Override
public boolean destroy(final Network config, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
    final Long vpcId = config.getVpcId();
    if (vpcId == null) {
        s_logger.debug("Network " + config + " doesn't belong to any vpc, so skipping unplug nic part");
        return true;
    }
    boolean success = true;
    final List<? extends VirtualRouter> routers = _routerDao.listByVpcId(vpcId);
    for (final VirtualRouter router : routers) {
        // 1) Check if router is already a part of the network
        if (!_networkMdl.isVmPartOfNetwork(router.getId(), config.getId())) {
            s_logger.debug("Router " + router + " is not a part the network " + config);
            continue;
        }
        // 2) Call unplugNics in the network service
        success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, config);
        if (!success) {
            s_logger.warn("Failed to unplug nic in network " + config + " for virtual router " + router);
        } else {
            s_logger.debug("Successfully unplugged nic in network " + config + " for virtual router " + router);
        }
    }
    return success;
}
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