Search in sources :

Example 31 with Attributes1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1 in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method createPrefix.

/**
 * Create new Prefix in the Connected Graph.
 *
 * @param value       The complete Linkstate route information
 * @param prefixCase  The Prefix part of the Linkstate route
 * @param attributes  The Prefix attributes
 */
private void createPrefix(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;
    }
    /* Verify that all mandatory information are present */
    final PrefixAttributes pa;
    final Attributes1 attr = attributes.augmentation(Attributes1.class);
    if (attr != null) {
        final LinkStateAttribute attrType = attr.getLinkStateAttribute();
        if (attrType instanceof PrefixAttributesCase) {
            pa = ((PrefixAttributesCase) attrType).getPrefixAttributes();
        } else {
            LOG.warn("Missing attribute type in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
            return;
        }
    } else {
        LOG.warn("Missing attributes in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
        return;
    }
    /*
         * Get Connected Vertex from Connected Graph corresponding to the
         * Advertising Node Descriptor
         */
    Uint64 vertexId = getVertexId(prefixCase.getAdvertisingNodeDescriptors().getCRouterIdentifier());
    if (vertexId == Uint64.ZERO) {
        LOG.warn("Unable to get the Vertex Identifier from descriptor {}, skipping it", prefixCase.getAdvertisingNodeDescriptors());
        return;
    }
    /* Create Prefix */
    PrefixBuilder builder = new PrefixBuilder().setVertexId(vertexId).setPrefix(ippfx);
    if (pa.getSrPrefix() != null && pa.getSrPrefix().getSidLabelIndex() instanceof SidCase) {
        builder.setPrefixSid(((SidCase) pa.getSrPrefix().getSidLabelIndex()).getSid());
        if (pa.getSrPrefix().getFlags() instanceof IsisPrefixFlagsCase) {
            builder.setNodeSid(((IsisPrefixFlagsCase) pa.getSrPrefix().getFlags()).getIsisPrefixFlags().getNodeSid());
        } else {
            /*
                 * Seems that OSPF Flags are not accessible. Assuming that the
                 * Prefix is a Node SID
                 */
            builder.setNodeSid(true);
        }
    }
    Prefix prefix = builder.build();
    /* Add the Prefix to the Connected Vertex within the Connected Graph */
    LOG.info("Add prefix {} in TED[{}]", builder.getPrefix(), cgraph);
    cgraph.addPrefix(prefix);
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IsisPrefixFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.prefix.sid.tlv.flags.IsisPrefixFlagsCase) PrefixAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes) PrefixAttributesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.routes.linkstate.routes.linkstate.route.Attributes1) Prefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) LinkStateAttribute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.LinkStateAttribute) SidCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCase) Uint64(org.opendaylight.yangtools.yang.common.Uint64) PrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder)

Example 32 with Attributes1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1 in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method getNodeAttributes.

/**
 * Get Node Attributes from Link State Route attributes.
 *
 * @param attributes  The attribute part from the Link State route
 *
 * @return Node Attributes
 */
private static NodeAttributes getNodeAttributes(final Attributes attributes) {
    final NodeAttributes na;
    final Attributes1 attr = attributes.augmentation(Attributes1.class);
    if (attr != null) {
        final LinkStateAttribute attrType = attr.getLinkStateAttribute();
        if (attrType != null) {
            na = ((NodeAttributesCase) attrType).getNodeAttributes();
        } else {
            return null;
        }
    } else {
        return null;
    }
    return na;
}
Also used : NodeAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.routes.linkstate.routes.linkstate.route.Attributes1) LinkStateAttribute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.LinkStateAttribute)

Aggregations

Test (org.junit.Test)12 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1)12 ByteBuf (io.netty.buffer.ByteBuf)10 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)10 Attributes2 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2)10 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1)6 LinkStateAttribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.LinkStateAttribute)6 AdvertizedRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes)6 Preconditions (com.google.common.base.Preconditions)5 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.routes.linkstate.routes.linkstate.route.Attributes1)5 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)5 WithdrawnRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutes)5 ArrayList (java.util.ArrayList)4 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)4 Attributes1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder)4 MpReachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri)4 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)3 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1)3 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)3 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)3