use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testTrafficActionParser.
@Test
public void testTrafficActionParser() throws BGPDocumentedException, BGPParsingException {
final TrafficActionExtendedCommunityCase trafficAction = new TrafficActionExtendedCommunityCaseBuilder().setTrafficActionExtendedCommunity(new TrafficActionExtendedCommunityBuilder().setSample(true).setTerminalAction(true).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficAction).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(TRAFFIC_ACTION));
Assert.assertEquals(expected, parsed);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder in project bgpcep by opendaylight.
the class SimpleExtendedCommunityRegistryTest method testExtendedCommunityRegistryUnknown.
@Test
public void testExtendedCommunityRegistryUnknown() throws BGPDocumentedException, BGPParsingException {
final ByteBuf output = Unpooled.buffer();
this.register.serializeExtendedCommunity(new ExtendedCommunitiesBuilder().setTransitive(false).setExtendedCommunity(new RouteOriginIpv4CaseBuilder().build()).build(), output);
// no ex. community was serialized
Assert.assertEquals(0, output.readableBytes());
Mockito.verify(this.serializer, Mockito.never()).serializeExtendedCommunity(Mockito.any(ExtendedCommunity.class), Mockito.any(ByteBuf.class));
final ExtendedCommunities noExtCommunity = this.register.parseExtendedCommunity(Unpooled.copiedBuffer(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }));
// no ext. community was parsed
Assert.assertNull(noExtCommunity);
Mockito.verify(this.parser, Mockito.never()).parseExtendedCommunity(Mockito.any(ByteBuf.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder in project bgpcep by opendaylight.
the class SimpleExtendedCommunityRegistry method parseExtendedCommunity.
@Override
public ExtendedCommunities parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final short type = buffer.readUnsignedByte();
final short subtype = buffer.readUnsignedByte();
final ExtendedCommunityParser parser = this.handlers.getParser(createKey(type, subtype));
if (parser == null) {
buffer.skipBytes(EXTENDED_COMMUNITY_LENGTH);
LOG.info("Skipping unknown extended-community type/sub-type {}/{}.", type, subtype);
return null;
}
return new ExtendedCommunitiesBuilder().setTransitive(isTransitive(type)).setExtendedCommunity(parser.parseExtendedCommunity(buffer)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder in project bgpcep by opendaylight.
the class AbstractExtCommunityHandler method loadCommunitySet.
private List<ExtendedCommunities> loadCommunitySet(final String key) throws ExecutionException, InterruptedException {
final ReadOnlyTransaction tr = this.databroker.newReadOnlyTransaction();
final Optional<ExtCommunitySet> result = tr.read(LogicalDatastoreType.CONFIGURATION, EXT_COMMUNITY_SETS_IID.child(ExtCommunitySet.class, new ExtCommunitySetKey(key))).get();
if (!result.isPresent()) {
return Collections.emptyList();
}
return result.get().getExtCommunityMember().stream().map(ge -> new ExtendedCommunitiesBuilder().setExtendedCommunity(ge.getExtendedCommunity()).setTransitive(ge.isTransitive()).build()).collect(Collectors.toList());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder in project bgpcep by opendaylight.
the class SetExtCommunityHandler method setExtComm.
private Attributes setExtComm(final Attributes attributes, final SetExtCommunityMethod setExtCommunityMethod, final BgpSetCommunityOptionType options) {
if (setExtCommunityMethod instanceof Inline) {
final Inline inline = (Inline) setExtCommunityMethod;
final List<ExtendedCommunities> list = inline.getExtCommunityMember().stream().map(ge -> new ExtendedCommunitiesBuilder().setExtendedCommunity(ge.getExtendedCommunity()).setTransitive(ge.isTransitive()).build()).collect(Collectors.toList());
return inlineSetExtComm(attributes, list, options);
}
return referenceSetExtComm(attributes, ((Reference) setExtCommunityMethod).getExtCommunitySetRef(), options);
}
Aggregations