use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class ImportAttributeTestUtil method createInput.
public static Attributes createInput() {
final AttributesBuilder attBuilder = new AttributesBuilder();
// local pref
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build());
// cluster pref
attBuilder.setClusterId(new ClusterIdBuilder().setCluster(Collections.singletonList(new ClusterIdentifier("40.40.40.40"))).build());
// c-next-hop pref
attBuilder.setCNextHop(createNexHop());
// originator pref
attBuilder.setOriginatorId(new OriginatorIdBuilder().setOriginator(new Ipv4AddressNoZone("41.41.41.41")).build());
// origin pref
attBuilder.setOrigin(createOrigin());
// as path
attBuilder.setAsPath(new AsPathBuilder().build());
// multi-exit-disc pref
attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.ZERO).build());
return attBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes 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 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class ExportDefaultStatementTest method testToEbgp.
@Test
public void testToEbgp() {
final Statement statement = getStatementAndSetToRole("to-external", PeerRole.Ebgp);
final Attributes expectedOutput = createPathInputWithAs();
final RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(createPathInput(Collections.emptyList()));
assertApplyExportStatement(statement, PeerRole.Ebgp, attributeContainer, expectedOutput);
assertApplyExportStatement(statement, PeerRole.Ibgp, attributeContainer, expectedOutput);
assertApplyExportStatement(statement, PeerRole.Internal, attributeContainer, expectedOutput);
assertApplyExportStatement(statement, PeerRole.RrClient, attributeContainer, expectedOutput);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class MPReachAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
if (pathAttributes1 != null) {
final ByteBuf reachBuffer = Unpooled.buffer();
reg.serializeMpReach(pathAttributes1.getMpReachNlri(), reachBuffer);
for (final NlriSerializer nlriSerializer : reg.getSerializers()) {
nlriSerializer.serializeAttribute(pathAttributes, reachBuffer);
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, reachBuffer, byteAggregator);
}
}
Aggregations