Search in sources :

Example 81 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class LLDPSpeaker method nodeConnectorAdded.

@Override
public void nodeConnectorAdded(final InstanceIdentifier<NodeConnector> nodeConnectorInstanceId, final FlowCapableNodeConnector flowConnector) {
    NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(nodeConnectorInstanceId).getId();
    // port, so first we check if we actually need to perform any action
    if (nodeConnectorMap.containsKey(nodeConnectorInstanceId)) {
        LOG.debug("Port {} already in LLDPSpeaker.nodeConnectorMap, no need for additional processing", nodeConnectorId.getValue());
        return;
    }
    // Prepare to build LLDP payload
    InstanceIdentifier<Node> nodeInstanceId = nodeConnectorInstanceId.firstIdentifierOf(Node.class);
    NodeId nodeId = InstanceIdentifier.keyOf(nodeInstanceId).getId();
    MacAddress srcMacAddress = flowConnector.getHardwareAddress();
    Long outputPortNo = flowConnector.getPortNumber().getUint32();
    // No need to send LLDP frames on local ports
    if (outputPortNo == null) {
        LOG.debug("Port {} is local, not sending LLDP frames through it", nodeConnectorId.getValue());
        return;
    }
    // Generate packet with destination switch and port
    TransmitPacketInput packet;
    try {
        packet = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(nodeConnectorInstanceId)).setNode(new NodeRef(nodeInstanceId)).setPayload(LLDPUtil.buildLldpFrame(nodeId, nodeConnectorId, srcMacAddress, outputPortNo, addressDestionation)).build();
    } catch (NoSuchAlgorithmException | PacketException e) {
        LOG.error("Error building LLDP frame", e);
        return;
    }
    // Save packet to node connector id -> packet map to transmit it periodically on the configured interval.
    nodeConnectorMap.put(nodeConnectorInstanceId, packet);
    LOG.debug("Port {} added to LLDPSpeaker.nodeConnectorMap", nodeConnectorId.getValue());
    // Transmit packet for first time immediately
    final Future<RpcResult<Void>> resultFuture = packetProcessingService.transmitPacket(packet);
    JdkFutures.addErrorLogging(resultFuture, LOG, "transmitPacket");
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)

Example 82 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class NodeNotificationSupplierImpl method createNotification.

@Override
public NodeUpdated createNotification(final FlowCapableNode flowCapableNode, final InstanceIdentifier<FlowCapableNode> ii) {
    Preconditions.checkArgument(flowCapableNode != null);
    Preconditions.checkArgument(ii != null);
    final FlowCapableNodeUpdatedBuilder flowNodeNotifBuilder = new FlowCapableNodeUpdatedBuilder(flowCapableNode);
    final NodeUpdatedBuilder notifBuilder = new NodeUpdatedBuilder();
    notifBuilder.setId(ii.firstKeyOf(Node.class, NodeKey.class).getId());
    notifBuilder.setNodeRef(new NodeRef(getNodeII(ii)));
    notifBuilder.addAugmentation(FlowCapableNodeUpdated.class, flowNodeNotifBuilder.build());
    return notifBuilder.build();
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder) FlowCapableNodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder) FlowCapableNodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder)

Example 83 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class DefaultConfigPusher method onDataTreeChanged.

@Override
public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<FlowCapableNode>> modifications) {
    for (DataTreeModification<FlowCapableNode> modification : modifications) {
        if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
            SetConfigInputBuilder setConfigInputBuilder = new SetConfigInputBuilder();
            setConfigInputBuilder.setFlag(SwitchConfigFlag.FRAGNORMAL.toString());
            setConfigInputBuilder.setMissSearchLength(OFConstants.OFPCML_NO_BUFFER);
            setConfigInputBuilder.setNode(new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class)));
            final Future<RpcResult<SetConfigOutput>> resultFuture = nodeConfigService.setConfig(setConfigInputBuilder.build());
            JdkFutures.addErrorLogging(resultFuture, LOG, "addFlow");
        }
    }
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) SetConfigInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult)

Example 84 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class Test method testFlow.

@Override
public Future<RpcResult<Void>> testFlow(TestFlowInput input) {
    AddFlowInputBuilder flow = new AddFlowInputBuilder();
    flow.setPriority(2);
    flow.setMatch(createMatchBld().build());
    flow.setInstructions(createDecNwTtlInstructionsBld().build());
    flow.setBarrier(Boolean.FALSE);
    BigInteger value = BigInteger.valueOf(10L);
    flow.setCookie(new FlowCookie(value));
    flow.setCookieMask(new FlowCookie(value));
    flow.setHardTimeout(0);
    flow.setIdleTimeout(0);
    flow.setInstallHw(false);
    flow.setStrict(false);
    flow.setContainerName(null);
    flow.setFlags(new FlowModFlags(false, false, false, false, true));
    flow.setTableId((short) 0);
    flow.setFlowName("NiciraFLOW");
    // Construct the flow instance id
    final InstanceIdentifier<Node> flowInstanceId = InstanceIdentifier.builder(// File under nodes
    Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
    flow.setNode(new NodeRef(flowInstanceId));
    pushFlowViaRpc(flow.build());
    return Futures.immediateFuture(RpcResultBuilder.<Void>status(true).build());
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder) BigInteger(java.math.BigInteger) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 85 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class SalRoleServiceImplTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId);
    Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
    short testVersion = 4;
    Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion);
    Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState);
    Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo);
    Mockito.when(mockDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
    Mockito.when(mockConnectionContext.getFeatures()).thenReturn(mockFeaturesReply);
    Mockito.when(mockConnectionContext.getNodeId()).thenReturn(testNodeId);
    Mockito.when(mockFeaturesReply.getVersion()).thenReturn(testVersion);
    Mockito.when(mockDeviceContext.getMessageSpy()).thenReturn(mockMessageSpy);
    Mockito.when(mockRequestContextStack.<RoleRequestOutput>createRequestContext()).thenReturn(mockRequestContext);
    Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(testXid));
    Mockito.when(mockConnectionContext.getOutboundQueueProvider()).thenReturn(mockOutboundQueue);
    Mockito.when(mockDeviceContext.getPrimaryConnectionContext().getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
    NodeKey key = new NodeKey(testNodeId);
    InstanceIdentifier<Node> path = InstanceIdentifier.<Nodes>builder(Nodes.class).<Node, NodeKey>child(Node.class, key).build();
    nodeRef = new NodeRef(path);
}
Also used : RoleRequestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Before(org.junit.Before)

Aggregations

NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)69 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)30 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)29 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)27 ArrayList (java.util.ArrayList)23 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)18 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)17 Test (org.junit.Test)16 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)14 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)14 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)12 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)12 TransmitPacketInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder)12 BigInteger (java.math.BigInteger)11 TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)11 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)10 FlowRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef)8 GroupRef (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef)8 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)8 AddFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)7