Search in sources :

Example 1 with LinkDiscoveredBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder in project openflowplugin by opendaylight.

the class LLDPDiscoveryListener method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived lldp) {
    NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload(), true);
    if (src != null) {
        final NodeKey nodeKey = lldp.getIngress().getValue().firstKeyOf(Node.class);
        LOG.debug("LLDP packet received for destination node {}", nodeKey);
        if (nodeKey != null) {
            LinkDiscoveredBuilder ldb = new LinkDiscoveredBuilder();
            ldb.setDestination(lldp.getIngress());
            ldb.setSource(new NodeConnectorRef(src));
            LinkDiscovered ld = ldb.build();
            lldpLinkAger.put(ld);
            if (LLDPDiscoveryUtils.isEntityOwned(this.eos, nodeKey.getId().getValue())) {
                LOG.debug("Publish add event for link {}", ld);
                notificationService.publish(ld);
            } else {
                LOG.trace("Skip publishing the add event for link because controller is non-owner of the " + "node {}. Link : {}", nodeKey.getId().getValue(), ld);
            }
        } else {
            LOG.debug("LLDP packet ignored. Unable to extract node-key from packet-in ingress.");
        }
    }
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) LinkDiscoveredBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder) LinkDiscovered(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered)

Example 2 with LinkDiscoveredBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder in project openflowplugin by opendaylight.

the class FlowCapableTopologyExporterTest method testOnLinkDiscovered.

@Test
public void testOnLinkDiscovered() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey sourceNodeKey = newInvNodeKey("sourceNode");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey sourceNodeConnKey = newInvNodeConnKey("sourceTP");
    InstanceIdentifier<?> sourceConnID = newNodeConnID(sourceNodeKey, sourceNodeConnKey);
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey destNodeKey = newInvNodeKey("destNode");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey destNodeConnKey = newInvNodeConnKey("destTP");
    InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
    ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
    CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
    doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
    exporter.onLinkDiscovered(new LinkDiscoveredBuilder().setSource(new NodeConnectorRef(sourceConnID)).setDestination(new NodeConnectorRef(destConnID)).build());
    waitForSubmit(submitLatch);
    ArgumentCaptor<Link> mergedNode = ArgumentCaptor.forClass(Link.class);
    verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))), mergedNode.capture(), eq(true));
    assertEquals("Source node ID", "sourceNode", mergedNode.getValue().getSource().getSourceNode().getValue());
    assertEquals("Dest TP ID", "sourceTP", mergedNode.getValue().getSource().getSourceTp().getValue());
    assertEquals("Dest node ID", "destNode", mergedNode.getValue().getDestination().getDestNode().getValue());
    assertEquals("Dest TP ID", "destTP", mergedNode.getValue().getDestination().getDestTp().getValue());
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) LinkKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey) CountDownLatch(java.util.concurrent.CountDownLatch) LinkDiscoveredBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder) Mockito.doReturn(org.mockito.Mockito.doReturn) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TestUtils.newLink(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) LinkId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId) Test(org.junit.Test)

Aggregations

LinkDiscoveredBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder)2 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1 Mockito.doReturn (org.mockito.Mockito.doReturn)1 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)1 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)1 LinkDiscovered (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered)1 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)1 LinkId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId)1 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)1 LinkKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey)1