Search in sources :

Example 11 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project bgpcep by opendaylight.

the class NodeChangedListener method getIpTerminationPoint.

private InstanceIdentifier<TerminationPoint> getIpTerminationPoint(final ReadWriteTransaction trans, final IpAddress addr, final InstanceIdentifier<Node> sni, final Boolean inControl) throws ReadFailedException {
    final Topology topo = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).checkedGet().get();
    if (topo.getNode() != null) {
        for (final Node n : topo.getNode()) {
            if (n.getTerminationPoint() != null) {
                for (final TerminationPoint tp : n.getTerminationPoint()) {
                    final TerminationPoint1 tpa = tp.getAugmentation(TerminationPoint1.class);
                    if (tpa != null) {
                        final TerminationPointType tpt = tpa.getIgpTerminationPointAttributes().getTerminationPointType();
                        if (tpt instanceof Ip) {
                            for (final IpAddress address : ((Ip) tpt).getIpAddress()) {
                                if (addr.equals(address)) {
                                    handleSni(sni, n, inControl, trans);
                                    return this.target.builder().child(Node.class, n.getKey()).child(TerminationPoint.class, tp.getKey()).build();
                                }
                            }
                        } else {
                            LOG.debug("Ignoring termination point type {}", tpt);
                        }
                    }
                }
            }
        }
    }
    LOG.debug("Termination point for {} not found, creating a new one", addr);
    return createTP(addr, sni, inControl, trans);
}
Also used : TerminationPoint1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Ip(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.Ip) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) TerminationPointType(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.TerminationPointType)

Example 12 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project bgpcep by opendaylight.

the class NodeChangedListener method create.

private void create(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier, final ReportedLsp value) throws ReadFailedException {
    final InstanceIdentifier<Node> ni = identifier.firstIdentifierOf(Node.class);
    final Path1 rl = value.getPath().get(0).getAugmentation(Path1.class);
    final AddressFamily af = rl.getLsp().getTlvs().getLspIdentifiers().getAddressFamily();
    /*
         * We are trying to ensure we have source and destination nodes.
         */
    final IpAddress srcIp;
    final IpAddress dstIp;
    if (af instanceof Ipv4Case) {
        final Ipv4 ipv4 = ((Ipv4Case) af).getIpv4();
        srcIp = new IpAddress(ipv4.getIpv4TunnelSenderAddress());
        dstIp = new IpAddress(ipv4.getIpv4TunnelEndpointAddress());
    } else if (af instanceof Ipv6Case) {
        final Ipv6 ipv6 = ((Ipv6Case) af).getIpv6();
        srcIp = new IpAddress(ipv6.getIpv6TunnelSenderAddress());
        dstIp = new IpAddress(ipv6.getIpv6TunnelSenderAddress());
    } else {
        throw new IllegalArgumentException("Unsupported address family: " + af.getImplementedInterface());
    }
    final Path path0 = value.getPath().get(0);
    final Link1Builder lab = new Link1Builder();
    if (path0.getBandwidth() != null) {
        lab.setBandwidth(path0.getBandwidth().getBandwidth());
    }
    if (path0.getClassType() != null) {
        lab.setClassType(path0.getClassType().getClassType());
    }
    lab.setSymbolicPathName(value.getName());
    final InstanceIdentifier<TerminationPoint> dst = getIpTerminationPoint(trans, dstIp, null, Boolean.FALSE);
    final InstanceIdentifier<TerminationPoint> src = getIpTerminationPoint(trans, srcIp, ni, rl.getLsp().isDelegate());
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1Builder slab = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1Builder();
    slab.setOperationalStatus(rl.getLsp().getOperational());
    slab.setAdministrativeStatus(rl.getLsp().isAdministrative() ? AdministrativeStatus.Active : AdministrativeStatus.Inactive);
    final LinkId id = linkIdForLsp(identifier, value);
    final LinkBuilder lb = new LinkBuilder();
    lb.setLinkId(id);
    lb.setSource(new SourceBuilder().setSourceNode(src.firstKeyOf(Node.class).getNodeId()).setSourceTp(src.firstKeyOf(TerminationPoint.class).getTpId()).build());
    lb.setDestination(new DestinationBuilder().setDestNode(dst.firstKeyOf(Node.class).getNodeId()).setDestTp(dst.firstKeyOf(TerminationPoint.class).getTpId()).build());
    lb.addAugmentation(Link1.class, lab.build());
    lb.addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1.class, slab.build());
    trans.put(LogicalDatastoreType.OPERATIONAL, linkForLsp(id), lb.build());
}
Also used : Preconditions(com.google.common.base.Preconditions) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Link1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.Link1Builder) Path1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1) AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.AddressFamily) Ipv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv4Case) Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path) Ipv6(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6) SourceBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.SourceBuilder) Ipv4(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4) LinkBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder) Ipv6Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv6Case) DestinationBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.DestinationBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) LinkId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId)

Example 13 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project bgpcep by opendaylight.

the class LinkstateTopologyBuilder method createLink.

private void createLink(final WriteTransaction trans, final UriBuilder base, final LinkstateRoute value, final LinkCase linkCase, final Attributes attributes) {
    // defensive lookup
    final LinkAttributes la;
    final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
    if (attr != null) {
        final LinkStateAttribute attrType = attr.getLinkStateAttribute();
        if (attrType != null) {
            la = ((LinkAttributesCase) attrType).getLinkAttributes();
        } else {
            LOG.debug("Missing attribute type in link {} route {}, skipping it", linkCase, value);
            la = null;
        }
    } else {
        LOG.debug("Missing attributes in link {} route {}, skipping it", linkCase, value);
        la = null;
    }
    final IgpLinkAttributesBuilder ilab = new IgpLinkAttributesBuilder();
    if (la != null) {
        if (la.getMetric() != null) {
            ilab.setMetric(la.getMetric().getValue());
        }
        ilab.setName(la.getLinkName());
    }
    ProtocolUtil.augmentProtocolId(value, ilab, la, linkCase.getLinkDescriptors());
    final LinkBuilder lb = new LinkBuilder();
    lb.setLinkId(buildLinkId(base, linkCase));
    lb.addAugmentation(Link1.class, new Link1Builder().setIgpLinkAttributes(ilab.build()).build());
    final NodeId srcNode = buildNodeId(base, linkCase.getLocalNodeDescriptors());
    LOG.trace("Link {} implies source node {}", linkCase, srcNode);
    final NodeId dstNode = buildNodeId(base, linkCase.getRemoteNodeDescriptors());
    LOG.trace("Link {} implies destination node {}", linkCase, dstNode);
    final TerminationPoint srcTp = buildLocalTp(base, linkCase.getLinkDescriptors());
    LOG.trace("Link {} implies source TP {}", linkCase, srcTp);
    final TerminationPoint dstTp = buildRemoteTp(base, linkCase.getLinkDescriptors());
    LOG.trace("Link {} implies destination TP {}", linkCase, dstTp);
    lb.setSource(new SourceBuilder().setSourceNode(srcNode).setSourceTp(srcTp.getTpId()).build());
    lb.setDestination(new DestinationBuilder().setDestNode(dstNode).setDestTp(dstTp.getTpId()).build());
    LOG.trace("Created TP {} as link source", srcTp);
    NodeHolder snh = this.nodes.get(srcNode);
    if (snh == null) {
        snh = getNode(srcNode);
        snh.addTp(srcTp, lb.getLinkId(), false);
        putNode(trans, snh);
    } else {
        snh.addTp(srcTp, lb.getLinkId(), false);
        final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(snh.getNodeId()));
        trans.put(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class, srcTp.getKey()), srcTp);
    }
    LOG.debug("Created TP {} as link destination", dstTp);
    NodeHolder dnh = this.nodes.get(dstNode);
    if (dnh == null) {
        dnh = getNode(dstNode);
        dnh.addTp(dstTp, lb.getLinkId(), true);
        putNode(trans, dnh);
    } else {
        dnh.addTp(dstTp, lb.getLinkId(), true);
        final InstanceIdentifier<Node> nid = getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class, new NodeKey(dnh.getNodeId()));
        trans.put(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class, dstTp.getKey()), dstTp);
    }
    final InstanceIdentifier<Link> lid = buildLinkIdentifier(lb.getLinkId());
    final Link link = lb.build();
    trans.put(LogicalDatastoreType.OPERATIONAL, lid, link);
    LOG.debug("Created link {} at {} for {}", link, lid, linkCase);
}
Also used : IgpLinkAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.link.attributes.IgpLinkAttributesBuilder) SourceBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.SourceBuilder) LinkBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder) 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) LinkStateAttribute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.LinkStateAttribute) Link1Builder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Link1Builder) LinkAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) DestinationBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.DestinationBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)

Example 14 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project bgpcep by opendaylight.

the class LinkstateTopologyBuilder method buildTp.

private static TerminationPoint buildTp(final TpId id, final TerminationPointType type) {
    final TerminationPointBuilder stpb = new TerminationPointBuilder();
    stpb.setKey(new TerminationPointKey(id));
    stpb.setTpId(id);
    if (type != null) {
        stpb.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder().setTerminationPointType(type).build()).build());
    }
    return stpb.build();
}
Also used : TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) IgpTerminationPointAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.IgpTerminationPointAttributesBuilder) TerminationPoint1Builder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1Builder)

Example 15 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project openflowplugin by opendaylight.

the class TerminationPointChangeListenerImpl method processAddedTerminationPoints.

private void processAddedTerminationPoints(final DataTreeModification<FlowCapableNodeConnector> modification) {
    final InstanceIdentifier<FlowCapableNodeConnector> iiToNodeInInventory = modification.getRootPath().getRootIdentifier();
    TpId terminationPointIdInTopology = provideTopologyTerminationPointId(iiToNodeInInventory);
    if (terminationPointIdInTopology != null) {
        InstanceIdentifier<TerminationPoint> iiToTopologyTerminationPoint = provideIIToTopologyTerminationPoint(terminationPointIdInTopology, iiToNodeInInventory);
        TerminationPoint point = prepareTopologyTerminationPoint(terminationPointIdInTopology, iiToNodeInInventory);
        sendToTransactionChain(point, iiToTopologyTerminationPoint);
        removeLinks(modification.getRootNode().getDataAfter(), point);
    } else {
        LOG.debug("Inventory node connector key is null. Data can't be written to topology termination point");
    }
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Aggregations

TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)41 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)25 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)20 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)18 TerminationPointBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder)16 ArrayList (java.util.ArrayList)12 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)10 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)8 HwvtepPhysicalPortAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation)7 OvsdbTerminationPointAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder)7 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 Test (org.junit.Test)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 VlanBindings (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)6 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)6 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)5 OvsdbTerminationPointAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation)5 BigInteger (java.math.BigInteger)4 List (java.util.List)3