use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathKey in project bgpcep by opendaylight.
the class CommonPathKeyParserTest method setUp.
@Before
public void setUp() {
this.key1 = new PathKeyBuilder().build();
this.key2 = new PathKeyBuilder().setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey(1)).build();
this.key3 = new PathKeyBuilder().setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey(1)).setPceId(new PceId(new byte[] { 2, 3 })).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathKey in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getRequests.
protected List<Requests> getRequests(final List<Object> objects, final List<Message> errors) {
final List<Requests> requests = new ArrayList<>();
while (!objects.isEmpty()) {
final RequestsBuilder rBuilder = new RequestsBuilder();
Rp rpObj = null;
if (!(objects.get(0) instanceof Rp)) {
// if RP obj is missing return error only
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
return null;
}
rpObj = (Rp) objects.get(0);
objects.remove(0);
if (!rpObj.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
} else {
rBuilder.setRp(rpObj);
}
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
if (!vendorInfo.isEmpty()) {
rBuilder.setVendorInformationObject(vendorInfo);
}
// expansion
if (rpObj.isPathKey() && objects.get(0) instanceof PathKey) {
rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) objects.get(0)).build());
}
final P2pBuilder p2pBuilder = new P2pBuilder();
if (!objects.isEmpty() && objects.get(0) instanceof EndpointsObj) {
final EndpointsObj ep = (EndpointsObj) objects.get(0);
objects.remove(0);
if (!ep.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rpObj)));
} else {
p2pBuilder.setEndpointsObj(ep);
}
} else {
errors.add(createErrorMsg(PCEPErrors.END_POINTS_MISSING, Optional.of(rpObj)));
return null;
}
// p2p
if (!rpObj.isP2mp()) {
final SegmentComputation segm = getSegmentComputation(p2pBuilder, objects, errors, rpObj);
if (segm != null) {
rBuilder.setSegmentComputation(segm);
}
}
requests.add(rBuilder.build());
}
return requests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathKey in project bgpcep by opendaylight.
the class PCEPXROSubobjectParserTest method testXROPathKey128Subobject.
@Test
public void testXROPathKey128Subobject() throws PCEPDeserializerException {
final XROPathKey128SubobjectParser parser = new XROPathKey128SubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setMandatory(true);
final PathKeyBuilder pBuilder = new PathKeyBuilder();
pBuilder.setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }));
pBuilder.setPathKey(new PathKey(4660));
subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(pathKey128Bytes, 2)), true));
final ByteBuf buff = Unpooled.buffer();
XROPathKey128SubobjectParser.serializeSubobject(subs.build(), buff);
assertArrayEquals(pathKey128Bytes, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathKey in project bgpcep by opendaylight.
the class RROPathKey128SubobjectParser method serializeSubobject.
public static void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
final PathKeyCase pkcase = (PathKeyCase) subobject.getSubobjectType();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
final ByteBuf body = Unpooled.buffer();
final PathKey pathKey = pk.getPathKey();
checkArgument(pathKey != null, "PathKey is mandatory.");
ByteBufUtils.write(body, pathKey.getValue());
final PceId pceId = pk.getPceId();
checkArgument(pceId != null, "PceId is mandatory.");
body.writeBytes(pceId.getValue());
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathKey in project bgpcep by opendaylight.
the class PCEPPathKeyObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof PathKey, "Wrong instance of PCEPObject. Passed %s. Needed PathKeyObject.", object.getClass());
final PathKey pkey = (PathKey) object;
final ByteBuf body = Unpooled.buffer();
final List<Subobject> subs = new ArrayList<>();
for (final PathKeys pk : pkey.nonnullPathKeys()) {
subs.add(new SubobjectBuilder().setLoose(pk.getLoose()).setSubobjectType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder().setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder().setPathKey(pk.getPathKey()).setPceId(pk.getPceId()).build()).build()).build());
}
serializeSubobject(subs, body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Aggregations