use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder in project bgpcep by opendaylight.
the class SetCommunityHandler method setComm.
private Attributes setComm(final Attributes attributes, final SetCommunityMethod setCommunityMethod, final BgpSetCommunityOptionType options) {
if (setCommunityMethod instanceof Inline) {
final Inline inline = (Inline) setCommunityMethod;
final List<Communities> list = inline.getCommunities().stream().map(ge -> new CommunitiesBuilder().setAsNumber(ge.getAsNumber()).setSemantics(ge.getSemantics()).build()).collect(Collectors.toList());
return inlineSetComm(attributes, list, options);
}
return referenceSetComm(attributes, ((Reference) setCommunityMethod).getCommunitySetRef(), options);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder in project bgpcep by opendaylight.
the class MatchCommunityTest method testComAll.
@Test
public void testComAll() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("community-all-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setCommunities(Arrays.asList(new CommunitiesBuilder().setAsNumber(AsNumber.getDefaultInstance("65")).setSemantics(Uint16.TEN).build(), new CommunitiesBuilder().setAsNumber(AsNumber.getDefaultInstance("66")).setSemantics(Uint16.valueOf(11)).build())).build());
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder in project bgpcep by opendaylight.
the class CommunityUtil method valueOf.
/**
* Creates a Community from its String representation.
*
* @param refCache reference cache to use
* @param string String representation of a community
* @return new Community
*/
public static Community valueOf(final ReferenceCache refCache, final String string) {
final String[] parts = string.split(":", 2);
final CommunitiesBuilder builder = new CommunitiesBuilder();
builder.setAsNumber(refCache.getSharedReference(new AsNumber(Uint32.valueOf(parts[0]))));
builder.setSemantics(refCache.getSharedReference(Uint16.valueOf(parts[1])));
return refCache.getSharedReference(builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder in project bgpcep by opendaylight.
the class TestUtil method createCommunities.
private static List<Communities> createCommunities() {
final List<Communities> communities = new ArrayList<>();
final CommunitiesBuilder commBuilder = new CommunitiesBuilder().setAsNumber(new AsNumber(Uint32.valueOf(65535))).setSemantics(Uint16.valueOf(65381));
final CommunitiesBuilder commBuilder2 = new CommunitiesBuilder().setAsNumber(new AsNumber(Uint32.valueOf(65535))).setSemantics(Uint16.valueOf(65382));
communities.add(commBuilder.build());
communities.add(commBuilder2.build());
return communities;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder in project bgpcep by opendaylight.
the class AbstractCommunityHandler method loadCommunitySet.
private List<Communities> loadCommunitySet(final String key) throws ExecutionException, InterruptedException {
final ReadOnlyTransaction tr = this.databroker.newReadOnlyTransaction();
final Optional<CommunitySet> result = tr.read(LogicalDatastoreType.CONFIGURATION, COMMUNITY_SETS_IID.child(CommunitySet.class, new CommunitySetKey(key))).get();
if (!result.isPresent()) {
return Collections.emptyList();
}
return result.get().getCommunities().stream().map(ge -> new CommunitiesBuilder().setAsNumber(ge.getAsNumber()).setSemantics(ge.getSemantics()).build()).collect(Collectors.toList());
}
Aggregations