Search in sources :

Example 1 with VendorInformationObjectBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder 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();
}
Also used : LspaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.LspaBuilder) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) AsNumberCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder) ArrayList(java.util.ArrayList) PceIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceIdBuilder) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion) SpecificMetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetricsBuilder) MetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder) PccIdReqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReqBuilder) OverloadBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.OverloadBuilder) Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) EroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder) NoPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder) RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId) BaseParserExtensionActivator(org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.c.close.TlvsBuilder) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder) AttributeFilter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.Subobject) ProcTimeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.proc.time.object.ProcTimeBuilder) Notifications(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications) Collections(java.util.Collections) P2mpIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv4._case.P2mpIpv4Builder) Ipv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder) VendorInformationObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.SubobjectBuilder) AsNumberBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder) P2mpIpv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv4CaseBuilder) Ipv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder) TestEnterpriseSpecificInformation(org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation) OfId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OfId) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) EnterpriseNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) SimplePCEPExtensionProviderContext(org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext) MetricBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder) EndpointsObjBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.Subobject) MonitoringBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.MonitoringBuilder) SvecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags) OfBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.OfBuilder) IroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.IroBuilder) Before(org.junit.Before)

Example 2 with VendorInformationObjectBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder in project bgpcep by opendaylight.

the class AbstractVendorInformationObjectParser method parseObject.

@Override
public final Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final VendorInformationObjectBuilder builder = new VendorInformationObjectBuilder();
    builder.setEnterpriseNumber(new EnterpriseNumber(getEnterpriseNumber()));
    builder.setEnterpriseSpecificInformation(parseEnterpriseSpecificInformation(buffer));
    return builder.build();
}
Also used : EnterpriseNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber) VendorInformationObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObjectBuilder)

Example 3 with VendorInformationObjectBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testVendorInformationObject.

@Test
public void testVendorInformationObject() throws PCEPDeserializerException {
    final byte[] viObjBytes = { /* vendor-information object */
    0x22, 0x10, 0x00, 0x0C, /* enterprise number */
    0x00, 0x00, 0x00, 0x00, /* enterprise specific information */
    0x00, 0x00, 0x00, 0x05 };
    final TestVendorInformationObjectParser parser = new TestVendorInformationObjectParser();
    final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
    final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO)).setEnterpriseSpecificInformation(esInfo).build();
    final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
    result.readerIndex(8);
    final VendorInformationObject o = (VendorInformationObject) parser.parseObject(new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
    assertEquals(viObj, o);
    final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
    parser.serializeObject(viObj, buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
Also used : ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) TestEnterpriseSpecificInformation(org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) EnterpriseNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber) VendorInformationObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 4 with VendorInformationObjectBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder in project bgpcep by opendaylight.

the class AbstractMessageParserTest method setUp.

@Before
public void setUp() throws PCEPDeserializerException {
    this.object = new ErrorObjectBuilder().setType(Uint8.ONE).setValue(Uint8.ONE).build();
    this.viObject = new VendorInformationObjectBuilder().setEnterpriseNumber(EN).build();
    doNothing().when(this.registry).serializeVendorInformationObject(any(VendorInformationObject.class), any(ByteBuf.class));
    doReturn(Optional.of(this.viObject)).when(this.registry).parseVendorInformationObject(eq(EN), eq(new ObjectHeaderImpl(true, true)), any(ByteBuf.class));
    doNothing().when(this.registry).serializeObject(any(Object.class), any(ByteBuf.class));
    doReturn(this.object).when(this.registry).parseObject(13, 1, new ObjectHeaderImpl(true, true), Unpooled.wrappedBuffer(new byte[] { 0, 0, 1, 1 }));
}
Also used : VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObject) VendorInformationObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder) ByteBuf(io.netty.buffer.ByteBuf) ErrorObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObjectBuilder) Before(org.junit.Before)

Aggregations

EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)3 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)3 VendorInformationObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder)3 ByteBuf (io.netty.buffer.ByteBuf)2 Before (org.junit.Before)2 TestEnterpriseSpecificInformation (org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Test (org.junit.Test)1 BaseParserExtensionActivator (org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 SimplePCEPExtensionProviderContext (org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext)1 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)1 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)1 Float32 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32)1 VendorInformationObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObjectBuilder)1 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)1 OfId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OfId)1 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion)1 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId)1