use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method getValidReply.
protected Replies getValidReply(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Object object = objects.remove(0);
if (!(object instanceof Rp)) {
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
return null;
}
final Rp rp = (Rp) object;
final RepliesBuilder repliesBuilder = new RepliesBuilder();
if (!objects.isEmpty() && objects.get(0) instanceof Monitoring) {
repliesBuilder.setMonitoring((Monitoring) objects.get(0));
objects.remove(0);
}
if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
repliesBuilder.setPccIdReq((PccIdReq) objects.get(0));
objects.remove(0);
}
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
Result res = null;
if (!objects.isEmpty()) {
if (objects.get(0) instanceof NoPath) {
res = handleNoPath((NoPath) objects.get(0), objects);
} else if (objects.get(0) instanceof Ero) {
res = handleEro((Ero) objects.get(0), objects);
}
}
final List<MetricPce> metricPceList = new ArrayList<>();
if (!objects.isEmpty() && objects.get(0) instanceof PceId) {
while (!objects.isEmpty()) {
metricPceList.add(Util.validateMonitoringMetrics(objects));
}
}
if (!vendorInfo.isEmpty()) {
repliesBuilder.setVendorInformationObject(vendorInfo);
}
if (!metricPceList.isEmpty()) {
repliesBuilder.setMetricPce(metricPceList);
}
return repliesBuilder.setRp(rp).setResult(res).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getMonitoring.
protected MonitoringRequest getMonitoring(final Queue<Object> objects) {
final MonitoringRequestBuilder builder = new MonitoringRequestBuilder();
Object obj = objects.peek();
if (obj instanceof Monitoring) {
builder.setMonitoring((Monitoring) obj);
objects.remove();
} else {
return null;
}
obj = objects.peek();
if (obj instanceof PccIdReq) {
builder.setPccIdReq((PccIdReq) obj);
objects.remove();
obj = objects.peek();
}
final List<PceIdList> pceIdList = new ArrayList<>();
while (obj instanceof PceId) {
pceIdList.add(new PceIdListBuilder().setPceId((PceId) obj).build());
objects.remove();
obj = objects.peek();
}
if (!pceIdList.isEmpty()) {
builder.setPceIdList(pceIdList);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testPceIdIPv6Object.
@Test
public void testPceIdIPv6Object() throws PCEPDeserializerException {
final byte[] pccIdReqBytes = { /* object header */
0x19, 0x20, 0x00, 0x14, /* ipv6 header */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
final PCEPPceIdIPv6ObjectParser parser = new PCEPPceIdIPv6ObjectParser();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceId pccIdReq = new PceIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("::1"))).build();
final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
parser.serializeObject(pccIdReq, buf);
assertArrayEquals(pccIdReqBytes, buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq in project bgpcep by opendaylight.
the class PCEPMonitoringReplyMessageParser method validate.
@Override
protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcmonrep message cannot be empty.");
}
if (!(objects.get(0) instanceof Monitoring)) {
errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.absent()));
return null;
}
final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder();
builder.setMonitoring((Monitoring) objects.get(0));
objects.remove(0);
if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
builder.setPccIdReq((PccIdReq) objects.get(0));
objects.remove(0);
}
validateSpecificMetrics(objects, builder);
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getMonitoring.
protected MonitoringRequest getMonitoring(final List<Object> objects) {
final MonitoringRequestBuilder builder = new MonitoringRequestBuilder();
if (!objects.isEmpty() && objects.get(0) instanceof Monitoring) {
builder.setMonitoring((Monitoring) objects.get(0));
objects.remove(0);
} else {
return null;
}
if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
builder.setPccIdReq((PccIdReq) objects.get(0));
objects.remove(0);
}
final List<PceIdList> pceIdList = new ArrayList<>();
while (!objects.isEmpty() && objects.get(0) instanceof PceId) {
pceIdList.add(new PceIdListBuilder().setPceId((PceId) objects.get(0)).build());
objects.remove(0);
}
if (!pceIdList.isEmpty()) {
builder.setPceIdList(pceIdList);
}
return builder.build();
}
Aggregations