use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder in project bgpcep by opendaylight.
the class ClusterIdAttributeParserTest method testParserAttribute.
@Test
public void testParserAttribute() throws Exception {
final List<ClusterIdentifier> list = new ArrayList<>();
final Ipv4AddressNoZone ip1 = new Ipv4AddressNoZone("192.168.1.1");
final Ipv4AddressNoZone ip2 = new Ipv4AddressNoZone("192.168.1.2");
list.add(new ClusterIdentifier(ip1));
list.add(new ClusterIdentifier(ip2));
final Attributes clusterId = new AttributesBuilder().setClusterId(new ClusterIdBuilder().setCluster(list).build()).build();
final ByteBuf output = Unpooled.buffer();
this.parser.serializeAttribute(clusterId, output);
assertArrayEquals(CLUSTER_ID_BYTES, ByteArray.getAllBytes(output));
AttributesBuilder clusterIdOutput = new AttributesBuilder();
this.parser.parseAttribute(Unpooled.wrappedBuffer(ByteArray.cutBytes(CLUSTER_ID_BYTES, 3)), clusterIdOutput, null);
assertEquals(clusterId, clusterIdOutput.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder in project bgpcep by opendaylight.
the class AbstractAddPathTest method createSimpleUpdate.
private static Update createSimpleUpdate(final Ipv4Prefix prefix, final PathId pathId, final ClusterIdentifier clusterId, final long localPreference) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(localPreference)).build());
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.ZERO).build());
if (clusterId != null) {
attBuilder.setClusterId(new ClusterIdBuilder().setCluster(Collections.singletonList(clusterId)).build());
attBuilder.setOriginatorId(new OriginatorIdBuilder().setOriginator(new Ipv4AddressNoZone(clusterId)).build());
}
addAttributeAugmentation(attBuilder, prefix, pathId);
return new UpdateBuilder().setAttributes(attBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder in project bgpcep by opendaylight.
the class TestUtil method createAttributes.
private static Attributes createAttributes() {
final List<AsNumber> asSequences = Lists.newArrayList(new AsNumber(Uint32.valueOf(72)), new AsNumber(Uint32.valueOf(82)), new AsNumber(Uint32.valueOf(92)));
final List<Segments> segments = new ArrayList<>();
final SegmentsBuilder segmentsBuild = new SegmentsBuilder();
segmentsBuild.setAsSequence(asSequences).build();
return new AttributesBuilder().setAggregator(new AggregatorBuilder().setAsNumber(new AsNumber(Uint32.valueOf(72))).setNetworkAddress(IPV4_ADDRESS_20).build()).setAigp(new AigpBuilder().setAigpTlv(new AigpTlvBuilder().setMetric(new AccumulatedIgpMetric(Uint64.ONE)).build()).build()).setAsPath(new AsPathBuilder().setSegments(segments).build()).setAtomicAggregate(new AtomicAggregateBuilder().build()).setClusterId(new ClusterIdBuilder().setCluster(Lists.newArrayList(new ClusterIdentifier(IPV4_ADDRESS_30), new ClusterIdentifier(IPV4_ADDRESS_40))).build()).setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(IPV4_ADDRESS_100).build()).build()).setCommunities(createCommunities()).setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(2)).build()).setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.valueOf(123)).build()).setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build()).setOriginatorId(new OriginatorIdBuilder().setOriginator(IPV4_ADDRESS_12).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder in project bgpcep by opendaylight.
the class ExportAttributeTestUtil method createClusterIdInput.
private static ClusterId createClusterIdInput() {
final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.1"));
final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.2"));
return new ClusterIdBuilder().setCluster(Arrays.asList(cluster1, cluster2)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder in project bgpcep by opendaylight.
the class SetClusterIdPrependHandler method prependClusterId.
private static Attributes prependClusterId(final Attributes attributes, final ClusterIdentifier clusterId) {
final AttributesBuilder newAtt = new AttributesBuilder(attributes);
final List<ClusterIdentifier> newClusterList = new ArrayList<>();
newClusterList.add(clusterId);
if (attributes.getClusterId() != null && !attributes.getClusterId().getCluster().isEmpty()) {
final List<ClusterIdentifier> oldList = attributes.getClusterId().getCluster();
newClusterList.addAll(oldList);
}
return newAtt.setClusterId(new ClusterIdBuilder().setCluster(newClusterList).build()).build();
}
Aggregations