Package org.midonet.client.resource

Examples of org.midonet.client.resource.Router


         * this function could be called as a part of network cleanup. In
         * that case, we do not want to recreate the guest network or
         * any ports.
         */
        boolean resources = false;
        Router tenantRouter = null;
        Router providerRouter = null;
        RouterPort[] ports = null;

        RouterPort tenantUplink = null;
        RouterPort providerDownlink = null;

View Full Code Here


        if (!canHandle(network, Service.StaticNat)) {
            return false;
        }

        boolean resources = false;
        Router tenantRouter = null;
        Router providerRouter = null;

        RouterPort[] ports = null;

        RouterPort tenantUplink = null;
        RouterPort providerDownlink = null;
View Full Code Here

        }

        if(network.getTrafficType() == Networks.TrafficType.Guest){
            // Create the Midonet bridge for this network
            Bridge netBridge = getOrCreateNetworkBridge(network);
            Router tenantRouter = getOrCreateGuestNetworkRouter(network);

            // connect router and bridge
            ensureBridgeConnectedToRouter(network, netBridge, tenantRouter);
        }
View Full Code Here

                nic.getBroadcastType() == Networks.BroadcastDomainType.Mido){
            Bridge netBridge = getOrCreateNetworkBridge(network);
            if(nic.getTrafficType() == Networks.TrafficType.Public &&
                vm.getVirtualMachine().getType() != VirtualMachine.Type.DomainRouter){
                // Get provider router
                Router providerRouter = api.getRouter(_providerRouterId);

                Port[] ports = getOrCreatePublicBridgePorts(nic, netBridge, providerRouter);

                RouterPort providerDownlink = (RouterPort) ports[1];

                // Set route from router to bridge for this particular IP. Prepare
                // is called in both starting a new VM and restarting a VM, so the
                // NIC may
                boolean routeExists = false;
                for (Route route : providerRouter.getRoutes(new MultivaluedMapImpl())) {
                    String ip4 = route.getDstNetworkAddr();
                    if (ip4 != null && ip4.equals(nic.getIp4Address())) {
                        routeExists = true;
                        break;
                    }
                }

                if (!routeExists) {
                    providerRouter.addRoute()
                                  .type("Normal")
                                  .weight(100)
                                  .srcNetworkAddr("0.0.0.0")
                                  .srcNetworkLength(0)
                                  .dstNetworkAddr(nic.getIp4Address())
View Full Code Here

                (nic.getTrafficType() == Networks.TrafficType.Public &&
                nic.getBroadcastType() == Networks.BroadcastDomainType.Mido)) {
            // Seems like a good place to remove the port in midonet
            Bridge netBridge = getOrCreateNetworkBridge(network);

            Router providerRouter = api.getRouter(_providerRouterId);

            //remove the routes associated with this IP address
            for (Route route : providerRouter.getRoutes(new MultivaluedMapImpl())) {
                String routeDstAddr = route.getDstNetworkAddr();
                if (routeDstAddr != null && routeDstAddr.equals(nic.getIp4Address())) {
                    route.delete();
                }
            }
View Full Code Here

        String accountIdStr = getAccountUuid(network);
        String networkUUIDStr = String.valueOf(network.getId());
        RuleChain preNat = getChain(accountIdStr, networkUUIDStr, RuleChainCode.TR_PRENAT);
        RuleChain postNat = getChain(accountIdStr, networkUUIDStr, RuleChainCode.TR_POST);
        RuleChain preFilter = getChain(accountIdStr, networkUUIDStr, RuleChainCode.TR_PREFILTER);
        Router providerRouter = api.getRouter(_providerRouterId);
        Router tenantRouter = getOrCreateGuestNetworkRouter(network);
        RouterPort[] ports = getOrCreateProviderRouterPorts(tenantRouter, providerRouter);
        RouterPort providerDownlink = ports[1];

        // Rules in the preNat table
        Map<String, Rule> existingPreNatRules = new HashMap<String, Rule>();
View Full Code Here

                   .outboundFilterId(post.getId())
                   .create();
    }

    private Router getOrCreateGuestNetworkRouter(long id, String accountUuid, boolean isVpc) {
        Router tenantRouter = getGuestNetworkRouter(id, accountUuid, isVpc);
        if(tenantRouter == null){
            tenantRouter = createRouter(id, accountUuid, isVpc);
        }
        return tenantRouter;
    }
View Full Code Here

    private void deleteGuestNetworkRouters(Network network){
        String accountUuid = getAccountUuid(network);
        boolean isVpc = getIsVpc(network);
        long id = getRouterId(network, isVpc);

        Router tenantRouter = getGuestNetworkRouter(id, accountUuid, isVpc);

        // Delete any peer ports corresponding to this router
        for(Port peerPort : tenantRouter.getPeerPorts((new MultivaluedMapImpl()))){
            if(peerPort != null && peerPort instanceof RouterPort){
                RouterPort checkPort = (RouterPort) peerPort;
                if(checkPort.getType().equals("ExteriorRouter")) {
                    checkPort.vifId(null).update();
                } else if (checkPort.getType().equals("InteriorRouter")) {
                    checkPort.unlink();
                }
                checkPort.delete();
            } else if (peerPort != null && peerPort instanceof BridgePort) {
                BridgePort checkPort = (BridgePort) peerPort;
                if(checkPort.getType().equals("ExteriorBridge")) {
                    checkPort.vifId(null).update();
                } else if (checkPort.getType().equals("InteriorBridge")) {
                    checkPort.unlink();
                }
                checkPort.delete();
            }
        }

        if(tenantRouter != null){
            // Remove all peer ports if any exist
            for(RouterPort p : tenantRouter.getPorts(new MultivaluedMapImpl())) {
                if(p.getType().equals("ExteriorRouter")) {
                    // Set VIF ID to null
                    p.vifId(null).update();
                    // the port might have some chains associated with it
                }

                if(p.getType().equals("InteriorRouter")) {
                    p.unlink();
                }

                // Delete port
                p.delete();
            }

            // Remove inbound and outbound filter chains
            String accountIdStr = String.valueOf(accountUuid);
            String routerName = getRouterName(isVpc, id);

            RuleChain pre = api.getChain(tenantRouter.getInboundFilterId());
            RuleChain preFilter = getChain(accountIdStr, routerName, RuleChainCode.TR_PREFILTER);
            RuleChain preNat = getChain(accountIdStr, routerName, RuleChainCode.TR_PRENAT);
            RuleChain post = api.getChain(tenantRouter.getOutboundFilterId());

            pre.delete();
            preFilter.delete();
            preNat.delete();
            post.delete();


            // Remove routes
            for(Route r : tenantRouter.getRoutes(new MultivaluedMapImpl())) {
                r.delete();
            }

            tenantRouter.delete();
        }
    }
View Full Code Here

        Bridge mockBridge = mock(Bridge.class);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.getDhcpSubnets()).thenReturn(mockSubnetCollection);

        //mockRouter
        Router mockRouter = mock(Router.class);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
View Full Code Here

        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.addInteriorPort().create()).thenReturn(mockBPort);
        when(mockBridge.getPeerPorts()).thenReturn(peerPorts);

        //mockRouter
        Router mockRouter = mock(Router.class, RETURNS_DEEP_STUBS);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);
        when(mockRouter.addInteriorRouterPort().create()).thenReturn(mockRPort);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
        when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
View Full Code Here

TOP

Related Classes of org.midonet.client.resource.Router

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.