private static String getSubInterfaceName(@Nonnull final InstanceIdentifier<Address> id) { return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(), Math.toIntExact(id.firstKeyOf(SubInterface.class).getIdentifier())); } }
@Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<IetfAcl> id, @Nonnull final IetfAcl dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { final String subInterfaceName = getSubInterfaceName(id); final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, writeContext.getMappingContext()); LOG.debug("Adding IETF-ACL for sub-interface: {}(id={}): {}", subInterfaceName, subInterfaceIndex, dataAfter); final AccessLists accessLists = dataAfter.getAccessLists(); checkArgument(accessLists != null && accessLists.getAcl() != null, "ietf-acl container does not define acl list"); final Optional<SubInterface> subInterfaceOptional = writeContext.readAfter(id.firstIdentifierOf(SubInterface.class)); checkState(subInterfaceOptional.isPresent(), "Could not read SubInterface data object for %s", id); final SubInterface subInterface = subInterfaceOptional.get(); try { aclWriter.write(id, subInterfaceIndex, accessLists.getAcl(), writeContext, getNumberOfTags(subInterface.getTags())); } catch (VppBaseCallException e) { throw new WriteFailedException.CreateFailedException(id, dataAfter, e); } }
request.swIfIndex = swIfIndex; final int numberOfTags = getNumberOfTags(subInterface.getTags()); switch (numberOfTags) { case 0:
private String getSubInterfaceName(@Nonnull final InstanceIdentifier<IetfAcl> id) { final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class); return SubInterfaceUtils .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); }
@Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<L2> id, @Nonnull final L2Builder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.debug("Reading attributes for sub-interface L2: {}", id); final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class); final String subInterfaceName = getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); builder.setInterconnection(icReadUtils.readInterconnection(id, subInterfaceName, ctx)); } }
private String getSubInterfaceName(@Nonnull final InstanceIdentifier<Address> id) { final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class); return SubInterfaceUtils .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); }
private String getSubInterfaceName(@Nonnull final InstanceIdentifier<L2> id) { final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class); return SubInterfaceUtils .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); }
private static String getSubInterfaceName(final InstanceIdentifier<Rewrite> id) { return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(), Math.toIntExact(id.firstKeyOf(SubInterface.class).getIdentifier())); }
private static String getSubInterfaceName(final InstanceIdentifier<Rewrite> id) { return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(), Math.toIntExact(id.firstKeyOf(SubInterface.class).getIdentifier())); }
private static String getSubInterfaceName(final InstanceIdentifier<SubInterface> id) { return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(), Math.toIntExact(id.firstKeyOf(id.getTargetType()).getIdentifier())); }
private void setAcl(final boolean isAdd, @Nonnull final InstanceIdentifier<Acl> id, @Nonnull final Acl acl, @Nonnull final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class); final String subInterfaceName = SubInterfaceUtils .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, writeContext.getMappingContext()); LOG.debug("Setting ACL(isAdd={}) on sub-interface={}(id={}): {}", isAdd, subInterfaceName, subInterfaceIndex, acl); inputAclSetInterface(getFutureJVpp(), isAdd, id, acl, subInterfaceIndex, classifyTableContext, writeContext.getMappingContext()); LOG.debug("Successfully set ACL(isAdd={}) on sub-interface={}(id={}): {}", isAdd, subInterfaceName, subInterfaceIndex, acl); } }
@Override public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<SubInterface> id, @Nonnull final SubInterface dataBefore, @Nonnull final SubInterface dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { if (Objects.equals(dataBefore.isEnabled(), dataAfter.isEnabled())) { LOG.debug("No state update will be performed. Ignoring config"); return; // TODO shouldn't we throw exception here (if there will be dedicated L2 customizer)? } final String subIfaceName = getSubInterfaceName(id.firstKeyOf(Interface.class).getName(), Math.toIntExact(dataAfter.getIdentifier())); try { setInterfaceState(id, interfaceContext.getIndex(subIfaceName, writeContext.getMappingContext()), booleanToByte(dataAfter.isEnabled())); } catch (VppBaseCallException e) { LOG.warn("Failed to update interface state for: interface if={}, enabled: {}", subIfaceName, booleanToByte(dataAfter.isEnabled())); throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e); } }
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); }
@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); } } }