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;
}
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();
}
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());
}
Aggregations