@Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id, @Nonnull final BridgeDomainBuilder builder, @Nonnull final ReadContext context) throws ReadFailedException { LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: id={}, builderbuilder={}, context={}", id, builder, context); final BridgeDomainKey key = id.firstKeyOf(id.getTargetType()); LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: key={}", key); final int bdId = bdContext.getIndex(key.getName(), context.getMappingContext()); LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: bdId={}", bdId); BridgeDomainDetailsReplyDump reply; BridgeDomainDetails bridgeDomainDetails; final BridgeDomainDump request = new BridgeDomainDump(); request.bdId = bdContext.getIndex(key.getName(), context.getMappingContext()); try { reply = getFutureJVpp().bridgeDomainDump(request).toCompletableFuture().get(); bridgeDomainDetails = Iterables.getOnlyElement(reply.bridgeDomainDetails); } catch (Exception e) { LOG.debug("Unable to read bridge domain: {}", key.getName(), e); return; } logBridgeDomainDetails(bridgeDomainDetails); builder.setName(key.getName()); builder.setArpTermination(byteToBoolean(bridgeDomainDetails.arpTerm)); builder.setFlood(byteToBoolean(bridgeDomainDetails.flood)); builder.setForward(byteToBoolean(bridgeDomainDetails.forward)); builder.setLearn(byteToBoolean(bridgeDomainDetails.learn)); builder.setUnknownUnicastFlood(byteToBoolean(bridgeDomainDetails.uuFlood)); }
@Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntryBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { final L2FibEntryKey key = id.firstKeyOf(id.getTargetType()); final BridgeDomainKey bridgeDomainKey = id.firstKeyOf(BridgeDomain.class); final int bdId = bdContext.getIndex(bridgeDomainKey.getName(), ctx.getMappingContext()); LOG.debug("Reading L2 FIB entry: key={}. bridgeDomainKey={}, bdId={}", key, bridgeDomainKey, bdId); try { // TODO use cached l2FibTable final L2FibTableEntry entry = dumpL2Fibs(id, bdId).stream().filter(e -> key.getPhysAddress() .equals(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(e.mac), 2)))) .collect(SINGLE_ITEM_COLLECTOR); builder.setAction(byteToBoolean(entry.filterMac) ? L2FibFilter.class : L2FibForward.class); builder.setBridgedVirtualInterface(byteToBoolean(entry.bviMac)); if (entry.swIfIndex != -1) { builder.setOutgoingInterface(interfaceContext.getName(entry.swIfIndex, ctx.getMappingContext())); } builder.setStaticConfig(byteToBoolean(entry.staticMac)); builder.setPhysAddress(key.getPhysAddress()); builder.setKey(key); } catch (Exception e) { throw new ReadFailedException(id, e); } }
private Match readMatch(final SwInterfaceDetails iface) { final MatchBuilder match = new MatchBuilder(); if (iface.subDefault == 1) { match.setMatchType(new DefaultBuilder().build()); } else if (iface.subNumberOfTags == 0) { match.setMatchType(new UntaggedBuilder().build()); } else { final VlanTaggedBuilder tagged = new VlanTaggedBuilder(); tagged.setMatchExactTags(byteToBoolean(iface.subExactMatch)); match.setMatchType( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.match.attributes.match.type.VlanTaggedBuilder() .setVlanTagged(tagged.build()).build()); } return match.build(); } }