Search in sources :

Example 11 with OpenflowVersion

use of org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion in project openflowplugin by opendaylight.

the class NodeConnectorRefToPortTranslator method fromNodeConnectorRef.

/**
 * Gets port number from {@link NodeConnectorRef}.
 * @param nodeConnectorRef Node connector reference
 * @param version Openflow version
 * @return port number
 */
@SuppressWarnings("unchecked")
@Nullable
public static Long fromNodeConnectorRef(@Nonnull NodeConnectorRef nodeConnectorRef, short version) {
    Preconditions.checkNotNull(nodeConnectorRef);
    Long port = null;
    final InstanceIdentifier<?> value = nodeConnectorRef.getValue();
    if (value instanceof KeyedInstanceIdentifier) {
        KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> identifier = (KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey>) value;
        OpenflowVersion ofVersion = OpenflowVersion.get(version);
        String nodeConnectorId = identifier.getKey().getId().getValue();
        port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, nodeConnectorId);
    }
    return port;
}
Also used : NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) Nullable(javax.annotation.Nullable)

Example 12 with OpenflowVersion

use of org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion in project openflowplugin by opendaylight.

the class PortTranslatorUtil method translatePortRemoved.

public static NodeConnectorRemoved translatePortRemoved(final Short version, final BigInteger datapathId, final Long portNumber, final PortGrouping port) {
    OpenflowVersion ofVersion = OpenflowVersion.get(version);
    NodeConnectorRemovedBuilder builder = new NodeConnectorRemovedBuilder();
    builder.setNodeConnectorRef(InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(datapathId, portNumber, ofVersion));
    return builder.build();
}
Also used : OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) NodeConnectorRemovedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemovedBuilder)

Example 13 with OpenflowVersion

use of org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion in project openflowplugin by opendaylight.

the class OfToSalOutputActionCase method process.

@Override
public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
    OutputActionBuilder outputAction = new OutputActionBuilder();
    OutputAction outputActionFromOF = source.getOutputAction();
    if (outputActionFromOF.getPort() != null) {
        PortNumberUni protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(ofVersion, outputActionFromOF.getPort().getValue());
        String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
        outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
    } else {
        LOG.error("Provided action is not OF Output action, no associated port found!");
    }
    Integer maxLength = outputActionFromOF.getMaxLength();
    if (maxLength != null) {
        outputAction.setMaxLength(maxLength);
    } else {
        LOG.error("Provided action is not OF Output action, no associated length found!");
    }
    OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
    outputActionCaseBuilder.setOutputAction(outputAction.build());
    return Optional.of(outputActionCaseBuilder.build());
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) OutputAction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputAction) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)

Aggregations

OpenflowVersion (org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)13 BigInteger (java.math.BigInteger)3 Nullable (javax.annotation.Nullable)3 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)3 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)3 Collections (java.util.Collections)2 Nonnull (javax.annotation.Nonnull)2 TranslatorLibrary (org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary)2 ConvertorExecutor (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)2 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)2 NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)2 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)2 PortStatusMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 HashedWheelTimer (io.netty.util.HashedWheelTimer)1