use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method stateSynchronizationAchieved.
/**
* Indicate that the peer has completed state synchronization.
*
* @param ctx Message context
*/
protected final synchronized void stateSynchronizationAchieved(final MessageContext ctx) {
if (this.synced.getAndSet(true)) {
LOG.debug("State synchronization achieved while synchronizing, not updating state");
return;
}
if (this.triggeredResyncInProcess) {
this.triggeredResyncInProcess = false;
}
updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).build());
// The node has completed synchronization, cleanup metadata no longer reported back
this.nodeState.cleanupExcept(this.lsps.values());
LOG.debug("Session {} achieved synchronized state", this.session);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer in project netvirt by opendaylight.
the class BgpConfigurationManager method replayNbrConfig.
private static boolean replayNbrConfig(List<Neighbors> neighbors, BgpRouter br) {
if (neighbors == null || neighbors.isEmpty()) {
LOG.error("Replaying nbr configuration, received NULL list ");
return true;
}
List<ReplayNbr> replayNbrList = new ArrayList<>();
for (Neighbors nbr : neighbors) {
if (nbr != null) {
replayNbrList.add(new ReplayNbr(nbr, true));
}
}
final int numberOfNbrRetries = 3;
RetryOnException nbrRetry = new RetryOnException(numberOfNbrRetries);
do {
for (ReplayNbr replayNbr : replayNbrList) {
if (!replayNbr.isShouldRetry()) {
continue;
}
boolean replayDone = false;
LOG.debug("Replaying addNbr {}", replayNbr.getNbr().getAddress().getValue());
replayDone = false;
try {
final String md5password = extractMd5Secret(replayNbr.getNbr());
br.addNeighbor(replayNbr.getNbr().getAddress().getValue(), replayNbr.getNbr().getRemoteAs().longValue(), md5password);
UpdateSource us = replayNbr.getNbr().getUpdateSource();
if (us != null) {
LOG.debug("Replaying updatesource along with nbr: {} US-ip: {} to peer {}", replayNbr.getNbr().getAddress().getValue(), us.getSourceIp().getValue(), us.getPeerIp().getValue());
br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
}
replayDone = true;
} catch (TException | BgpRouterException eNbr) {
LOG.debug("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eNbr);
}
boolean replaySuccess = true;
replaySuccess = replaySuccess && replayDone;
LOG.debug("Replay addNbr {} successful", replayNbr.getNbr().getAddress().getValue());
// Update Source handling
UpdateSource us = replayNbr.getNbr().getUpdateSource();
if (replayDone == false && us != null) {
LOG.debug("Replaying updatesource {} to peer {}", us.getSourceIp().getValue(), us.getPeerIp().getValue());
replayDone = false;
try {
br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
replayDone = true;
} catch (TException | BgpRouterException eUs) {
LOG.debug("Replaying UpdateSource for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eUs);
}
LOG.debug("Replay updatesource {} successful", us.getSourceIp().getValue());
replaySuccess = replaySuccess && replayDone;
}
// Ebgp Multihope
EbgpMultihop en = replayNbr.getNbr().getEbgpMultihop();
if (en != null) {
replayDone = false;
try {
br.addEbgpMultihop(en.getPeerIp().getValue(), en.getNhops().intValue());
replayDone = true;
} catch (TException | BgpRouterException eEbgpMhop) {
LOG.debug("Replaying EbgpMultihop for Nbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eEbgpMhop);
}
replaySuccess = replaySuccess && replayDone;
}
// afs
List<AddressFamilies> afs = replayNbr.getNbr().getAddressFamilies();
if (afs != null) {
for (AddressFamilies af : afs) {
af_afi afi = af_afi.findByValue(af.getAfi().intValue());
af_safi safi = af_safi.findByValue(af.getSafi().intValue());
replayDone = false;
try {
br.addAddressFamily(af.getPeerIp().getValue(), afi, safi);
replayDone = true;
} catch (TException | BgpRouterException eAFs) {
LOG.debug("Replaying AddressFamily for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eAFs);
}
replaySuccess = replaySuccess && replayDone;
}
}
// replay is success --> no need to replay this nbr in next iteration.
replayNbr.setShouldRetry(replaySuccess ? false : true);
}
} while (nbrRetry.decrementAndRetry());
boolean replaySuccess = true;
for (ReplayNbr replayNbr : replayNbrList) {
replaySuccess = replaySuccess && !replayNbr.isShouldRetry();
}
return replaySuccess;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer in project netvirt by opendaylight.
the class BgpConfigurationManager method extractMd5Secret.
private static String extractMd5Secret(final Neighbors val) {
String md5Secret = null;
TcpSecurityOption tcpSecOpt = val.getTcpSecurityOption();
if (tcpSecOpt != null) {
if (tcpSecOpt instanceof TcpMd5SignatureOption) {
md5Secret = ((TcpMd5SignatureOption) tcpSecOpt).getTcpMd5SignaturePassword().getValue();
} else {
// unknown TcpSecurityOption
LOG.debug("neighbors Ignored unknown tcp-security-option of peer {}", val.getAddress().getValue());
}
}
return md5Secret;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.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.bgp.rib.rev171207.bgp.rib.rib.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