use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni in project openflowplugin by opendaylight.
the class PortConvertorTest method testtoPortDescwithAllParameters.
/**
* test of {@link PortConvertor#toPortDesc(FlowCapablePort , short)}.
*/
@Test
public void testtoPortDescwithAllParameters() {
State state = new StateBuilder().setBlocked(false).setLinkDown(false).setLive(false).build();
FlowCapableNodeConnectorBuilder flowCapableNodeConnectorBuilder = new FlowCapableNodeConnectorBuilder();
flowCapableNodeConnectorBuilder.setAdvertisedFeatures(features);
flowCapableNodeConnectorBuilder.setConfiguration(config);
flowCapableNodeConnectorBuilder.setCurrentFeature(features);
flowCapableNodeConnectorBuilder.setCurrentSpeed(null);
flowCapableNodeConnectorBuilder.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
flowCapableNodeConnectorBuilder.setMaximumSpeed(null);
flowCapableNodeConnectorBuilder.setName("foo");
flowCapableNodeConnectorBuilder.setPeerFeatures(features);
flowCapableNodeConnectorBuilder.setPortNumber(new PortNumberUni(42L));
flowCapableNodeConnectorBuilder.setState(state);
flowCapableNodeConnectorBuilder.setSupported(features);
final Ports portsOut = PortConvertor.toPortDesc(flowCapableNodeConnectorBuilder.build(), EncodeConstants.OF13_VERSION_ID);
PortsBuilder portsB = new PortsBuilder();
portsB.setAdvertisedFeatures(portf31);
portsB.setConfig(config31);
portsB.setCurrentFeatures(portf31);
portsB.setCurrSpeed(null);
portsB.setHwAddr(new MacAddress(DEFAULT_MAC_ADDRESS));
portsB.setMaxSpeed(null);
portsB.setName("foo");
portsB.setPeerFeatures(portf31);
portsB.setPortNo(42L);
portsB.setState(new PortState(false, false, false));
portsB.setSupportedFeatures(portf31);
Assert.assertEquals(portsB.build(), portsOut);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni in project openflowplugin by opendaylight.
the class PortConvertorTest method testtoPortModInputwithAllParameters.
/**
* test of {@link PortConvertor#convert(Port, VersionConvertorData)} }.
*/
@Test
public void testtoPortModInputwithAllParameters() {
PortBuilder portBld = new PortBuilder();
portBld.setAdvertisedFeatures(features);
portBld.setConfiguration(config);
portBld.setPortNumber(new PortNumberUni(42L));
portBld.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
Optional<PortModInput> portOutOptional = convertorManager.convert(portBld.build(), data);
final PortModInput portOut = portOutOptional.orElse(PortConvertor.defaultResult(OFConstants.OFP_VERSION_1_3));
PortConfigV10 portConfV10 = new PortConfigV10(false, false, false, false, true, true, false);
PortModInputBuilder portModInputBld = new PortModInputBuilder();
portModInputBld.setConfig(config31);
portModInputBld.setMask(configMask31);
portModInputBld.setPortNo(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(42L));
portModInputBld.setHwAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
portModInputBld.setAdvertise(portf31);
portModInputBld.setConfigV10(portConfV10);
portModInputBld.setMaskV10(portConfMaskV10);
portModInputBld.setAdvertiseV10(new PortFeaturesV10(null, null, null, null, null, null, null, true, null, null, null, null));
portModInputBld.setVersion((short) EncodeConstants.OF13_VERSION_ID);
Assert.assertEquals(portModInputBld.build(), portOut);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni in project openflowplugin by opendaylight.
the class SingleLayerPortServiceTest method buildRequest.
@Test
public void buildRequest() throws Exception {
final Port input = new PortBuilder().setPortNumber(new PortNumberUni(PORT_ID)).build();
final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
assertEquals(PortMessage.class, ofHeader.getImplementedInterface());
final PortMessage result = PortMessage.class.cast(ofHeader);
assertEquals(PORT_ID, result.getPortNumber().getUint32().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni in project openflowplugin by opendaylight.
the class OpenflowPortsUtilTest method testPortNumberToString.
/**
* test for method {@link OpenflowPortsUtil}.
*/
@Test
public void testPortNumberToString() {
PortNumberUni portNumber;
portNumber = new PortNumberUni(42L);
Assert.assertEquals("42", OpenflowPortsUtil.portNumberToString(portNumber));
portNumber = new PortNumberUni(OutputPortValues.FLOOD.toString());
Assert.assertEquals("FLOOD", OpenflowPortsUtil.portNumberToString(portNumber));
portNumber = new PortNumberUni((String) null);
Assert.assertNotNull(portNumber);
}
Aggregations