private void createClassifySession(@Nonnull final InstanceIdentifier<?> id, @Nonnull final ClassifyAddDelSession request) throws VppBaseCallException, WriteTimeoutException { final CompletionStage<ClassifyAddDelSessionReply> cs = futureJVppCore.classifyAddDelSession(request); TranslateUtils.getReplyForWrite(cs.toCompletableFuture(), id); }
private int createClassifyTable(@Nonnull final InstanceIdentifier<?> id, @Nonnull final ClassifyAddDelTable request) throws VppBaseCallException, WriteTimeoutException { final CompletionStage<ClassifyAddDelTableReply> cs = futureJVppCore.classifyAddDelTable(request); final ClassifyAddDelTableReply reply = TranslateUtils.getReplyForWrite(cs.toCompletableFuture(), id); return reply.newTableIndex; }
public static <REP extends JVppReply<?>> REP getReplyForWrite(@Nonnull Future<REP> future, @Nonnull final InstanceIdentifier<?> replyType, @Nonnegative final int timeoutInSeconds) throws VppBaseCallException, WriteTimeoutException { try { return getReply(future, timeoutInSeconds); } catch (TimeoutException e) { throw new WriteTimeoutException(replyType, e); } }
private void removeClassifyTable(@Nonnull final InstanceIdentifier<?> id, final int tableIndex) throws VppBaseCallException, WriteTimeoutException { if (tableIndex == -1) { return; // classify table id is absent } final ClassifyAddDelTable request = new ClassifyAddDelTable(); request.tableIndex = tableIndex; final CompletionStage<ClassifyAddDelTableReply> cs = jvpp.classifyAddDelTable(request); TranslateUtils.getReplyForWrite(cs.toCompletableFuture(), id); }
private void setInterfaceState(final InstanceIdentifier<SubInterface> id, final int swIfIndex, final byte enabled) throws VppBaseCallException, WriteTimeoutException { final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags(); swInterfaceSetFlags.swIfIndex = swIfIndex; swInterfaceSetFlags.adminUpDown = enabled; final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture = getFutureJVpp().swInterfaceSetFlags(swInterfaceSetFlags); LOG.debug("Updating interface state for interface if={}, enabled: {}", swIfIndex, enabled); SwInterfaceSetFlagsReply reply = TranslateUtils.getReplyForWrite(swInterfaceSetFlagsReplyFuture.toCompletableFuture(), id); LOG.debug("Interface state updated successfully for interface index: {}, enabled: {}, ctxId: {}", swIfIndex, enabled, reply.context); }
static void addDelAddress(@Nonnull final FutureJVppCore futureJVppCore, final boolean add, final InstanceIdentifier<?> id, @Nonnegative final int ifaceId, @Nonnull final Ipv4AddressNoZone address, @Nonnegative final byte prefixLength) throws VppBaseCallException, WriteTimeoutException { checkArgument(prefixLength > 0, "Invalid prefix length"); checkNotNull(address, "address should not be null"); final byte[] addressBytes = TranslateUtils.ipv4AddressNoZoneToArray(address); final CompletionStage<SwInterfaceAddDelAddressReply> swInterfaceAddDelAddressReplyCompletionStage = futureJVppCore.swInterfaceAddDelAddress( getSwInterfaceAddDelAddressRequest(ifaceId, TranslateUtils.booleanToByte(add) /* isAdd */, (byte) 0 /* isIpv6 */, (byte) 0 /* delAll */, prefixLength, addressBytes)); TranslateUtils.getReplyForWrite(swInterfaceAddDelAddressReplyCompletionStage.toCompletableFuture(), id); }
private void setInterfaceFlags(final InstanceIdentifier<Interface> id, final String swIfName, final int swIfIndex, final byte enabled) throws VppBaseCallException, WriteTimeoutException { final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture = getFutureJVpp().swInterfaceSetFlags( getSwInterfaceSetFlagsInput(swIfIndex, enabled, (byte) 0 /* deleted */)); LOG.debug("Updating interface flags for: {}, index: {}, enabled: {}", swIfName, swIfIndex, enabled); TranslateUtils.getReplyForWrite(swInterfaceSetFlagsReplyFuture.toCompletableFuture(), id); LOG.debug("Interface flags updated successfully for: {}, index: {}, enabled: {}", swIfName, swIfIndex, enabled); }
private int nshAddDelMap(final boolean isAdd, @Nonnull final InstanceIdentifier<NshMap> id, @Nonnull final NshMap map, final int mapId, final MappingContext ctx) throws VppBaseCallException, WriteTimeoutException { final CompletionStage<NshAddDelMapReply> createNshMapReplyCompletionStage = getFutureJVppNsh().nshAddDelMap(getNshAddDelMapRequest(isAdd, mapId, map, ctx)); final NshAddDelMapReply reply = TranslateUtils.getReplyForWrite(createNshMapReplyCompletionStage.toCompletableFuture(), id); return reply.mapIndex; }
private int nshAddDelEntry(final boolean isAdd, @Nonnull final InstanceIdentifier<NshEntry> id, @Nonnull final NshEntry entry, final int entryId, final MappingContext ctx) throws VppBaseCallException, WriteTimeoutException { final CompletionStage<NshAddDelEntryReply> createNshEntryReplyCompletionStage = getFutureJVppNsh().nshAddDelEntry(getNshAddDelEntryRequest(isAdd, entryId, entry, ctx)); final NshAddDelEntryReply reply = TranslateUtils.getReplyForWrite(createNshEntryReplyCompletionStage.toCompletableFuture(), id); return reply.entryIndex; }
private void deleteTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index, final Tap dataBefore, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { LOG.debug("Deleting tap interface: {}. Tap: {}", swIfName, dataBefore); final CompletionStage<TapDeleteReply> vxlanAddDelTunnelReplyCompletionStage = getFutureJVpp().tapDelete(getTapDeleteRequest(index)); TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Tap deleted successfully for: {}, tap: {}", swIfName, dataBefore); // Remove deleted interface from interface context interfaceContext.removeName(swIfName, writeContext.getMappingContext()); }
private void setTagRewrite(final InstanceIdentifier<Rewrite> id, final String ifname, final Rewrite rewrite, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { final int swIfIndex = interfaceContext.getIndex(ifname, writeContext.getMappingContext()); LOG.debug("Setting tag rewrite for interface {}(id=): {}", ifname, swIfIndex, rewrite); final CompletionStage<L2InterfaceVlanTagRewriteReply> replyCompletionStage = getFutureJVpp().l2InterfaceVlanTagRewrite(getTagRewriteRequest(swIfIndex, rewrite)); TranslateUtils.getReplyForWrite(replyCompletionStage.toCompletableFuture(), id); LOG.debug("Tag rewrite for interface {}(id=) set successfully: {}", ifname, swIfIndex, rewrite); }
private int classifyAddDelTable(final boolean isAdd, @Nonnull final InstanceIdentifier<ClassifyTable> id, @Nonnull final ClassifyTable table, final int tableId, final MappingContext ctx) throws VppBaseCallException, WriteFailedException { final int missNextIndex = getNodeIndex(table.getMissNext(), table, classifyTableContext, ctx, id); final CompletionStage<ClassifyAddDelTableReply> createClassifyTableReplyCompletionStage = getFutureJVpp() .classifyAddDelTable(getClassifyAddDelTableRequest(isAdd, tableId, table, missNextIndex, ctx)); final ClassifyAddDelTableReply reply = TranslateUtils.getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id); return reply.newTableIndex; }
private void createVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { LOG.debug("Creating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser); final CompletionStage<CreateVhostUserIfReply> createVhostUserIfReplyCompletionStage = getFutureJVpp().createVhostUserIf(getCreateVhostUserIfRequest(vhostUser)); final CreateVhostUserIfReply reply = TranslateUtils.getReplyForWrite(createVhostUserIfReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Vhost user interface created successfully for: {}, vhostUser: {}", swIfName, vhostUser); // Add new interface to our interface context interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext()); }
private void modifyVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { LOG.debug("Updating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser); final CompletionStage<ModifyVhostUserIfReply> modifyVhostUserIfReplyCompletionStage = getFutureJVpp() .modifyVhostUserIf(getModifyVhostUserIfRequest(vhostUser, interfaceContext.getIndex(swIfName, writeContext.getMappingContext()))); TranslateUtils.getReplyForWrite(modifyVhostUserIfReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Vhost user interface updated successfully for: {}, vhostUser: {}", swIfName, vhostUser); }
private void modifyTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index, final Tap tap) throws VppBaseCallException, WriteTimeoutException { LOG.debug("Modifying tap interface: {}. Tap: {}", swIfName, tap); final CompletionStage<TapModifyReply> vxlanAddDelTunnelReplyCompletionStage = getFutureJVpp().tapModify(getTapModifyRequest(tap.getTapName(), index, tap.getMac(), tap.getDeviceInstance())); TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Tap modified successfully for: {}, tap: {}", swIfName, tap); }
private void bdIpMacAddDel(@Nonnull final InstanceIdentifier<ArpTerminationTableEntry> id, @Nonnull final ArpTerminationTableEntry entry, final WriteContext writeContext, boolean isAdd) throws VppBaseCallException, WriteTimeoutException { final String bdName = id.firstKeyOf(BridgeDomain.class).getName(); final int bdId = bdContext.getIndex(bdName, writeContext.getMappingContext()); final BdIpMacAddDel request = createRequest(entry, bdId, isAdd); LOG.debug("Sending l2FibAddDel request: {}", ReflectionToStringBuilder.toString(request)); final CompletionStage<BdIpMacAddDelReply> replyCompletionStage = getFutureJVpp().bdIpMacAddDel(request); TranslateUtils.getReplyForWrite(replyCompletionStage.toCompletableFuture(), id); }
private void deleteVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { LOG.debug("Deleting vhost user interface: name={}, vhostUser={}", swIfName, vhostUser); final CompletionStage<DeleteVhostUserIfReply> deleteVhostUserIfReplyCompletionStage = getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest(interfaceContext.getIndex(swIfName, writeContext.getMappingContext()))); TranslateUtils.getReplyForWrite(deleteVhostUserIfReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Vhost user interface deleted successfully for: {}, vhostUser: {}", swIfName, vhostUser); // Remove interface from our interface context interfaceContext.removeName(swIfName, writeContext.getMappingContext()); }
private void setProxyArp(InstanceIdentifier<ProxyArp> id, String swIfName, ProxyArp proxyArp, WriteContext writeContext, byte operation) throws VppBaseCallException, WriteFailedException { LOG.debug("Setting Proxy ARP settings for interface: {}", swIfName); final InetAddress srcAddress = InetAddresses.forString(getv4AddressString(proxyArp.getLowAddr())); final InetAddress dstAddress = InetAddresses.forString(getv4AddressString(proxyArp.getHighAddr())); final int vrfId = proxyArp.getVrfId().intValue(); final CompletionStage<ProxyArpAddDelReply> proxyArpAddDelReplyCompletionStage = getFutureJVpp().proxyArpAddDel(getProxyArpConfRequest(operation, srcAddress.getAddress(), dstAddress.getAddress(), vrfId)); final ProxyArpAddDelReply reply = TranslateUtils.getReplyForWrite(proxyArpAddDelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Proxy ARP setting applied, with reply context:", reply.context); }
private void createTap(final InstanceIdentifier<Tap> id, final String swIfName, final Tap tap, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { LOG.debug("Setting tap interface: {}. Tap: {}", swIfName, tap); final CompletionStage<TapConnectReply> tapConnectFuture = getFutureJVpp().tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance())); final TapConnectReply reply = TranslateUtils.getReplyForWrite(tapConnectFuture.toCompletableFuture(), id); LOG.debug("Tap set successfully for: {}, tap: {}", swIfName, tap); // Add new interface to our interface context interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext()); }
private void createSubInterface(final InstanceIdentifier<SubInterface> id, @Nonnull final String superIfName, @Nonnull final SubInterface subInterface, final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { final int superIfIndex = interfaceContext.getIndex(superIfName, writeContext.getMappingContext()); final CompletionStage<CreateSubifReply> createSubifReplyCompletionStage = getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, superIfIndex)); final CreateSubifReply reply = TranslateUtils.getReplyForWrite(createSubifReplyCompletionStage.toCompletableFuture(), id); setInterfaceState(id, reply.swIfIndex, booleanToByte(subInterface.isEnabled())); interfaceContext.addName(reply.swIfIndex, getSubInterfaceName(superIfName, Math.toIntExact(subInterface.getIdentifier())), writeContext.getMappingContext()); LOG.debug("Sub interface created successfully for: {}, subInterface: {}", superIfName, subInterface); }