use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testredirect4bSerializer.
@Test
public void testredirect4bSerializer() throws BGPDocumentedException, BGPParsingException {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCaseBuilder().setRedirectAs4(new RedirectAs4Builder().setGlobalAdministrator(new AsNumber(Uint32.valueOf(6548))).setLocalAdministrator(Uint16.valueOf(126)).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
final ByteBuf output = Unpooled.buffer(REDIRECT_AS_4BYTES.length);
this.registry.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(REDIRECT_AS_4BYTES, output.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testRedirectIpv6NhParser.
@Test
public void testRedirectIpv6NhParser() throws BGPDocumentedException, BGPParsingException {
final RedirectIpNhExtendedCommunityCase redirect = new RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddressNoZone(new Ipv6AddressNoZone("2001::1"))).setCopy(false).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_NH_IPV6));
Assert.assertEquals(expected, parsed);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class AbstractExtCommunityHandler method loadCommunitySet.
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private List<ExtendedCommunities> loadCommunitySet(final String key) throws ExecutionException, InterruptedException {
final FluentFuture<Optional<ExtCommunitySet>> future;
try (ReadTransaction tr = this.databroker.newReadOnlyTransaction()) {
future = tr.read(LogicalDatastoreType.CONFIGURATION, EXT_COMMUNITY_SETS_IID.child(ExtCommunitySet.class, new ExtCommunitySetKey(key)));
}
final Optional<ExtCommunitySet> result = future.get();
return result.map(AbstractExtCommunityHandler::toExtendedCommunitiesList).orElse(Collections.emptyList());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities 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.getTransitive()).build()).collect(Collectors.toList());
return inlineSetExtComm(attributes, list, options);
}
return referenceSetExtComm(attributes, ((Reference) setExtCommunityMethod).getExtCommunitySetRef(), options);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class SetExtCommunityHandler method inlineSetExtComm.
private static Attributes inlineSetExtComm(final Attributes attributes, final List<ExtendedCommunities> actionExtCommunities, final BgpSetCommunityOptionType options) {
final AttributesBuilder newAtt = new AttributesBuilder(attributes);
if (options.equals(BgpSetCommunityOptionType.REPLACE)) {
return newAtt.setExtendedCommunities(actionExtCommunities).build();
}
final List<ExtendedCommunities> actualComm;
if (attributes.getCommunities() != null) {
actualComm = new ArrayList<>(attributes.getExtendedCommunities());
} else {
actualComm = new ArrayList<>();
}
switch(options) {
case ADD:
actualComm.addAll(actionExtCommunities);
break;
case REMOVE:
actualComm.removeAll(actionExtCommunities);
break;
default:
throw new IllegalArgumentException("Option Type not Recognized!");
}
return newAtt.setExtendedCommunities(actualComm).build();
}
Aggregations