Search in sources :

Example 1 with TeLspAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes in project bgpcep by opendaylight.

the class TeLspAttributesParser method serializeLspAttributes.

static void serializeLspAttributes(final RSVPTeObjectRegistry registry, final TeLspAttributesCase linkState, final ByteBuf output) {
    LOG.trace("Started serializing TE LSP Objects");
    final ByteBuf byteBuf = Unpooled.buffer();
    final TeLspAttributes teLspAttribute = linkState.getTeLspAttributes();
    final TspecObject tSpec = teLspAttribute.getTspecObject();
    registry.serializeRSPVTe(tSpec, byteBuf);
    final FlowSpecObject flow = teLspAttribute.getFlowSpecObject();
    registry.serializeRSPVTe(flow, byteBuf);
    final SessionAttributeObject sao = teLspAttribute.getSessionAttributeObject();
    if (sao instanceof BasicSessionAttributeObject) {
        registry.serializeRSPVTe((BasicSessionAttributeObject) sao, byteBuf);
    } else if (sao instanceof SessionAttributeObjectWithResourcesAffinities) {
        registry.serializeRSPVTe((SessionAttributeObjectWithResourcesAffinities) sao, byteBuf);
    }
    final ExplicitRouteObject ero = teLspAttribute.getExplicitRouteObject();
    registry.serializeRSPVTe(ero, byteBuf);
    final RecordRouteObject rro = teLspAttribute.getRecordRouteObject();
    registry.serializeRSPVTe(rro, byteBuf);
    final FastRerouteObject fro = teLspAttribute.getFastRerouteObject();
    if (fro instanceof BasicFastRerouteObject) {
        registry.serializeRSPVTe((BasicFastRerouteObject) fro, byteBuf);
    } else if (fro instanceof LegacyFastRerouteObject) {
        registry.serializeRSPVTe((LegacyFastRerouteObject) fro, byteBuf);
    }
    final DetourObject dto = teLspAttribute.getDetourObject();
    if (dto instanceof Ipv4DetourObject) {
        registry.serializeRSPVTe((Ipv4DetourObject) dto, byteBuf);
    } else if (dto instanceof Ipv6DetourObject) {
        registry.serializeRSPVTe((Ipv6DetourObject) dto, byteBuf);
    }
    final ExcludeRouteObject exro = teLspAttribute.getExcludeRouteObject();
    registry.serializeRSPVTe(exro, byteBuf);
    final SecondaryExplicitRouteObject sero = teLspAttribute.getSecondaryExplicitRouteObject();
    registry.serializeRSPVTe(sero, byteBuf);
    final SecondaryRecordRouteObject srro = teLspAttribute.getSecondaryRecordRouteObject();
    registry.serializeRSPVTe(srro, byteBuf);
    final LspAttributesObject lspAtt = teLspAttribute.getLspAttributesObject();
    registry.serializeRSPVTe(lspAtt, byteBuf);
    final LspRequiredAttributesObject rao = teLspAttribute.getLspRequiredAttributesObject();
    registry.serializeRSPVTe(rao, byteBuf);
    final ProtectionObject po = teLspAttribute.getProtectionObject();
    if (po instanceof DynamicControlProtectionObject) {
        registry.serializeRSPVTe((DynamicControlProtectionObject) po, byteBuf);
    } else if (po instanceof BasicProtectionObject) {
        registry.serializeRSPVTe((BasicProtectionObject) po, byteBuf);
    }
    final AssociationObject aso = teLspAttribute.getAssociationObject();
    registry.serializeRSPVTe(aso, byteBuf);
    final PrimaryPathRouteObject ppr = teLspAttribute.getPrimaryPathRouteObject();
    registry.serializeRSPVTe(ppr, byteBuf);
    final AdminStatusObject adso = teLspAttribute.getAdminStatusObject();
    registry.serializeRSPVTe(adso, byteBuf);
    final BandwidthObject bo = teLspAttribute.getBandwidthObject();
    if (bo instanceof BasicBandwidthObject) {
        registry.serializeRSPVTe((BasicBandwidthObject) bo, byteBuf);
    } else if (bo instanceof ReoptimizationBandwidthObject) {
        registry.serializeRSPVTe((ReoptimizationBandwidthObject) bo, byteBuf);
    }
    final MetricObject mo = teLspAttribute.getMetricObject();
    registry.serializeRSPVTe(mo, byteBuf);
    output.writeShort(MAGIC_NUMBER);
    output.writeShort(byteBuf.readableBytes());
    output.writeBytes(byteBuf);
    LOG.trace("Finished serializing TE LSP Objects");
}
Also used : DynamicControlProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.DynamicControlProtectionObject) ByteBuf(io.netty.buffer.ByteBuf) LspRequiredAttributesObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.required.attributes.object.LspRequiredAttributesObject) FlowSpecObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.flow.spec.object.FlowSpecObject) TspecObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject) BasicFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.BasicFastRerouteObject) ReoptimizationBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.ReoptimizationBandwidthObject) BandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.BandwidthObject) BasicBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.BasicBandwidthObject) MetricObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.metric.object.MetricObject) BasicProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.BasicProtectionObject) LspAttributesObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.LspAttributesObject) AssociationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject) BasicSessionAttributeObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.BasicSessionAttributeObject) SessionAttributeObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.SessionAttributeObject) SessionAttributeObjectWithResourcesAffinities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.SessionAttributeObjectWithResourcesAffinities) Ipv4DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv4DetourObject) Ipv6DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv6DetourObject) DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.DetourObject) RecordRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.object.RecordRouteObject) SecondaryRecordRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.object.SecondaryRecordRouteObject) TeLspAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes) BasicSessionAttributeObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.BasicSessionAttributeObject) LegacyFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.LegacyFastRerouteObject) ProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.ProtectionObject) DynamicControlProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.DynamicControlProtectionObject) BasicProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.BasicProtectionObject) BasicBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.BasicBandwidthObject) SecondaryRecordRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.object.SecondaryRecordRouteObject) FastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.FastRerouteObject) LegacyFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.LegacyFastRerouteObject) BasicFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.BasicFastRerouteObject) Ipv6DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv6DetourObject) ExplicitRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.object.ExplicitRouteObject) SecondaryExplicitRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.SecondaryExplicitRouteObject) PrimaryPathRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.primary.path.route.object.PrimaryPathRouteObject) AdminStatusObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.admin.status.object.AdminStatusObject) ReoptimizationBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.ReoptimizationBandwidthObject) SecondaryExplicitRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.SecondaryExplicitRouteObject) ExcludeRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.ExcludeRouteObject) Ipv4DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv4DetourObject)

Example 2 with TeLspAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes in project bgpcep by opendaylight.

the class LinkstateAttributeParserTest method testPositiveTELspAttribute.

@Test
public void testPositiveTELspAttribute() throws BGPParsingException {
    final AttributesBuilder builder = createBuilder(new TeLspCaseBuilder().build());
    this.parser.parseAttribute(Unpooled.copiedBuffer(TE_LSP_ATTR), builder);
    final Attributes1 attrs = builder.getAugmentation(Attributes1.class);
    final TeLspAttributes teLspAttributes = ((TeLspAttributesCase) attrs.getLinkStateAttribute()).getTeLspAttributes();
    assertNotNull(teLspAttributes);
    final TspecObject tSpec = teLspAttributes.getTspecObject();
    assertNotNull(tSpec);
    assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 }), tSpec.getTokenBucketRate());
    assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02 }), teLspAttributes.getTspecObject().getTokenBucketSize());
    assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03 }), tSpec.getPeakDataRate());
    assertEquals(new Long("4"), tSpec.getMinimumPolicedUnit());
    assertEquals(new Long("5"), tSpec.getMaximumPacketSize());
    final AssociationObject associationObject = teLspAttributes.getAssociationObject();
    assertEquals(AssociationType.Recovery, associationObject.getAssociationType());
    final IpAddress ipv4 = new IpAddress(Ipv4Util.addressForByteBuf(Unpooled.copiedBuffer(new byte[] { 0x01, 0x02, 0x03, 0x04 })));
    assertEquals(ipv4, associationObject.getIpAddress());
    final short associationId = 2;
    assertEquals(associationId, associationObject.getAssociationId().shortValue());
    // serialization
    final ByteBuf buff = Unpooled.buffer();
    this.parser.serializeAttribute(builder.build(), buff);
    assertArrayEquals(TE_LSP_ATTR, ByteArray.getAllBytes(buff));
    assertTrue(Arrays.equals(TE_LSP_ATTR, ByteArray.getAllBytes(buff)));
}
Also used : TspecObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject) AssociationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject) Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) TeLspAttributesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.TeLspAttributesCase) TeLspCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) TeLspAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 TeLspAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes)2 AssociationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject)2 TspecObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject)2 Test (org.junit.Test)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1)1 TeLspCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCaseBuilder)1 TeLspAttributesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.TeLspAttributesCase)1 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)1 Float32 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32)1 AdminStatusObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.admin.status.object.AdminStatusObject)1 BandwidthObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.BandwidthObject)1 BasicBandwidthObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.BasicBandwidthObject)1 ReoptimizationBandwidthObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.ReoptimizationBandwidthObject)1 DetourObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.DetourObject)1 Ipv4DetourObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv4DetourObject)1 Ipv6DetourObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv6DetourObject)1 ExcludeRouteObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.ExcludeRouteObject)1 ExplicitRouteObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.object.ExplicitRouteObject)1