Search in sources :

Example 1 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class PCEPTriggeredReSynchronizationProcedureTest method testTriggeredResynchronizationLsp.

@Test
public void testTriggeredResynchronizationLsp() throws Exception {
    // session up - sync skipped (LSP-DBs match)
    this.session = getPCEPSession(getOpen(), getOpen());
    this.listener.onSessionUp(this.session);
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = getPcrt();
    this.listener.onMessage(this.session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        final List<ReportedLsp> reportedLspPcc = pcc.getReportedLsp();
        assertFalse(reportedLspPcc.isEmpty());
        return pcc;
    });
    // Trigger Full Resync
    this.listener.triggerSync(new TriggerSyncInputBuilder().setNode(this.nodeId).setName("test").build());
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(PccSyncState.PcepTriggeredResync, pcc.getStateSync());
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    this.listener.onMessage(this.session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    // sync rpt + LSP-DB
    final Pcrpt syncMsg = getSyncMsg();
    this.listener.onMessage(this.session, syncMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        // check reported LSP
        assertEquals(1, pcc.getReportedLsp().size());
        return pcc;
    });
    // Trigger Full Resync
    this.listener.triggerSync(new TriggerSyncInputBuilder().setNode(this.nodeId).setName("test").build());
    this.listener.onMessage(this.session, syncMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        // check reported LSP
        assertEquals(0, pcc.getReportedLsp().size());
        return pcc;
    });
}
Also used : ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) TriggerSyncInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TriggerSyncInputBuilder) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) Test(org.junit.Test)

Example 2 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class NodeChangedListenerTest method createNode.

private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final long lspId, final String dstIpv4Address) throws TransactionCommitFailedException {
    final NodeBuilder nodeBuilder = new NodeBuilder();
    nodeBuilder.setKey(new NodeKey(nodeId));
    nodeBuilder.setNodeId(nodeId);
    final PathBuilder pathBuilder = new PathBuilder();
    pathBuilder.setKey(new PathKey(new LspId(lspId)));
    pathBuilder.setBandwidth(new BandwidthBuilder().setBandwidth(new Bandwidth(new byte[] { 0x00, 0x00, (byte) 0xff, (byte) 0xff })).build());
    pathBuilder.addAugmentation(Path1.class, new Path1Builder().setLsp(new LspBuilder().setTlvs(new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4Address(ipv4Address)).setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(ipv4Address)).setIpv4TunnelEndpointAddress(new Ipv4Address(dstIpv4Address)).build()).build()).build()).build()).setAdministrative(true).setDelegate(true).build()).build());
    final ReportedLsp reportedLps = new ReportedLspBuilder().setKey(new ReportedLspKey(lspName)).setPath(Collections.singletonList(pathBuilder.build())).build();
    final Node1Builder node1Builder = new Node1Builder();
    node1Builder.setPathComputationClient(new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).setReportedLsp(Lists.newArrayList(reportedLps)).setIpAddress(new IpAddress(new Ipv4Address(ipv4Address))).build());
    nodeBuilder.addAugmentation(Node1.class, node1Builder.build());
    final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
    wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class, new NodeKey(nodeId)).build(), nodeBuilder.build());
    wTx.submit().checkedGet();
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) LspIdentifiersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder) Node1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1Builder) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspBuilder) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClientBuilder) Ipv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4Builder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) BandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.BandwidthBuilder) PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathKey) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder) Ipv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv4CaseBuilder) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) Path1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1Builder) ReportedLspKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspKey) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv4ExtendedTunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv4ExtendedTunnelId) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 3 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method updateLsp.

/**
 * Update an LSP in the data store.
 *
 * @param ctx       Message context
 * @param id        Revision-specific LSP identifier
 * @param lspName   LSP name
 * @param rlb       Reported LSP builder
 * @param solicited True if the update was solicited
 * @param remove    True if this is an LSP path removal
 */
protected final synchronized void updateLsp(final MessageContext ctx, final L id, final String lspName, final ReportedLspBuilder rlb, final boolean solicited, final boolean remove) {
    final String name;
    if (lspName == null) {
        name = this.lsps.get(id);
        if (name == null) {
            LOG.error("PLSPID {} seen for the first time, not reporting the LSP", id);
            return;
        }
    } else {
        name = lspName;
    }
    LOG.debug("Saved LSP {} with name {}", id, name);
    this.lsps.put(id, name);
    final ReportedLsp previous = this.lspData.get(name);
    // if no previous report about the lsp exist, just proceed
    if (previous != null) {
        final List<Path> updatedPaths = makeBeforeBreak(rlb, previous, name, remove);
        // if all paths or the last path were deleted, delete whole tunnel
        if (updatedPaths.isEmpty()) {
            LOG.debug("All paths were removed, removing LSP with {}.", id);
            removeLsp(ctx, id);
            return;
        }
        rlb.setPath(updatedPaths);
    }
    rlb.setKey(new ReportedLspKey(name));
    rlb.setName(name);
    // If this is an unsolicited update. We need to make sure we retain the metadata already present
    if (solicited) {
        this.nodeState.setLspMetadata(name, rlb.getMetadata());
    } else {
        rlb.setMetadata(this.nodeState.getLspMetadata(name));
    }
    final ReportedLsp rl = rlb.build();
    ctx.trans.put(LogicalDatastoreType.OPERATIONAL, this.pccIdentifier.child(ReportedLsp.class, rlb.getKey()), rl);
    LOG.debug("LSP {} updated to MD-SAL", name);
    this.lspData.put(name, rl);
}
Also used : Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) ReportedLspKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspKey)

Example 4 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method makeBeforeBreak.

private List<Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous, final String name, final boolean remove) {
    // just one path should be reported
    Preconditions.checkState(rlb.getPath().size() == 1);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId reportedLspId = rlb.getPath().get(0).getLspId();
    final List<Path> updatedPaths;
    // remove existing tunnel's paths now, as explicit path remove will not come
    if (!remove && reportedLspId.getValue() == 0) {
        updatedPaths = new ArrayList<>();
        LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
    } else {
        // check previous report for existing paths
        updatedPaths = new ArrayList<>(previous.getPath());
        LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
        for (final Path path : previous.getPath()) {
            // we found reported path in previous reports
            if (path.getLspId().getValue() == 0 || path.getLspId().equals(reportedLspId)) {
                LOG.debug("Match on lsp-id {}", path.getLspId().getValue());
                // path that was reported previously and does have the same lsp-id, path will be updated
                final boolean r = updatedPaths.remove(path);
                LOG.trace("Request removed? {}", r);
            }
        }
    }
    // if the path does not exist in previous report, add it to path list, it's a new ERO
    // only one path will be added
    // lspId is 0 means confirmation message that shouldn't be added (because we have no means of deleting it later)
    LOG.trace("Adding new path {} to {}", rlb.getPath(), updatedPaths);
    updatedPaths.addAll(rlb.getPath());
    if (remove) {
        if (reportedLspId.getValue() == 0) {
            // if lsp-id also 0, remove all paths
            LOG.debug("Removing all paths.");
            updatedPaths.clear();
        } else {
            // path is marked to be removed
            LOG.debug("Removing path {} from {}", rlb.getPath(), updatedPaths);
            final boolean r = updatedPaths.removeAll(rlb.getPath());
            LOG.trace("Request removed? {}", r);
        }
    }
    LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
    return updatedPaths;
}
Also used : Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path)

Example 5 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class NodeChangedListener method remove.

private void remove(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier, final ReportedLsp value) throws ReadFailedException {
    final InstanceIdentifier<Link> li = linkForLsp(linkIdForLsp(identifier, value));
    final Optional<Link> ol = trans.read(LogicalDatastoreType.OPERATIONAL, li).checkedGet();
    if (!ol.isPresent()) {
        return;
    }
    final Link l = ol.get();
    LOG.debug("Removing link {} (was {})", li, l);
    trans.delete(LogicalDatastoreType.OPERATIONAL, li);
    LOG.debug("Searching for orphan links/nodes");
    final Optional<Topology> ot = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).checkedGet();
    Preconditions.checkState(ot.isPresent());
    final Topology topology = ot.get();
    final NodeId srcNode = l.getSource().getSourceNode();
    final NodeId dstNode = l.getDestination().getDestNode();
    final TpId srcTp = l.getSource().getSourceTp();
    final TpId dstTp = l.getDestination().getDestTp();
    boolean orphSrcNode = true;
    boolean orphDstNode = true;
    boolean orphDstTp = true;
    boolean orphSrcTp = true;
    for (final Link lw : topology.getLink()) {
        LOG.trace("Checking link {}", lw);
        final NodeId sn = lw.getSource().getSourceNode();
        final NodeId dn = lw.getDestination().getDestNode();
        final TpId st = lw.getSource().getSourceTp();
        final TpId dt = lw.getDestination().getDestTp();
        // Source node checks
        if (srcNode.equals(sn)) {
            if (orphSrcNode) {
                LOG.debug("Node {} held by source of link {}", srcNode, lw);
                orphSrcNode = false;
            }
            if (orphSrcTp && srcTp.equals(st)) {
                LOG.debug("TP {} held by source of link {}", srcTp, lw);
                orphSrcTp = false;
            }
        }
        if (srcNode.equals(dn)) {
            if (orphSrcNode) {
                LOG.debug("Node {} held by destination of link {}", srcNode, lw);
                orphSrcNode = false;
            }
            if (orphSrcTp && srcTp.equals(dt)) {
                LOG.debug("TP {} held by destination of link {}", srcTp, lw);
                orphSrcTp = false;
            }
        }
        // Destination node checks
        if (dstNode.equals(sn)) {
            if (orphDstNode) {
                LOG.debug("Node {} held by source of link {}", dstNode, lw);
                orphDstNode = false;
            }
            if (orphDstTp && dstTp.equals(st)) {
                LOG.debug("TP {} held by source of link {}", dstTp, lw);
                orphDstTp = false;
            }
        }
        if (dstNode.equals(dn)) {
            if (orphDstNode) {
                LOG.debug("Node {} held by destination of link {}", dstNode, lw);
                orphDstNode = false;
            }
            if (orphDstTp && dstTp.equals(dt)) {
                LOG.debug("TP {} held by destination of link {}", dstTp, lw);
                orphDstTp = false;
            }
        }
    }
    if (orphSrcNode && !orphSrcTp) {
        LOG.warn("Orphan source node {} but not TP {}, retaining the node", srcNode, srcTp);
        orphSrcNode = false;
    }
    if (orphDstNode && !orphDstTp) {
        LOG.warn("Orphan destination node {} but not TP {}, retaining the node", dstNode, dstTp);
        orphDstNode = false;
    }
    if (orphSrcNode) {
        LOG.debug("Removing orphan node {}", srcNode);
        trans.delete(LogicalDatastoreType.OPERATIONAL, nodeIdentifier(srcNode));
    } else if (orphSrcTp) {
        LOG.debug("Removing orphan TP {} on node {}", srcTp, srcNode);
        trans.delete(LogicalDatastoreType.OPERATIONAL, tpIdentifier(srcNode, srcTp));
    }
    if (orphDstNode) {
        LOG.debug("Removing orphan node {}", dstNode);
        trans.delete(LogicalDatastoreType.OPERATIONAL, nodeIdentifier(dstNode));
    } else if (orphDstTp) {
        LOG.debug("Removing orphan TP {} on node {}", dstTp, dstNode);
        trans.delete(LogicalDatastoreType.OPERATIONAL, tpIdentifier(dstNode, dstTp));
    }
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)

Aggregations

ReportedLsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp)10 Test (org.junit.Test)3 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)3 Path1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1)3 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)3 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)3 Path (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path)3 Optional (com.google.common.base.Optional)2 Preconditions (com.google.common.base.Preconditions)2 Collections (java.util.Collections)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 PcinitiateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder)2 PcinitiateMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder)2 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder)2 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)2 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp)2 ReportedLspKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspKey)2 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 SupportingNode (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode)2 ArrayList (java.util.ArrayList)1