public static <REP extends JVppReply<?>> REP getReplyForRead(@Nonnull Future<REP> future, @Nonnull final InstanceIdentifier<?> replyType, @Nonnegative final int timeoutInSeconds) throws VppBaseCallException, ReadTimeoutException { try { return getReply(future, timeoutInSeconds); } catch (TimeoutException e) { throw new ReadTimeoutException(replyType, e); } }
private static Optional<IpAddressDetailsReplyDump> dumpAddressFromOperationalData( @Nonnull final FutureJVppCore futureJVppCore, @Nonnull final InstanceIdentifier<?> id, final int interfaceIndex) throws VppBaseCallException, ReadTimeoutException { LOG.debug("Dumping Ipv4 addresses for interface id={}", interfaceIndex); final IpAddressDump dumpRequest = new IpAddressDump(); dumpRequest.isIpv6 = 0; dumpRequest.swIfIndex = interfaceIndex; return Optional.fromNullable( TranslateUtils.getReplyForRead(futureJVppCore.ipAddressDump(dumpRequest).toCompletableFuture(), id)); }
@Nonnull private List<L2FibTableEntry> dumpL2Fibs(final InstanceIdentifier<L2FibEntry> id, final int bdId) throws VppBaseCallException, ReadTimeoutException { final L2FibTableDump l2FibRequest = new L2FibTableDump(); l2FibRequest.bdId = bdId; final CompletableFuture<L2FibTableEntryReplyDump> l2FibTableDumpCompletableFuture = getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture(); final L2FibTableEntryReplyDump dump = TranslateUtils.getReplyForRead(l2FibTableDumpCompletableFuture, id); if (null == dump || null == dump.l2FibTableEntry) { return Collections.emptyList(); } else { return dump.l2FibTableEntry; } }
private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier<?> id) throws ReadFailedException { try { // We need to perform full bd dump, because there is no way // to ask VPP for BD details given interface id/name (TODO add it to vpp.api?) // TODO cache dump result final BridgeDomainDump request = new BridgeDomainDump(); request.bdId = -1; final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture = futureJVppCore.bridgeDomainSwIfDump(request).toCompletableFuture(); return TranslateUtils.getReplyForRead(bdCompletableFuture, id); } catch (VppBaseCallException e) { throw new ReadFailedException(id, e); } } }
@Nonnull @Override public List<ClassifyTableKey> getAllIds(@Nonnull final InstanceIdentifier<ClassifyTable> id, @Nonnull final ReadContext context) throws ReadFailedException { LOG.debug("Reading list of keys for classify tables: {}", id); try { final ClassifyTableIdsReply classifyTableIdsReply = TranslateUtils .getReplyForRead(getFutureJVpp().classifyTableIds(new ClassifyTableIds()).toCompletableFuture(), id); if (classifyTableIdsReply.ids != null) { return Arrays.stream(classifyTableIdsReply.ids).mapToObj(i -> { final String tableName = classifyTableContext.getTableName(i, context.getMappingContext()); LOG.trace("Classify table with name: {} and index: {} found in VPP", tableName, i); return new ClassifyTableKey(tableName); }).collect(Collectors.toList()); } else { return Collections.emptyList(); } } catch (VppBaseCallException e) { throw new ReadFailedException(id, e); } } }
try { CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJVppCore.swInterfaceDump(request); ifaces = TranslateUtils.getReplyForRead(requestFuture.toCompletableFuture(), id); if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) { request.nameFilterValid = 0; ifaces = TranslateUtils.getReplyForRead(requestFuture.toCompletableFuture(), id);
private int nodeNameToIndex(@Nonnull final ClassifyTable classifyTable, @Nonnull final String nextNodeName, @Nonnull final VppClassifierContextManager vppClassifierContextManager, @Nonnull final MappingContext ctx, @Nonnull final InstanceIdentifier<?> id) throws VppBaseCallException, WriteFailedException { checkArgument(classifyTable != null && classifyTable.getClassifierNode() != null, "to use relative node names, table classifier node needs to be provided"); final GetNextIndex request = new GetNextIndex(); request.nodeName = classifyTable.getClassifierNode().getValue().getBytes(); request.nextName = nextNodeName.getBytes(); final CompletionStage<GetNextIndexReply> getNextIndexCompletionStage = getFutureJVpp().getNextIndex(request); final GetNextIndexReply reply; try { reply = TranslateUtils.getReplyForRead(getNextIndexCompletionStage.toCompletableFuture(), id); // vpp does not provide relative node index to node name conversion (https://jira.fd.io/browse/VPP-219) // as a workaround we need to add mapping to vpp-classfier-context vppClassifierContextManager.addNodeName(classifyTable.getName(), reply.nextIndex, nextNodeName, ctx); } catch (ReadTimeoutException e) { throw new WriteFailedException(id, String.format("Failed to get node index for %s relative to %s", nextNodeName, classifyTable.getClassifierNode()), e); } return reply.nextIndex; } }
getFutureJVpp().swInterfaceDump(request).toCompletableFuture(); final SwInterfaceDetailsReplyDump ifaces = TranslateUtils.getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id);
getFutureJVpp().swInterfaceDump(request).toCompletableFuture(); final SwInterfaceDetailsReplyDump ifaces = TranslateUtils.getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id);
@Override public void readCurrentAttributes(@Nonnull InstanceIdentifier<Version> id, @Nonnull final VersionBuilder builder, @Nonnull final ReadContext context) throws ReadFailedException { try { // Execute with timeout final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion()); final ShowVersionReply reply = TranslateUtils.getReplyForRead(showVersionFuture.toCompletableFuture(), id); builder.setBranch(TranslateUtils.toString(reply.version)); builder.setName(TranslateUtils.toString(reply.program)); builder.setBuildDate(TranslateUtils.toString(reply.buildDate)); builder.setBuildDirectory(TranslateUtils.toString(reply.buildDirectory)); } catch (VppBaseCallException e) { throw new ReadFailedException(id, e); } }
@Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Acl> id, @Nonnull final AclBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.debug("Reading attributes for interface ACL: {}", id); final InterfaceKey interfaceKey = id.firstKeyOf(Interface.class); checkArgument(interfaceKey != null, "No parent interface key found"); final ClassifyTableByInterface request = new ClassifyTableByInterface(); request.swIfIndex = interfaceContext.getIndex(interfaceKey.getName(), ctx.getMappingContext()); try { final ClassifyTableByInterfaceReply reply = TranslateUtils .getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id); builder.setL2Acl(readL2Acl(reply.l2TableId, classifyTableContext, ctx.getMappingContext())); builder.setIp4Acl(readIp4Acl(reply.ip4TableId, classifyTableContext, ctx.getMappingContext())); builder.setIp6Acl(readIp6Acl(reply.ip6TableId, classifyTableContext, ctx.getMappingContext())); if (LOG.isTraceEnabled()) { LOG.trace("Attributes for ACL {} successfully read: {}", id, builder.build()); } } catch (VppBaseCallException e) { throw new ReadFailedException(id, e); } } }
dumpRequest.tableId = tableId; classifySessionDump = TranslateUtils .getReplyForRead(getFutureJVpp().classifySessionDump(dumpRequest).toCompletableFuture(), id);
getFutureJVpp().swInterfaceTapDump(request); final SwInterfaceTapDetailsReplyDump reply = TranslateUtils.getReplyForRead(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
@Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Acl> id, @Nonnull final AclBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.debug("Reading attributes for sub-interface ACL: {}", id); final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); checkArgument(parentInterfacekey != null, "No parent interface key found"); final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class); checkArgument(subInterfacekey != null, "No sub-interface key found"); final String subInterfaceName = getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); final ClassifyTableByInterface request = new ClassifyTableByInterface(); request.swIfIndex = interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()); try { final ClassifyTableByInterfaceReply reply = TranslateUtils .getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id); builder.setL2Acl(readL2Acl(reply.l2TableId, classifyTableContext, ctx.getMappingContext())); builder.setIp4Acl(readIp4Acl(reply.ip4TableId, classifyTableContext, ctx.getMappingContext())); builder.setIp6Acl(readIp6Acl(reply.ip6TableId, classifyTableContext, ctx.getMappingContext())); if (LOG.isTraceEnabled()) { LOG.trace("Attributes for ACL {} successfully read: {}", id, builder.build()); } } catch (VppBaseCallException e) { throw new ReadFailedException(id, e); } } }
getFutureJVppNsh().nshMapDump(request); final NshMapDetailsReplyDump reply = TranslateUtils.getReplyForRead(nshMapDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
getFutureJVpp().swInterfaceVhostUserDump(request); final SwInterfaceVhostUserDetailsReplyDump reply = TranslateUtils.getReplyForRead(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
getFutureJVpp().greTunnelDump(request); final GreTunnelDetailsReplyDump reply = TranslateUtils.getReplyForRead(swInterfaceGreDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
getFutureJVpp().vxlanGpeTunnelDump(request); final VxlanGpeTunnelDetailsReplyDump reply = TranslateUtils.getReplyForRead(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
getFutureJVpp().vxlanTunnelDump(request); final VxlanTunnelDetailsReplyDump reply = TranslateUtils.getReplyForRead(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
TranslateUtils.getReplyForRead(getFutureJVpp().classifyTableInfo(request).toCompletableFuture(), id);