use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class AddPathAbstractRouteEntry method writeRoutePath.
@SuppressWarnings("unchecked")
private void writeRoutePath(final RouteEntryInfo entryInfo, final boolean destPeerSupAddPath, final AddPathBestPath path, final TablesKey localTK, final RouteEntryDependenciesContainer routeEntryDep, final WriteTransaction tx) {
final Identifier routeKey = entryInfo.getRouteKey();
final RIBSupport ribSupport = routeEntryDep.getRibSupport();
final BGPRouteEntryExportParameters baseExp = new BGPRouteEntryExportParametersImpl(this.peerTracker.getPeer(path.getPeerId()), entryInfo.getToPeer());
final Optional<Attributes> effAttrib = routeEntryDep.getRoutingPolicies().applyExportPolicies(baseExp, path.getAttributes());
Identifier newRouteKey = ribSupport.createNewRouteKey(destPeerSupAddPath ? path.getPathId() : NON_PATH_ID_VALUE, routeKey);
final Peer toPeer = entryInfo.getToPeer();
final Route route = createRoute(ribSupport, newRouteKey, destPeerSupAddPath ? path.getPathId() : NON_PATH_ID_VALUE, path);
InstanceIdentifier ribOutIId = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), newRouteKey);
if (effAttrib.isPresent() && route != null) {
LOG.debug("Write route {} to peer AdjRibsOut {}", route, toPeer.getPeerId());
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutIId, route);
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutIId.child(Attributes.class), effAttrib.get());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class BaseAbstractRouteEntry method fillAdjRibsOut.
@VisibleForTesting
@SuppressWarnings("unchecked")
private void fillAdjRibsOut(@Nullable final Attributes attributes, @Nullable final Route route, final Identifier routeKey, final PeerId fromPeerId, final RouteEntryDependenciesContainer routeEntryDep, final WriteTransaction tx) {
/*
* We need to keep track of routers and populate adj-ribs-out, too. If we do not, we need to
* expose from which client a particular route was learned from in the local RIB, and have
* the listener perform filtering.
*
* We walk the policy set in order to minimize the amount of work we do for multiple peers:
* if we have two eBGP peers, for example, there is no reason why we should perform the translation
* multiple times.
*/
final TablesKey localTK = routeEntryDep.getLocalTablesKey();
final BGPRibRoutingPolicy routingPolicies = routeEntryDep.getRoutingPolicies();
final RIBSupport ribSupport = routeEntryDep.getRibSupport();
for (final Peer toPeer : this.peerTracker.getPeers()) {
if (!filterRoutes(fromPeerId, toPeer, localTK)) {
continue;
}
Optional<Attributes> effAttr = Optional.empty();
final Peer fromPeer = this.peerTracker.getPeer(fromPeerId);
if (fromPeer != null && attributes != null) {
final BGPRouteEntryExportParameters routeEntry = new BGPRouteEntryExportParametersImpl(fromPeer, toPeer);
effAttr = routingPolicies.applyExportPolicies(routeEntry, attributes);
}
final InstanceIdentifier ribOutTarget = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), routeKey);
if (effAttr.isPresent() && route != null) {
LOG.debug("Write route {} to peer AdjRibsOut {}", route, toPeer.getPeerId());
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutTarget, route);
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutTarget.child(Attributes.class), effAttr.get());
} else {
LOG.trace("Removing {} from transaction for peer {}", ribOutTarget, toPeer.getPeerId());
tx.delete(LogicalDatastoreType.OPERATIONAL, ribOutTarget);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method onSessionUp.
@Override
protected void onSessionUp(final PCEPSession session, final PathComputationClientBuilder pccBuilder) {
final InetAddress peerAddress = session.getRemoteAddress();
final Tlvs tlvs = session.getRemoteTlvs();
if (tlvs != null && tlvs.getAugmentation(Tlvs1.class) != null) {
final Stateful stateful = tlvs.getAugmentation(Tlvs1.class).getStateful();
if (stateful != null) {
setStatefulCapabilities(stateful);
pccBuilder.setReportedLsp(Collections.emptyList());
if (isSynchronized()) {
pccBuilder.setStateSync(PccSyncState.Synchronized);
} else if (isTriggeredInitialSynchro()) {
pccBuilder.setStateSync(PccSyncState.TriggeredInitialSync);
} else if (isIncrementalSynchro()) {
pccBuilder.setStateSync(PccSyncState.IncrementalSync);
} else {
pccBuilder.setStateSync(PccSyncState.InitialResync);
}
pccBuilder.setStatefulTlv(new StatefulTlvBuilder().addAugmentation(StatefulTlv1.class, new StatefulTlv1Builder(tlvs.getAugmentation(Tlvs1.class)).build()).build());
} else {
LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
} else {
LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testPortDescSerialize.
@Test
public void testPortDescSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(13));
MultipartReplyPortDescCaseBuilder portDescCase = new MultipartReplyPortDescCaseBuilder();
MultipartReplyPortDescBuilder portDesc = new MultipartReplyPortDescBuilder();
portDesc.setPorts(createPortList());
portDescCase.setMultipartReplyPortDesc(portDesc.build());
builder.setMultipartReplyBody(portDescCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80);
Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTDESC.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyPortDescCase body = (MultipartReplyPortDescCase) message.getMultipartReplyBody();
MultipartReplyPortDesc messageOutput = body.getMultipartReplyPortDesc();
Ports port = messageOutput.getPorts().get(0);
Assert.assertEquals("Wrong PortNo", port.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
serializedBuffer.skipBytes(4);
byte[] address = new byte[6];
serializedBuffer.readBytes(address);
Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
serializedBuffer.skipBytes(2);
byte[] name = new byte[16];
serializedBuffer.readBytes(name);
Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
Assert.assertEquals("Wrong config", port.getConfig(), createPortConfig(serializedBuffer.readInt()));
Assert.assertEquals("Wrong state", port.getState(), createPortState(serializedBuffer.readInt()));
Assert.assertEquals("Wrong current", port.getCurrentFeatures(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong advertised", port.getAdvertisedFeatures(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong supported", port.getSupportedFeatures(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong peer", port.getPeerFeatures(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong Current speed", port.getCurrSpeed().longValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong Max speed", port.getMaxSpeed().longValue(), serializedBuffer.readInt());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project openflowplugin by opendaylight.
the class OF10PortStatusMessageFactoryTest method test.
/**
* Testing {@link OF10PortStatusMessageFactory} for correct translation into POJO.
*/
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00 00 00 00 00 " + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 00 15 00 00 00 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason());
Assert.assertEquals("Wrong port - port-no", 16, builtByFactory.getPortNo().intValue());
Assert.assertEquals("Wrong builtByFactory - hw-addr", new MacAddress("01:01:05:01:04:02"), builtByFactory.getHwAddr());
Assert.assertEquals("Wrong builtByFactory - name", new String("ALOHA"), builtByFactory.getName());
Assert.assertEquals("Wrong builtByFactory - config", new PortConfigV10(true, false, false, true, false, false, true), builtByFactory.getConfigV10());
Assert.assertEquals("Wrong builtByFactory - state", new PortStateV10(false, true, false, false, false, false, true, false), builtByFactory.getStateV10());
Assert.assertEquals("Wrong builtByFactory - curr", new PortFeaturesV10(false, false, false, false, true, true, true, false, false, false, false, false), builtByFactory.getCurrentFeaturesV10());
Assert.assertEquals("Wrong builtByFactory - advertised", new PortFeaturesV10(false, false, true, true, false, false, false, false, false, false, true, false), builtByFactory.getAdvertisedFeaturesV10());
Assert.assertEquals("Wrong builtByFactory - supbuiltByFactoryed", new PortFeaturesV10(true, true, false, false, false, false, false, true, false, true, false, false), builtByFactory.getSupportedFeaturesV10());
Assert.assertEquals("Wrong builtByFactory - peer", new PortFeaturesV10(true, false, false, false, false, false, false, false, true, false, false, true), builtByFactory.getPeerFeaturesV10());
}
Aggregations