Search in sources :

Example 1 with SrgbBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.vertex.SrgbBuilder in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method getVertex.

/**
 * Create Vertex from the Node Attributes.
 *
 * @param na       Node Attributes
 * @param cvertex  Connected Vertex associated to this Vertex
 * @param as       As number
 *
 * @return New Vertex
 */
private static Vertex getVertex(final NodeAttributes na, final Uint64 id, final Uint32 as) {
    VertexBuilder builder = new VertexBuilder().setVertexId(id).setAsn(as);
    if (na.getIpv4RouterId() != null) {
        builder.setRouterId(new IpAddress(na.getIpv4RouterId()));
    }
    if (na.getIpv6RouterId() != null) {
        builder.setRouterId(new IpAddress(na.getIpv6RouterId()));
    }
    /*
         * Set Router Name with dynamic hostname (IS-IS) or IPv4 address in dot decimal format (OSPF)
         */
    if (na.getDynamicHostname() != null) {
        builder.setName(na.getDynamicHostname());
    } else {
        int key = id.intValue();
        builder.setName((key << 24 & 0xFF) + "." + (key << 16 & 0xFF) + "." + (key << 8 & 0xFF) + "." + (key & 0xFF));
    }
    if (na.getSrCapabilities() != null) {
        final SidLabelIndex labelIndex = na.getSrCapabilities().getSidLabelIndex();
        if (labelIndex instanceof LocalLabelCase) {
            builder.setSrgb(new SrgbBuilder().setLowerBound(((LocalLabelCase) labelIndex).getLocalLabel().getValue()).setRangeSize(na.getSrCapabilities().getRangeSize().getValue()).build());
        } else if (labelIndex instanceof SidCase) {
            builder.setSrgb(new SrgbBuilder().setLowerBound(((SidCase) labelIndex).getSid()).setRangeSize(na.getSrCapabilities().getRangeSize().getValue()).build());
        }
    }
    if (na.getNodeFlags() != null) {
        if (na.getNodeFlags().getAbr()) {
            builder.setVertexType(VertexType.Abr);
        }
        if (na.getNodeFlags().getExternal()) {
            builder.setVertexType(VertexType.AsbrOut);
        }
    } else {
        builder.setVertexType(VertexType.Standard);
    }
    return builder.build();
}
Also used : SrgbBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.vertex.SrgbBuilder) VertexBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexBuilder) LocalLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase) SidLabelIndex(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.SidLabelIndex) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SidCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCase)

Aggregations

IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 SidLabelIndex (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.SidLabelIndex)1 LocalLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase)1 SidCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCase)1 VertexBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexBuilder)1 SrgbBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.vertex.SrgbBuilder)1