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;
}
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());
}
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()));
}
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;
}
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();
}
Aggregations