Search in sources :

Example 21 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables in project openflowplugin by opendaylight.

the class ReconcileUtil method resolveFlowDiffsInAllTables.

/**
 * Resolves flow differences in all tables.
 *
 * @param nodeId              target node
 * @param tableOperationalMap flow-tables resent on device
 * @param tablesConfigured    flow-tables configured for device
 * @param gatherUpdates       check content of pending item if present on device (and create update task eventually)
 * @return map : key={@link TableKey}, value={@link ItemSyncBox} of safe synchronization steps
 */
public static Map<TableKey, ItemSyncBox<Flow>> resolveFlowDiffsInAllTables(final NodeId nodeId, final Map<Short, Table> tableOperationalMap, final List<Table> tablesConfigured, final boolean gatherUpdates) {
    LOG.trace("resolving flows in tables for {}", nodeId.getValue());
    final Map<TableKey, ItemSyncBox<Flow>> tableFlowSyncBoxes = new HashMap<>();
    for (final Table tableConfigured : tablesConfigured) {
        final List<Flow> flowsConfigured = tableConfigured.getFlow();
        if (flowsConfigured == null || flowsConfigured.isEmpty()) {
            continue;
        }
        // lookup table (on device)
        final Table tableOperational = tableOperationalMap.get(tableConfigured.getId());
        // wrap existing (on device) flows in current table into map
        final Map<FlowDescriptor, Flow> flowOperationalMap = FlowCapableNodeLookups.wrapFlowsToMap(tableOperational != null ? tableOperational.getFlow() : null);
        final ItemSyncBox<Flow> flowsSyncBox = resolveFlowDiffsInTable(flowsConfigured, flowOperationalMap, gatherUpdates);
        if (!flowsSyncBox.isEmpty()) {
            tableFlowSyncBoxes.put(tableConfigured.getKey(), flowsSyncBox);
        }
    }
    return tableFlowSyncBoxes;
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) HashMap(java.util.HashMap) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 22 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables in project openflowplugin by opendaylight.

the class FeaturesReplyMessageFactoryTest method test.

/**
 * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + " 00 00 00 00 01 02 03");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
    Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
    Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue());
    Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue());
    Assert.assertEquals("Wrong capabilities", new Capabilities(false, false, false, false, false, false, false), builtByFactory.getCapabilities());
    Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue());
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 23 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables in project openflowplugin by opendaylight.

the class OF10FeaturesReplyMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setDatapathId(BigInteger.valueOf(1L));
    builder.setBuffers(1L);
    builder.setTables((short) 1);
    builder.setCapabilitiesV10(new CapabilitiesV10(true, false, true, false, true, false, true, false));
    builder.setActionsV10(new ActionTypeV10(true, false, true, false, true, false, true, false, true, false, true, false, true));
    builder.setPhyPort(createPorts());
    GetFeaturesOutput message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 80);
    Assert.assertEquals("Wrong datapath id", message.getDatapathId().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong n buffers", message.getBuffers().longValue(), serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong n tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(3);
    Assert.assertEquals("Wrong capabilities", message.getCapabilitiesV10(), createCapabilities(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", message.getActionsV10(), createActionsV10(serializedBuffer.readInt()));
    PhyPort port = message.getPhyPort().get(0);
    Assert.assertEquals("Wrong port No", port.getPortNo().intValue(), serializedBuffer.readShort());
    byte[] address = new byte[6];
    serializedBuffer.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
    byte[] name = new byte[16];
    serializedBuffer.readBytes(name);
    Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
    Assert.assertEquals("Wrong config", port.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong state", port.getStateV10(), createPortState(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong current", port.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong advertised", port.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong supported", port.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong peer", port.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
}
Also used : GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) ActionTypeV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) PhyPort(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort) CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Example 24 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables in project bgpcep by opendaylight.

the class BmpMonitorImplTest method testMonitoringStation.

private Channel testMonitoringStation(final String remoteRouterIpAddr) throws InterruptedException, ReadFailedException {
    final Channel channel = connectTestClient(remoteRouterIpAddr, this.msgRegistry);
    final RouterId routerId = getRouterId(remoteRouterIpAddr);
    readDataOperational(getDataBroker(), MONITOR_IID, monitor -> {
        assertFalse(monitor.getRouter().isEmpty());
        // now find the current router instance
        Router router = null;
        for (final Router r : monitor.getRouter()) {
            if (routerId.equals(r.getRouterId())) {
                router = r;
                break;
            }
        }
        assertNotNull(router);
        assertEquals(Status.Down, router.getStatus());
        assertTrue(router.getPeer().isEmpty());
        return router;
    });
    waitWriteAndFlushSuccess(channel.writeAndFlush(TestUtil.createInitMsg("description", "name", "some info")));
    readDataOperational(getDataBroker(), MONITOR_IID, monitor -> {
        assertFalse(monitor.getRouter().isEmpty());
        Router retRouter = null;
        for (final Router r : monitor.getRouter()) {
            if (routerId.equals(r.getRouterId())) {
                retRouter = r;
                break;
            }
        }
        assertEquals("some info;", retRouter.getInfo());
        assertEquals("name", retRouter.getName());
        assertEquals("description", retRouter.getDescription());
        assertEquals(routerId, retRouter.getRouterId());
        assertTrue(retRouter.getPeer().isEmpty());
        assertEquals(Status.Up, retRouter.getStatus());
        return retRouter;
    });
    waitWriteAndFlushSuccess(channel.writeAndFlush(TestUtil.createPeerUpNotification(PEER1, true)));
    final KeyedInstanceIdentifier<Router, RouterKey> routerIId = MONITOR_IID.child(Router.class, new RouterKey(routerId));
    readDataOperational(getDataBroker(), routerIId, router -> {
        final List<Peer> peers = router.getPeer();
        assertEquals(1, peers.size());
        final Peer peer = peers.get(0);
        assertEquals(PeerType.Global, peer.getType());
        assertEquals(PEER_ID, peer.getPeerId());
        assertEquals(PEER1, peer.getBgpId());
        assertEquals(TestUtil.IPV4_ADDRESS_10, peer.getAddress().getIpv4Address());
        assertEquals(TestUtil.PEER_AS, peer.getAs());
        assertNull(peer.getPeerDistinguisher());
        assertNull(peer.getStats());
        assertNotNull(peer.getPrePolicyRib());
        assertEquals(1, peer.getPrePolicyRib().getTables().size());
        final Tables prePolicyTable = peer.getPrePolicyRib().getTables().get(0);
        assertEquals(Ipv4AddressFamily.class, prePolicyTable.getAfi());
        assertEquals(UnicastSubsequentAddressFamily.class, prePolicyTable.getSafi());
        assertFalse(prePolicyTable.getAttributes().isUptodate());
        assertNotNull(prePolicyTable.getRoutes());
        assertNotNull(peer.getPostPolicyRib());
        assertEquals(1, peer.getPostPolicyRib().getTables().size());
        final Tables postPolicyTable = peer.getPrePolicyRib().getTables().get(0);
        assertEquals(Ipv4AddressFamily.class, postPolicyTable.getAfi());
        assertEquals(UnicastSubsequentAddressFamily.class, postPolicyTable.getSafi());
        assertFalse(postPolicyTable.getAttributes().isUptodate());
        assertNotNull(postPolicyTable.getRoutes());
        assertNotNull(peer.getPeerSession());
        final PeerSession peerSession = peer.getPeerSession();
        assertEquals(TestUtil.IPV4_ADDRESS_10, peerSession.getLocalAddress().getIpv4Address());
        assertEquals(TestUtil.PEER_LOCAL_PORT, peerSession.getLocalPort());
        assertEquals(TestUtil.PEER_REMOTE_PORT, peerSession.getRemotePort());
        assertEquals(Status.Up, peerSession.getStatus());
        assertNotNull(peerSession.getReceivedOpen());
        assertNotNull(peerSession.getSentOpen());
        return router;
    });
    final StatsReportsMessage statsMsg = TestUtil.createStatsReportMsg(PEER1);
    waitWriteAndFlushSuccess(channel.writeAndFlush(statsMsg));
    final KeyedInstanceIdentifier<Peer, PeerKey> peerIId = routerIId.child(Peer.class, new PeerKey(PEER_ID));
    readDataOperational(getDataBroker(), peerIId.child(Stats.class), peerStats -> {
        assertNotNull(peerStats.getTimestampSec());
        final Tlvs tlvs = statsMsg.getTlvs();
        assertEquals(tlvs.getAdjRibsInRoutesTlv().getCount(), peerStats.getAdjRibsInRoutes());
        assertEquals(tlvs.getDuplicatePrefixAdvertisementsTlv().getCount(), peerStats.getDuplicatePrefixAdvertisements());
        assertEquals(tlvs.getDuplicateWithdrawsTlv().getCount(), peerStats.getDuplicateWithdraws());
        assertEquals(tlvs.getInvalidatedAsConfedLoopTlv().getCount(), peerStats.getInvalidatedAsConfedLoop());
        assertEquals(tlvs.getInvalidatedAsPathLoopTlv().getCount(), peerStats.getInvalidatedAsPathLoop());
        assertEquals(tlvs.getInvalidatedClusterListLoopTlv().getCount(), peerStats.getInvalidatedClusterListLoop());
        assertEquals(tlvs.getInvalidatedOriginatorIdTlv().getCount(), peerStats.getInvalidatedOriginatorId());
        assertEquals(tlvs.getLocRibRoutesTlv().getCount(), peerStats.getLocRibRoutes());
        assertEquals(tlvs.getRejectedPrefixesTlv().getCount(), peerStats.getRejectedPrefixes());
        assertEquals(tlvs.getPerAfiSafiAdjRibInTlv().getCount().toString(), peerStats.getPerAfiSafiAdjRibInRoutes().getAfiSafi().get(0).getCount().toString());
        assertEquals(tlvs.getPerAfiSafiLocRibTlv().getCount().toString(), peerStats.getPerAfiSafiLocRibRoutes().getAfiSafi().get(0).getCount().toString());
        return peerStats;
    });
    // route mirror message test
    final RouteMirroringMessage routeMirrorMsg = TestUtil.createRouteMirrorMsg(PEER1);
    waitWriteAndFlushSuccess(channel.writeAndFlush(routeMirrorMsg));
    readDataOperational(getDataBroker(), peerIId.child(Mirrors.class), routeMirrors -> {
        assertNotNull(routeMirrors.getTimestampSec());
        return routeMirrors;
    });
    waitWriteAndFlushSuccess(channel.writeAndFlush(createRouteMonitMsg(false, PEER1, AdjRibInType.PrePolicy)));
    waitWriteAndFlushSuccess(channel.writeAndFlush(createRouteMonMsgWithEndOfRibMarker(PEER1, AdjRibInType.PrePolicy)));
    readDataOperational(getDataBroker(), peerIId.child(PrePolicyRib.class), prePolicyRib -> {
        assertTrue(!prePolicyRib.getTables().isEmpty());
        final Tables tables = prePolicyRib.getTables().get(0);
        assertTrue(tables.getAttributes().isUptodate());
        assertEquals(3, ((Ipv4RoutesCase) tables.getRoutes()).getIpv4Routes().getIpv4Route().size());
        return tables;
    });
    waitWriteAndFlushSuccess(channel.writeAndFlush(createRouteMonitMsg(false, PEER1, AdjRibInType.PostPolicy)));
    waitWriteAndFlushSuccess(channel.writeAndFlush(createRouteMonMsgWithEndOfRibMarker(PEER1, AdjRibInType.PostPolicy)));
    readDataOperational(getDataBroker(), peerIId.child(PostPolicyRib.class), postPolicyRib -> {
        assertTrue(!postPolicyRib.getTables().isEmpty());
        final Tables tables = postPolicyRib.getTables().get(0);
        assertTrue(tables.getAttributes().isUptodate());
        assertEquals(3, ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.bmp.monitor.monitor.router.peer.post.policy.rib.tables.routes.Ipv4RoutesCase) tables.getRoutes()).getIpv4Routes().getIpv4Route().size());
        return tables;
    });
    waitWriteAndFlushSuccess(channel.writeAndFlush(TestUtil.createPeerDownNotification(PEER1)));
    readDataOperational(getDataBroker(), routerIId, router -> {
        final List<Peer> peersAfterDown = router.getPeer();
        assertTrue(peersAfterDown.isEmpty());
        return router;
    });
    return channel;
}
Also used : MockitoAnnotations(org.mockito.MockitoAnnotations) BindingReflections(org.opendaylight.yangtools.yang.binding.util.BindingReflections) RouteMirroringMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.RouteMirroringMessage) RouterId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId) RouterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.RouterKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) StatsReportsMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.StatsReportsMessage) Mirrors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Mirrors) PostPolicyRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.PostPolicyRib) PrePolicyRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.PrePolicyRib) SocketChannel(io.netty.channel.socket.SocketChannel) EpollSocketChannel(io.netty.channel.epoll.EpollSocketChannel) Channel(io.netty.channel.Channel) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) Peer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.Peer) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router) PeerKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.PeerKey) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.stat.Tlvs) PeerSession(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.PeerSession) Stats(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Stats)

Example 25 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables in project bgpcep by opendaylight.

the class Ipv4ReachabilityTopologyBuilderTest method setUp.

@Before
@Override
public void setUp() {
    super.setUp();
    this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID);
    this.ipv4TopoBuilder.start();
    final InstanceIdentifier<Tables> path = LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class).child(Tables.class, new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)).build();
    this.ipv4RouteIID = path.builder().child((Class) Ipv4Routes.class).child(Ipv4Route.class, new Ipv4RouteKey(new PathId(PATH_ID), new Ipv4Prefix(ROUTE_IP4PREFIX))).build();
}
Also used : PathId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) Ipv4RouteKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4RouteKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Before(org.junit.Before)

Aggregations

Tables (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables)13 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)10 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)9 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)8 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)6 Map (java.util.Map)6 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)6 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)6 ByteBuf (io.netty.buffer.ByteBuf)5 BigInteger (java.math.BigInteger)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 HashMap (java.util.HashMap)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)4 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)4 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)4