use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnErrorMessage.
@Test
public void testOnErrorMessage() throws InterruptedException, ExecutionException {
final Message errorMsg = MsgBuilderUtil.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, 1L);
this.listener.onSessionUp(this.session);
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
this.listener.onMessage(this.session, errorMsg);
final AddLspOutput output = futureOutput.get().getResult();
assertEquals(FailureType.Failed, output.getFailure());
assertEquals(1, output.getError().size());
final ErrorObject err = output.getError().get(0).getErrorObject();
assertEquals(PCEPErrors.NON_ZERO_PLSPID.getErrorType(), err.getType().shortValue());
assertEquals(PCEPErrors.NON_ZERO_PLSPID.getErrorValue(), err.getValue().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnUnhandledErrorMessage.
@Test
public void testOnUnhandledErrorMessage() {
final Message errorMsg = AbstractMessageParser.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, Optional.absent());
this.listener.onSessionUp(this.session);
assertTrue(this.listener.onMessage(Optional.<AbstractTopologySessionListener.MessageContext>absent().orNull(), errorMsg));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method updateLsp.
/**
* Update an LSP in the data store.
*
* @param ctx Message context
* @param id Revision-specific LSP identifier
* @param lspName LSP name
* @param rlb Reported LSP builder
* @param solicited True if the update was solicited
* @param remove True if this is an LSP path removal
*/
protected final synchronized void updateLsp(final MessageContext ctx, final L id, final String lspName, final ReportedLspBuilder rlb, final boolean solicited, final boolean remove) {
final String name;
if (lspName == null) {
name = this.lsps.get(id);
if (name == null) {
LOG.error("PLSPID {} seen for the first time, not reporting the LSP", id);
return;
}
} else {
name = lspName;
}
LOG.debug("Saved LSP {} with name {}", id, name);
this.lsps.put(id, name);
final ReportedLsp previous = this.lspData.get(name);
// if no previous report about the lsp exist, just proceed
if (previous != null) {
final List<Path> updatedPaths = makeBeforeBreak(rlb, previous, name, remove);
// if all paths or the last path were deleted, delete whole tunnel
if (updatedPaths.isEmpty()) {
LOG.debug("All paths were removed, removing LSP with {}.", id);
removeLsp(ctx, id);
return;
}
rlb.setPath(updatedPaths);
}
rlb.setKey(new ReportedLspKey(name));
rlb.setName(name);
// If this is an unsolicited update. We need to make sure we retain the metadata already present
if (solicited) {
this.nodeState.setLspMetadata(name, rlb.getMetadata());
} else {
rlb.setMetadata(this.nodeState.getLspMetadata(name));
}
final ReportedLsp rl = rlb.build();
ctx.trans.put(LogicalDatastoreType.OPERATIONAL, this.pccIdentifier.child(ReportedLsp.class, rlb.getKey()), rl);
LOG.debug("LSP {} updated to MD-SAL", name);
this.lspData.put(name, rl);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method makeBeforeBreak.
private List<Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous, final String name, final boolean remove) {
// just one path should be reported
Preconditions.checkState(rlb.getPath().size() == 1);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId reportedLspId = rlb.getPath().get(0).getLspId();
final List<Path> updatedPaths;
// remove existing tunnel's paths now, as explicit path remove will not come
if (!remove && reportedLspId.getValue() == 0) {
updatedPaths = new ArrayList<>();
LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
} else {
// check previous report for existing paths
updatedPaths = new ArrayList<>(previous.getPath());
LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
for (final Path path : previous.getPath()) {
// we found reported path in previous reports
if (path.getLspId().getValue() == 0 || path.getLspId().equals(reportedLspId)) {
LOG.debug("Match on lsp-id {}", path.getLspId().getValue());
// path that was reported previously and does have the same lsp-id, path will be updated
final boolean r = updatedPaths.remove(path);
LOG.trace("Request removed? {}", r);
}
}
}
// if the path does not exist in previous report, add it to path list, it's a new ERO
// only one path will be added
// lspId is 0 means confirmation message that shouldn't be added (because we have no means of deleting it later)
LOG.trace("Adding new path {} to {}", rlb.getPath(), updatedPaths);
updatedPaths.addAll(rlb.getPath());
if (remove) {
if (reportedLspId.getValue() == 0) {
// if lsp-id also 0, remove all paths
LOG.debug("Removing all paths.");
updatedPaths.clear();
} else {
// path is marked to be removed
LOG.debug("Removing path {} from {}", rlb.getPath(), updatedPaths);
final boolean r = updatedPaths.removeAll(rlb.getPath());
LOG.trace("Request removed? {}", r);
}
}
LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
return updatedPaths;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project bgpcep by opendaylight.
the class AbstractMessageParserTest method testParseVendorInformationObject.
@Test
public void testParseVendorInformationObject() throws PCEPDeserializerException {
final Abs parser = new Abs(this.registry);
final ByteBuf buffer = Unpooled.buffer();
parser.serializeVendorInformationObjects(Lists.newArrayList(this.viObject), buffer);
Mockito.verify(this.registry, Mockito.only()).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
final Message msg = parser.parseMessage(Unpooled.wrappedBuffer(new byte[] { 0x22, 0x13, 0x00, 0x08, 0, 0, 0, 0 }), Collections.emptyList());
assertEquals(this.viObject, ((Pcrep) msg).getPcrepMessage().getReplies().get(0).getVendorInformationObject().get(0));
}
Aggregations