use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getValidSvec.
private static Svec getValidSvec(final SvecBuilder builder, final List<Object> objects) {
Preconditions.checkArgument(objects != null && !objects.isEmpty(), "Passed list can't be null or empty.");
if (objects.get(0) instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.Svec) {
builder.setSvec((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.Svec) objects.get(0));
objects.remove(0);
} else {
return null;
}
final List<Metrics> metrics = new ArrayList<>();
final List<VendorInformationObject> viObjects = new ArrayList<>();
Object obj = null;
SvecState state = SvecState.INIT;
while (!objects.isEmpty() && !state.equals(SvecState.END)) {
obj = objects.get(0);
state = insertObject(state, obj, builder, metrics, viObjects);
if (!state.equals(SvecState.END)) {
objects.remove(0);
}
}
if (!viObjects.isEmpty()) {
builder.setVendorInformationObject(viObjects);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getSvecs.
protected List<Svec> getSvecs(final List<Object> objects) {
final List<Svec> svecList = new ArrayList<>();
while (!objects.isEmpty()) {
final SvecBuilder sBuilder = new SvecBuilder();
final Svec svecComp = getValidSvec(sBuilder, objects);
if (svecComp == null) {
break;
}
svecList.add(svecComp);
}
return svecList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method setUp.
@Before
public void setUp() {
this.ctx = new SimplePCEPExtensionProviderContext();
this.act = new BaseParserExtensionActivator();
this.viObjAct = new TestVendorInformationActivator();
this.act.start(this.ctx);
this.viObjAct.start(this.ctx);
this.objectRegistry = this.ctx.getObjectHandlerRegistry();
final RpBuilder rpBuilder = new RpBuilder().setProcessingRule(true).setIgnore(false).setReoptimization(false).setBiDirectional(false).setLoose(true).setMakeBeforeBreak(false).setOrder(false).setPathKey(false).setSupplyOf(false).setFragmentation(false).setP2mp(false).setEroCompression(false).setPriority(Uint8.ONE).setRequestId(new RequestId(Uint32.TEN)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder().build());
this.rpTrue = rpBuilder.build();
this.rpFalse = rpBuilder.setProcessingRule(false).build();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder openBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder().setProcessingRule(false).setIgnore(false).setDeadTimer(Uint8.ONE).setKeepalive(Uint8.ONE).setSessionId(Uint8.ZERO).setVersion(new ProtocolVersion(Uint8.ONE)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder().build());
// TODO get rid of previous superfluous openBuilder
this.open = openBuilder.build();
this.noPath = new NoPathBuilder().setProcessingRule(false).setIgnore(false).setNatureOfIssue(Uint8.ZERO).setUnsatisfiedConstraints(false).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build()).build();
this.lspa = new LspaBuilder().setProcessingRule(false).setIgnore(false).setLocalProtectionDesired(false).setHoldPriority(Uint8.ZERO).setSetupPriority(Uint8.ZERO).setExcludeAny(new AttributeFilter(Uint32.ZERO)).setIncludeAll(new AttributeFilter(Uint32.ZERO)).setIncludeAny(new AttributeFilter(Uint32.ZERO)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.lspa.TlvsBuilder().build()).build();
this.metrics = new MetricsBuilder().setMetric(new MetricBuilder().setIgnore(false).setProcessingRule(false).setComputed(false).setBound(false).setMetricType(Uint8.ONE).setValue(new Float32(new byte[4])).build()).build();
this.eroASSubobject = new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber(Uint32.valueOf(0xFFFF))).build()).build();
final IroBuilder iroBuilder = new IroBuilder();
iroBuilder.setIgnore(false);
iroBuilder.setProcessingRule(false);
final List<Subobject> iroSubs = new ArrayList<>();
iroSubs.add(new SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
iroBuilder.setSubobject(iroSubs);
this.iro = iroBuilder.build();
final EroBuilder eroBuilder = new EroBuilder();
eroBuilder.setIgnore(false);
eroBuilder.setProcessingRule(false);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject> eroSubs = new ArrayList<>();
eroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
eroBuilder.setSubobject(eroSubs);
this.ero = eroBuilder.build();
this.of = new OfBuilder().setIgnore(false).setProcessingRule(false).setCode(new OfId(Uint16.ZERO)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.of.TlvsBuilder().build()).build();
this.endpoints = new EndpointsObjBuilder().setIgnore(false).setProcessingRule(true).setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setSourceIpv4Address(new Ipv4AddressNoZone("255.255.255.255")).setDestinationIpv4Address(new Ipv4AddressNoZone("255.255.255.255")).build()).build()).build();
this.svec = new SvecBuilder().setIgnore(false).setProcessingRule(false).setLinkDiverse(false).setNodeDiverse(false).setSrlgDiverse(false).setLinkDirectionDiverse(false).setPartialPathDiverse(false).setRequestsIds(Lists.newArrayList(new RequestId(Uint32.ONE))).build();
this.viObjects = new ArrayList<>();
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO)).setEnterpriseSpecificInformation(esInfo).build();
this.viObjects.add(viObj);
this.monitoring = new MonitoringBuilder().setMonitoringId(Uint32.valueOf(100)).setFlags(new Flags(false, false, false, false, false)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.monitoring.TlvsBuilder().build()).build();
this.pccIdReq = new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1"))).build();
this.pceId = new PceIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.2"))).build();
this.procTime = new ProcTimeBuilder().setEstimated(false).setCurrentProcTime(Uint32.ONE).setMinProcTime(Uint32.TWO).setMaxProcTime(Uint32.valueOf(3)).setAverageProcTime(Uint32.valueOf(4)).setVarianceProcTime(Uint32.valueOf(5)).build();
this.overload = new OverloadBuilder().setDuration(Uint16.valueOf(120)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testSvecObject.
@Test
public void testSvecObject() throws IOException, PCEPDeserializerException {
final PCEPSvecObjectParser parser = new PCEPSvecObjectParser();
final SvecBuilder builder = new SvecBuilder().setProcessingRule(false).setIgnore(false).setLinkDiverse(false).setNodeDiverse(false).setSrlgDiverse(false).setPartialPathDiverse(false).setLinkDirectionDiverse(false).setRequestsIds(Lists.newArrayList(new RequestId(Uint32.valueOf(0xFF))));
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject1_10ReqIDs.bin"));
builder.setProcessingRule(true);
builder.setLinkDiverse(true);
builder.setSrlgDiverse(true);
final List<RequestId> requestIDs = new ArrayList<>();
requestIDs.add(new RequestId(Uint32.valueOf(0xFFFFFFFFL)));
requestIDs.add(new RequestId(Uint32.valueOf(0x00000001L)));
requestIDs.add(new RequestId(Uint32.valueOf(0x01234567L)));
requestIDs.add(new RequestId(Uint32.valueOf(0x89ABCDEFL)));
requestIDs.add(new RequestId(Uint32.valueOf(0xFEDCBA98L)));
requestIDs.add(new RequestId(Uint32.valueOf(0x76543210L)));
requestIDs.add(new RequestId(Uint32.valueOf(0x15825266L)));
requestIDs.add(new RequestId(Uint32.valueOf(0x48120BBEL)));
requestIDs.add(new RequestId(Uint32.valueOf(0x25FB7E52L)));
requestIDs.add(new RequestId(Uint32.valueOf(0xB2F2546BL)));
builder.setRequestsIds(requestIDs);
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
try {
parser.parseObject(new ObjectHeaderImpl(true, true), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
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.pcep.types.rev181109.svec.object.SvecBuilder in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getSvecs.
protected List<Svec> getSvecs(final Queue<Object> objects) {
final List<Svec> svecList = new ArrayList<>();
while (!objects.isEmpty()) {
final SvecBuilder sBuilder = new SvecBuilder();
final Svec svecComp = getValidSvec(sBuilder, objects);
if (svecComp == null) {
break;
}
svecList.add(svecComp);
}
return svecList;
}
Aggregations