Search in sources :

Example 1 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project netvirt by opendaylight.

the class L2GwValidateCli method compareNodes.

private boolean compareNodes(Node node1, Node node2, boolean parentChildComparison, LogicalDatastoreType datastoreType) {
    if (node1 == null || node2 == null) {
        return false;
    }
    InstanceIdentifier<Node> nodeIid1 = HwvtepSouthboundUtils.createInstanceIdentifier(node1.getNodeId());
    InstanceIdentifier<Node> nodeIid2 = HwvtepSouthboundUtils.createInstanceIdentifier(node2.getNodeId());
    NodeId nodeId1 = nodeIid1.firstKeyOf(Node.class).getNodeId();
    NodeId nodeId2 = nodeIid2.firstKeyOf(Node.class).getNodeId();
    PhysicalSwitchAugmentation psAug1 = node1.getAugmentation(PhysicalSwitchAugmentation.class);
    PhysicalSwitchAugmentation psAug2 = node2.getAugmentation(PhysicalSwitchAugmentation.class);
    HwvtepGlobalAugmentation aug1 = node1.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation aug2 = node2.getAugmentation(HwvtepGlobalAugmentation.class);
    boolean globalNodes = psAug1 == null && psAug2 == null ? true : false;
    MergeCommand[] commands = globalNodes ? globalCommands : physicalSwitchCommands;
    for (MergeCommand cmd : commands) {
        List<DataObject> data1 = null;
        List<DataObject> data2 = null;
        if (globalNodes) {
            data1 = cmd.getData(aug1);
            data2 = cmd.getData(aug2);
        } else {
            data1 = cmd.getData(node1);
            data2 = cmd.getData(node2);
        }
        data1 = data1 == null ? Collections.EMPTY_LIST : data1;
        data2 = data2 == null ? Collections.EMPTY_LIST : data2;
        if (parentChildComparison) {
            data2 = cmd.transform(nodeIid1, data2);
        }
        Function<DataObject, DataObject> withoutUuidTransformer = cmd::withoutUuid;
        data1 = Lists.transform(data1, withoutUuidTransformer);
        data2 = Lists.transform(data2, withoutUuidTransformer);
        Map<Identifier<?>, DataObject> map1 = new HashMap<>();
        Map<Identifier<?>, DataObject> map2 = new HashMap<>();
        for (DataObject dataObject : data1) {
            map1.put(cmd.getKey(dataObject), dataObject);
        }
        for (DataObject dataObject : data2) {
            map2.put(cmd.getKey(dataObject), dataObject);
        }
        Set<DataObject> diff = Sets.newHashSet();
        for (Entry<Identifier<?>, DataObject> entry : map1.entrySet()) {
            DataObject obj1 = entry.getValue();
            DataObject obj2 = map2.get(entry.getKey());
            if (obj2 == null || !cmd.areEqual(obj1, obj2)) {
                diff.add(obj1);
            }
        }
        if (!diff.isEmpty()) {
            if (parentChildComparison) {
                pw.println("Missing " + cmd.getDescription() + " child entries in " + datastoreType + " parent node " + nodeId1 + " contain " + " more entries than child " + nodeId2 + " " + diff.size());
            } else {
                pw.println("Missing " + cmd.getDescription() + " op entries config " + nodeId1 + " contain " + " more entries than operational node " + diff.size());
            }
            if (diff.size() < 10) {
                for (Object obj : diff) {
                    pw.println(cmd.getKey((DataObject) obj));
                }
            }
        }
        diff = Sets.newHashSet();
        for (Entry<Identifier<?>, DataObject> entry : map2.entrySet()) {
            DataObject obj1 = entry.getValue();
            DataObject obj2 = map1.get(entry.getKey());
            if (globalNodes || parentChildComparison) {
                if (obj2 == null || !cmd.areEqual(obj1, obj2)) {
                    diff.add(obj1);
                }
            }
        }
        if (!diff.isEmpty()) {
            if (parentChildComparison) {
                pw.println("Extra " + cmd.getDescription() + " child entries in " + datastoreType + " node " + nodeId2 + " contain " + " more entries than parent node " + nodeId1 + " " + diff.size());
            } else {
                pw.println("Extra " + cmd.getDescription() + " operational node " + nodeId2 + " contain " + " more entries than config node " + diff.size());
            }
            if (diff.size() < 10) {
                for (Object obj : diff) {
                    pw.println(cmd.getKey((DataObject) obj));
                }
            }
        }
    }
    return true;
}
Also used : HashMap(java.util.HashMap) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) MergeCommand(org.opendaylight.netvirt.elan.l2gw.ha.commands.MergeCommand) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) DataObject(org.opendaylight.yangtools.yang.binding.DataObject)

Example 2 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 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 Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method onSessionUp.

@Override
public final synchronized void onSessionUp(final PCEPSession psession) {
    /*
         * The session went up. Look up the router in Inventory model,
         * create it if it is not there (marking that fact for later
         * deletion), and mark it as synchronizing. Also create it in
         * the topology model, with empty LSP list.
         */
    final InetAddress peerAddress = psession.getRemoteAddress();
    this.syncOptimization = new SyncOptimization(psession);
    final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress, this, isLspDbRetreived());
    // takeNodeState(..) may fail when the server session manager is being restarted due to configuration change
    if (state == null) {
        LOG.error("Unable to fetch topology node state for PCEP session. Closing session {}", psession);
        psession.close(TerminationReason.UNKNOWN);
        this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
        return;
    }
    if (this.session != null || this.nodeState != null) {
        LOG.error("PCEP session is already up with {}. Closing session {}", psession.getRemoteAddress(), psession);
        psession.close(TerminationReason.UNKNOWN);
        this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
        return;
    }
    this.session = psession;
    this.nodeState = state;
    this.serverSessionManager.bind(this.nodeState.getNodeId(), this.listenerState);
    LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
    // Our augmentation in the topology node
    final PathComputationClientBuilder pccBuilder = new PathComputationClientBuilder();
    onSessionUp(psession, pccBuilder);
    this.synced.set(isSynchronized());
    pccBuilder.setIpAddress(IpAddressBuilder.getDefaultInstance(peerAddress.getHostAddress()));
    final InstanceIdentifier<Node1> topologyAugment = state.getNodeId().augmentation(Node1.class);
    this.pccIdentifier = topologyAugment.child(PathComputationClient.class);
    final Node initialNodeState = state.getInitialNodeState();
    final boolean isNodePresent = isLspDbRetreived() && initialNodeState != null;
    if (isNodePresent) {
        loadLspData(initialNodeState, this.lspData, this.lsps, isIncrementalSynchro());
        pccBuilder.setReportedLsp(initialNodeState.getAugmentation(Node1.class).getPathComputationClient().getReportedLsp());
    }
    state.storeNode(topologyAugment, new Node1Builder().setPathComputationClient(pccBuilder.build()).build(), this.session);
    this.listenerState.init(psession);
    LOG.info("Session with {} attached to topology node {}", psession.getRemoteAddress(), state.getNodeId());
}
Also used : PCEPCloseTermination(org.opendaylight.protocol.pcep.PCEPCloseTermination) Node1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1) Node1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1Builder) PathComputationClient(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClient) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClientBuilder) InetAddress(java.net.InetAddress)

Example 4 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project bgpcep by opendaylight.

the class Stateful07TopologySessionListener method loadLspData.

/**
 * Recover lspData and mark any LSPs in the LSP database that were previously reported by the PCC as stale.
 */
@Override
protected synchronized void loadLspData(final Node node, final Map<String, ReportedLsp> lspData, final Map<PlspId, String> lsps, final boolean incrementalSynchro) {
    // load node's lsps from DS
    final PathComputationClient pcc = node.getAugmentation(Node1.class).getPathComputationClient();
    final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
    for (final ReportedLsp reportedLsp : reportedLsps) {
        final String lspName = reportedLsp.getName();
        lspData.put(lspName, reportedLsp);
        if (!reportedLsp.getPath().isEmpty()) {
            final Path1 path1 = reportedLsp.getPath().get(0).getAugmentation(Path1.class);
            if (path1 != null) {
                final PlspId plspId = path1.getLsp().getPlspId();
                if (!incrementalSynchro) {
                    this.staleLsps.add(plspId);
                }
                lsps.put(plspId, lspName);
            }
        }
    }
}
Also used : Node1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) PathComputationClient(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClient) Path1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Example 5 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project bgpcep by opendaylight.

the class AbstractReachabilityTopologyBuilder method ensureNodePresent.

private InstanceIdentifier<IgpNodeAttributes> ensureNodePresent(final ReadWriteTransaction trans, final NodeId ni) {
    final NodeUsage present = this.nodes.get(ni);
    if (present != null) {
        return present.attrId;
    }
    final KeyedInstanceIdentifier<Node, NodeKey> nii = nodeInstanceId(ni);
    final InstanceIdentifier<IgpNodeAttributes> ret = nii.builder().augmentation(Node1.class).child(IgpNodeAttributes.class).build();
    trans.merge(LogicalDatastoreType.OPERATIONAL, nii, new NodeBuilder().setKey(nii.getKey()).setNodeId(ni).addAugmentation(Node1.class, new Node1Builder().setIgpNodeAttributes(new IgpNodeAttributesBuilder().setPrefix(Collections.emptyList()).build()).build()).build());
    this.nodes.put(ni, new NodeUsage(ret));
    return ret;
}
Also used : Node1Builder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Node1Builder) IgpNodeAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.IgpNodeAttributesBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) IgpNodeAttributes(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.IgpNodeAttributes) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)18 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)14 Test (org.junit.Test)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)11 CountDownLatch (java.util.concurrent.CountDownLatch)8 Mockito.doReturn (org.mockito.Mockito.doReturn)8 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)8 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 TestUtils.newInvNodeKey (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)8 Optional (com.google.common.base.Optional)6 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)6 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)5 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)5 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)5 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)5 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)4 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)4 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)4