Search in sources :

Example 6 with LinkStateAttribute

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.LinkStateAttribute in project bgpcep by opendaylight.

the class LinkstateTopologyBuilder method createPrefix.

private void createPrefix(final WriteTransaction trans, final UriBuilder base, final LinkstateRoute value, final PrefixCase prefixCase, final Attributes attributes) {
    final IpPrefix ippfx = prefixCase.getPrefixDescriptors().getIpReachabilityInformation();
    if (ippfx == null) {
        LOG.warn("IP reachability not present in prefix {} route {}, skipping it", prefixCase, value);
        return;
    }
    final PrefixBuilder pb = new PrefixBuilder();
    final PrefixKey pk = new PrefixKey(ippfx);
    pb.setKey(pk);
    pb.setPrefix(ippfx);
    final PrefixAttributes pa;
    // Very defensive lookup
    final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
    if (attr != null) {
        final LinkStateAttribute attrType = attr.getLinkStateAttribute();
        if (attrType != null) {
            pa = ((PrefixAttributesCase) attrType).getPrefixAttributes();
        } else {
            LOG.debug("Missing attribute type in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
            pa = null;
        }
    } else {
        LOG.debug("Missing attributes in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
        pa = null;
    }
    if (pa != null) {
        pb.setMetric(pa.getPrefixMetric().getValue());
    }
    ProtocolUtil.augmentProtocolId(value, pa, pb);
    final Prefix pfx = pb.build();
    LOG.debug("Created prefix {} for {}", pfx, prefixCase);
    /*
         * All set, but... the hosting node may not exist, we may need to fake it.
         */
    final NodeId node = buildNodeId(base, prefixCase.getAdvertisingNodeDescriptors());
    NodeHolder nh = this.nodes.get(node);
    if (nh == null) {
        nh = getNode(node);
        nh.addPrefix(pfx);
        putNode(trans, nh);
    } else {
        nh.addPrefix(pfx);
        final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(nh.getNodeId()));
        final InstanceIdentifier<IgpNodeAttributes> inaId = nid.builder().augmentation(Node1.class).child(IgpNodeAttributes.class).build();
        trans.put(LogicalDatastoreType.OPERATIONAL, inaId.child(Prefix.class, pk), pfx);
    }
}
Also used : PrefixKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.PrefixKey) PrefixAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.routes.linkstate.routes.linkstate.route.Attributes1) Prefix(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.Prefix) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IgpNodeAttributes(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.IgpNodeAttributes) LinkStateAttribute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.LinkStateAttribute) PrefixBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.PrefixBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 7 with LinkStateAttribute

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.LinkStateAttribute in project bgpcep by opendaylight.

the class PrefixAttributesParser method parsePrefixAttributes.

/**
 * Parse prefix attributes.
 *
 * @param attributes key is the tlv type and value are the value bytes of the tlv
 * @param protocolId to differentiate parsing methods
 * @return {@link LinkStateAttribute}
 */
static LinkStateAttribute parsePrefixAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
    final PrefixAttributesBuilder builder = new PrefixAttributesBuilder();
    final List<RouteTag> routeTags = new ArrayList<>();
    final List<ExtendedRouteTag> exRouteTags = new ArrayList<>();
    for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
        final int key = entry.getKey();
        final ByteBuf value = entry.getValue();
        LOG.trace("Prefix attribute TLV {}", key);
        parseAttribute(key, value, protocolId, builder, routeTags, exRouteTags);
    }
    LOG.trace("Finished parsing Prefix Attributes.");
    builder.setRouteTags(routeTags);
    builder.setExtendedTags(exRouteTags);
    return new PrefixAttributesCaseBuilder().setPrefixAttributes(builder.build()).build();
}
Also used : ExtendedRouteTag(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.ExtendedRouteTag) ArrayList(java.util.ArrayList) PrefixAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributesBuilder) ByteBuf(io.netty.buffer.ByteBuf) RouteTag(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.RouteTag) ExtendedRouteTag(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.ExtendedRouteTag) PrefixAttributesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.PrefixAttributesCaseBuilder)

Example 8 with LinkStateAttribute

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.LinkStateAttribute in project bgpcep by opendaylight.

the class TeLspAttributesParser method parseTeLspAttributes.

static LinkStateAttribute parseTeLspAttributes(final RSVPTeObjectRegistry registry, final ByteBuf attributes) throws BGPParsingException {
    final TeLspAttributesBuilder builder = new TeLspAttributesBuilder();
    LOG.trace("Initiated parsing TE LSP Objects.");
    while (attributes.isReadable()) {
        final int length = attributes.readUnsignedShort();
        final int classNum = attributes.readUnsignedByte();
        final int cType = attributes.readUnsignedByte();
        final ByteBuf value = attributes.readSlice(length);
        try {
            addObject(builder, registry.parseRSPVTe(classNum, cType, value));
        } catch (final RSVPParsingException e) {
            LOG.debug("Parsering TE LSP Object error. class number: {} cType: {} value: {}", classNum, cType, value, e);
            throw new BGPParsingException(e.getMessage());
        }
    }
    LOG.trace("Finished parsing TE LSP Objects.");
    return new TeLspAttributesCaseBuilder().setTeLspAttributes(builder.build()).build();
}
Also used : TeLspAttributesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.TeLspAttributesCaseBuilder) TeLspAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributesBuilder) BGPParsingException(org.opendaylight.protocol.bgp.parser.BGPParsingException) ByteBuf(io.netty.buffer.ByteBuf) RSVPParsingException(org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)5 ArrayList (java.util.ArrayList)4 LinkStateAttribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.LinkStateAttribute)4 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.routes.linkstate.routes.linkstate.route.Attributes1)3 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)3 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)3 Ipv4RouterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Ipv4RouterIdentifier)2 Ipv6RouterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Ipv6RouterIdentifier)2 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 IgpNodeAttributes (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.IgpNodeAttributes)2 BGPParsingException (org.opendaylight.protocol.bgp.parser.BGPParsingException)1 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)1 BitArray (org.opendaylight.protocol.util.BitArray)1 DomainName (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.DomainName)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 AdministrativeGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.AdministrativeGroup)1 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1)1 ExtendedRouteTag (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.ExtendedRouteTag)1 IsisAreaIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.IsisAreaIdentifier)1