use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.srlg._case.SrlgBuilder in project bgpcep by opendaylight.
the class XROSrlgSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; " + "Expected: " + CONTENT_LENGTH + ".");
}
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setMandatory(mandatory);
builder.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(buffer.readUnsignedInt())).build()).build());
buffer.readByte();
builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.srlg._case.SrlgBuilder in project bgpcep by opendaylight.
the class ProtocolUtil method isisLinkAttributes.
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1 isisLinkAttributes(final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.isis.link.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.isis.link.attributes.TedBuilder();
if (la != null) {
if (la.getAdminGroup() != null) {
tb.setColor(la.getAdminGroup().getValue());
}
if (la.getTeMetric() != null) {
tb.setTeDefaultMetric(la.getTeMetric().getValue());
}
if (la.getUnreservedBandwidth() != null) {
tb.setUnreservedBandwidth(unreservedBandwidthList(la.getUnreservedBandwidth()));
}
if (la.getMaxLinkBandwidth() != null) {
tb.setMaxLinkBandwidth(bandwidthToBigDecimal(la.getMaxLinkBandwidth()));
}
if (la.getMaxReservableBandwidth() != null) {
tb.setMaxResvLinkBandwidth(bandwidthToBigDecimal(la.getMaxReservableBandwidth()));
}
if (la.getSharedRiskLinkGroups() != null) {
final List<SrlgValues> srlgs = new ArrayList<>();
for (final SrlgId id : la.getSharedRiskLinkGroups()) {
srlgs.add(new SrlgValuesBuilder().setSrlgValue(id.getValue()).build());
}
tb.setSrlg(new SrlgBuilder().setSrlgValues(srlgs).build());
}
}
final IsisLinkAttributesBuilder ilab = new IsisLinkAttributesBuilder();
ilab.setTed(tb.build());
if (topologyIdentifier != null) {
ilab.setMultiTopologyId(topologyIdentifier.getValue().shortValue());
}
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1Builder().setIsisLinkAttributes(ilab.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.srlg._case.SrlgBuilder in project bgpcep by opendaylight.
the class ProtocolUtil method ospfLinkAttributes.
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1 ospfLinkAttributes(final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.link.attributes.ospf.link.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.link.attributes.ospf.link.attributes.TedBuilder();
if (la != null) {
if (la.getAdminGroup() != null) {
tb.setColor(la.getAdminGroup().getValue());
}
if (la.getTeMetric() != null) {
tb.setTeDefaultMetric(la.getTeMetric().getValue());
}
if (la.getUnreservedBandwidth() != null) {
tb.setUnreservedBandwidth(unreservedBandwidthList(la.getUnreservedBandwidth()));
}
if (la.getMaxLinkBandwidth() != null) {
tb.setMaxLinkBandwidth(bandwidthToBigDecimal(la.getMaxLinkBandwidth()));
}
if (la.getMaxReservableBandwidth() != null) {
tb.setMaxResvLinkBandwidth(bandwidthToBigDecimal(la.getMaxReservableBandwidth()));
}
if (la.getSharedRiskLinkGroups() != null) {
final List<SrlgValues> srlgs = new ArrayList<>();
for (final SrlgId id : la.getSharedRiskLinkGroups()) {
srlgs.add(new SrlgValuesBuilder().setSrlgValue(id.getValue()).build());
}
tb.setSrlg(new SrlgBuilder().setSrlgValues(srlgs).build());
}
}
final OspfLinkAttributesBuilder ilab = new OspfLinkAttributesBuilder();
ilab.setTed(tb.build());
if (topologyIdentifier != null) {
ilab.setMultiTopologyId(topologyIdentifier.getValue().shortValue());
}
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1Builder().setOspfLinkAttributes(ilab.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.srlg._case.SrlgBuilder in project bgpcep by opendaylight.
the class XROSRLGSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + ".");
}
final SubobjectBuilder builder = new SubobjectBuilder();
builder.setMandatory(mandatory);
builder.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(buffer.readUnsignedInt())).build()).build());
buffer.readByte();
builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.srlg._case.SrlgBuilder in project bgpcep by opendaylight.
the class XROSubobjectParserTest method testXROSrlgSubobject.
@Test
public void testXROSrlgSubobject() throws RSVPParsingException {
final XROSrlgSubobjectParser parser = new XROSrlgSubobjectParser();
final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
subs.setMandatory(true);
subs.setAttribute(ExcludeRouteSubobjects.Attribute.Srlg);
subs.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(0x12345678L)).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(SRLG_BYTES, 2)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
Assert.assertArrayEquals(SRLG_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
Assert.fail();
} catch (final IllegalArgumentException e) {
Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
Assert.fail();
} catch (final IllegalArgumentException e) {
Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
Aggregations