Search in sources :

Example 6 with PortNumberUni

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

Example 7 with PortNumberUni

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);
}
Also used : FlowCapableNodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder) PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) State(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State) PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) StateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder) Test(org.junit.Test)

Example 8 with PortNumberUni

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);
}
Also used : PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortFeaturesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10) PortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) Test(org.junit.Test)

Example 9 with PortNumberUni

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());
}
Also used : PortMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) Test(org.junit.Test)

Example 10 with PortNumberUni

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);
}
Also used : PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) Test(org.junit.Test)

Aggregations

PortNumberUni (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni)10 Test (org.junit.Test)5 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 FlowCapableNodeConnectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder)2 PortBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder)2 ArrayList (java.util.ArrayList)1 OpenflowVersion (org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)1 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)1 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder)1 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)1 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)1 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig)1 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures)1 PortMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage)1 PortMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessageBuilder)1 State (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State)1 StateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder)1 MultipartReplyPortDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder)1 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports)1