Search in sources :

Example 1 with Sero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.Sero 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.dynamic.control.protection.object._case.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.basic.fast.reroute.object._case.BasicFastRerouteObject) BasicBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.basic.bandwidth.object._case.BasicBandwidthObject) ReoptimizationBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.reoptimization.bandwidth.object._case.ReoptimizationBandwidthObject) BandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.BandwidthObject) 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.basic.protection.object._case.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.basic.session.attribute.object._case.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.session.attribute.object.with.resources.affinities._case.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) SecondaryRecordRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.object.SecondaryRecordRouteObject) RecordRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.object.RecordRouteObject) TeLspAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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.basic.session.attribute.object._case.BasicSessionAttributeObject) LegacyFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.legacy.fast.reroute.object._case.LegacyFastRerouteObject) ProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.ProtectionObject) BasicProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.basic.protection.object._case.BasicProtectionObject) DynamicControlProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.dynamic.control.protection.object._case.DynamicControlProtectionObject) BasicBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.basic.bandwidth.object._case.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.legacy.fast.reroute.object._case.LegacyFastRerouteObject) BasicFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.basic.fast.reroute.object._case.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.reoptimization.bandwidth.object._case.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 Sero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.Sero in project bgpcep by opendaylight.

the class PCEPSecondaryExplicitRouteObjecParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Sero, "Wrong instance of PCEPObject. Passed %s. Needed EroObject.", object.getClass());
    final Sero sero = (Sero) object;
    final ByteBuf body = Unpooled.buffer();
    final List<Subobject> subObjects = sero.nonnullSubobject().stream().map(so -> new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setLoose(so.getLoose()).setSubobjectType(so.getSubobjectType()).build()).collect(Collectors.toList());
    serializeSubobject(subObjects, body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Also used : ObjectUtil(org.opendaylight.protocol.pcep.spi.ObjectUtil) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.sero.SubobjectBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) SeroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.SeroBuilder) Collectors(java.util.stream.Collectors) Sero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.Sero) Unpooled(io.netty.buffer.Unpooled) EROSubobjectRegistry(org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry) List(java.util.List) ByteBuf(io.netty.buffer.ByteBuf) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject) Preconditions(com.google.common.base.Preconditions) ObjectHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject) Sero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.Sero) Preconditions(com.google.common.base.Preconditions) Sero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.Sero) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with Sero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.Sero in project bgpcep by opendaylight.

the class PCEPSecondaryRecordRouteObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Srro, "Wrong instance of PCEPObject. Passed %s. Needed EroObject.", object.getClass());
    final Srro sero = (Srro) object;
    final ByteBuf body = Unpooled.buffer();
    final List<Subobject> subObjects = sero.nonnullSubobject().stream().map(so -> new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder().setSubobjectType(so.getSubobjectType()).setProtectionAvailable(so.getProtectionAvailable()).setProtectionInUse(so.getProtectionInUse()).build()).collect(Collectors.toList());
    serializeSubobject(subObjects, body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Also used : Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject) ObjectUtil(org.opendaylight.protocol.pcep.spi.ObjectUtil) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) Srro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro) Collectors(java.util.stream.Collectors) Unpooled(io.netty.buffer.Unpooled) List(java.util.List) ByteBuf(io.netty.buffer.ByteBuf) RROSubobjectRegistry(org.opendaylight.protocol.pcep.spi.RROSubobjectRegistry) SrroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.SrroBuilder) Preconditions(com.google.common.base.Preconditions) ObjectHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject) ByteBuf(io.netty.buffer.ByteBuf) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder) Srro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject)

Example 4 with Sero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.Sero in project bgpcep by opendaylight.

the class PCEPSecondaryExplicitRouteObjecParser method parseObject.

@Override
public Sero parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), EMPTY_ARRAY_ERROR);
    final SeroBuilder builder = new SeroBuilder();
    builder.setIgnore(header.getIgnore());
    builder.setProcessingRule(header.getProcessingRule());
    final List<Subobject> subObjects = parseSubobjects(buffer);
    builder.setSubobject(subObjects.stream().map(so -> new SubobjectBuilder().setLoose(so.getLoose()).setSubobjectType(so.getSubobjectType()).build()).collect(Collectors.toList()));
    return builder.build();
}
Also used : Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject) SeroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.SeroBuilder) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.sero.SubobjectBuilder)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)3 Preconditions (com.google.common.base.Preconditions)2 Unpooled (io.netty.buffer.Unpooled)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ObjectUtil (org.opendaylight.protocol.pcep.spi.ObjectUtil)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)2 ObjectHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader)2 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject)2 SeroBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.SeroBuilder)2 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.sero.SubobjectBuilder)2 EROSubobjectRegistry (org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry)1 RROSubobjectRegistry (org.opendaylight.protocol.pcep.spi.RROSubobjectRegistry)1 TeLspAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes)1 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject)1 Sero (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.explicit.route.object.Sero)1 Srro (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro)1 SrroBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.SrroBuilder)1 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder)1