Search in sources :

Example 61 with VirtualRouter

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

the class AdvancedNetworkTopology method applyStaticRoutes.

@Override
public boolean applyStaticRoutes(final List<StaticRouteProfile> staticRoutes, final List<DomainRouterVO> routers) throws ResourceUnavailableException {
    s_logger.debug("APPLYING STATIC ROUTES RULES");
    if (staticRoutes == null || staticRoutes.isEmpty()) {
        s_logger.debug("No static routes to apply");
        return true;
    }
    final StaticRoutesRules routesRules = new StaticRoutesRules(staticRoutes);
    boolean result = true;
    for (final VirtualRouter router : routers) {
        if (router.getState() == State.Running) {
            result = result && routesRules.accept(_advancedVisitor, router);
        } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
            s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending StaticRoute command to the backend");
        } else {
            s_logger.warn("Unable to apply StaticRoute, virtual router is not in the right state " + router.getState());
            throw new ResourceUnavailableException("Unable to apply StaticRoute on the backend," + " virtual router is not in the right state", DataCenter.class, router.getDataCenterId());
        }
    }
    return result;
}
Also used : DataCenter(com.cloud.dc.DataCenter) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) StaticRoutesRules(com.cloud.network.rules.StaticRoutesRules) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 62 with VirtualRouter

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

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final AdvancedVpnRules vpnRules) throws ResourceUnavailableException {
    final VirtualRouter router = vpnRules.getRouter();
    final Commands cmds = new Commands(Command.OnError.Continue);
    final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null, null);
    final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
    cmds.addCommand(updateNetworkOverviewCommand);
    // results accordingly
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.agent.api.to.overviews.NetworkOverviewTO) UpdateNetworkOverviewCommand(com.cloud.agent.api.UpdateNetworkOverviewCommand) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 63 with VirtualRouter

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

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final PublicIpAclsRules acls) throws ResourceUnavailableException {
    final VirtualRouter router = acls.getRouter();
    final Commands commands = new Commands(Command.OnError.Continue);
    final List<? extends NetworkACLItem> rules = acls.getRules();
    _commandSetupHelper.createPublicIpACLsCommands(rules, router, commands, acls.getPublicIp());
    return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
Also used : Commands(com.cloud.agent.manager.Commands) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 64 with VirtualRouter

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

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final UserdataPwdRules userdata) throws ResourceUnavailableException {
    final VirtualRouter router = userdata.getRouter();
    final Commands commands = new Commands(Command.OnError.Stop);
    final VirtualMachineProfile profile = userdata.getProfile();
    final NicVO nicVO = userdata.getNicVo();
    _commandSetupHelper.createPasswordCommand(router, profile, nicVO, commands);
    final VMOverviewTO vmOverview = _commandSetupHelper.createVmOverviewFromRouter(router);
    final UpdateVmOverviewCommand updateVmOverviewCommand = _commandSetupHelper.createUpdateVmOverviewCommand(router, vmOverview);
    commands.addCommand(updateVmOverviewCommand);
    return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
Also used : VMOverviewTO(com.cloud.agent.api.to.overviews.VMOverviewTO) Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter) UpdateVmOverviewCommand(com.cloud.agent.api.UpdateVmOverviewCommand)

Example 65 with VirtualRouter

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

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final DhcpEntryRules dhcp) throws ResourceUnavailableException {
    final VirtualRouter router = dhcp.getRouter();
    final Commands commands = new Commands(Command.OnError.Stop);
    final DeployDestination destination = dhcp.getDestination();
    return router.getPodIdToDeployIn() != destination.getPod().getId() || _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
Also used : DeployDestination(com.cloud.deploy.DeployDestination) Commands(com.cloud.agent.manager.Commands) 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