use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier 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.types.rev200120.ClusterIdentifier in project bgpcep by opendaylight.
the class ClusterIdAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final ClusterId cid = pathAttributes.getClusterId();
if (cid != null) {
final List<ClusterIdentifier> cluster = cid.getCluster();
if (cluster != null && !cluster.isEmpty()) {
final ByteBuf clusterIdBuffer = Unpooled.buffer();
for (final ClusterIdentifier clusterIdentifier : cluster) {
clusterIdBuffer.writeBytes(Ipv4Util.bytesForAddress(clusterIdentifier));
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, clusterIdBuffer, byteAggregator);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier in project bgpcep by opendaylight.
the class ClusterIdAttributeParserTest method testParseEmptyListAttribute.
@Test
public void testParseEmptyListAttribute() {
final List<ClusterIdentifier> list = new ArrayList<>();
final Attributes clusterId = new AttributesBuilder().setClusterId(new ClusterIdBuilder().setCluster(list).build()).build();
final ByteBuf output = Unpooled.buffer();
this.parser.serializeAttribute(clusterId, output);
assertEquals(Unpooled.buffer(), output);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier 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.types.rev200120.ClusterIdentifier 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();
}
Aggregations