Search in sources :

Example 1 with VersionDatapathIdConvertorData

use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.

the class GroupConvertorTest method testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure.

/**
 * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure() {
    int actionOrder = 0;
    final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
    addGroupBuilder.setGroupId(new GroupId(10L));
    addGroupBuilder.setGroupType(GroupTypes.GroupFf);
    final List<Bucket> bucketList = new ArrayList<>();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = new ArrayList<>();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList1 = new ArrayList<>();
    // Action1: 005
    actionsList.add(assembleActionBuilder("005", actionOrder++).build());
    // Action2: 006
    actionsList.add(assembleActionBuilder("006", actionOrder++).build());
    // .. and mr.Bond is not coming today
    final BucketsBuilder bucketsB = new BucketsBuilder();
    final BucketBuilder bucketB = new BucketBuilder();
    bucketB.setAction(actionsList);
    final Bucket bucket = bucketB.build();
    // List of bucket
    bucketList.add(bucket);
    final BucketBuilder bucketB1 = new BucketBuilder();
    // Action1
    actionsList1.add(assembleCopyTtlInBuilder(actionOrder++).build());
    // Action2:
    actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build());
    bucketB1.setAction(actionsList1);
    // second bucket
    final Bucket bucket1 = bucketB1.build();
    bucketList.add(bucket1);
    // List of bucket added to the Buckets
    bucketsB.setBucket(bucketList);
    final Buckets buckets = bucketsB.build();
    addGroupBuilder.setBuckets(buckets);
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
    data.setDatapathId(BigInteger.valueOf(1));
    final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
    assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
    assertEquals(GroupType.OFPGTFF, outAddGroupInput.getType());
    assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
    final List<Action> outActionList = outAddGroupInput.getBucketsList().get(0).getAction();
    for (int outItem = 0; outItem < outActionList.size(); outItem++) {
        final Action action = outActionList.get(outItem);
        if (action.getActionChoice() instanceof GroupActionCase) {
            assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
        }
    }
    final List<Action> outActionList1 = outAddGroupInput.getBucketsList().get(1).getAction();
    for (int outItem = 0; outItem < outActionList1.size(); outItem++) {
        final Action action = outActionList1.get(outItem);
        if (action.getActionChoice() instanceof GroupActionCase) {
            assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
        }
    }
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) SetMplsTtlAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) GroupActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase) Test(org.junit.Test)

Example 2 with VersionDatapathIdConvertorData

use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.

the class GroupConvertorTest method testGroupModConvertorNoBucket.

/**
 * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testGroupModConvertorNoBucket() {
    final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
    addGroupBuilder.setGroupId(new GroupId(10L));
    addGroupBuilder.setGroupType(GroupTypes.GroupAll);
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
    data.setDatapathId(BigInteger.valueOf(1));
    final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
    assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
    assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
}
Also used : VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Test(org.junit.Test)

Example 3 with VersionDatapathIdConvertorData

use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.

the class PacketReceivedTranslator method getPacketInMatch.

@VisibleForTesting
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(input.getVersion());
    datapathIdConvertorData.setDatapathId(datapathId);
    final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder> matchOptional = convertorExecutor.convert(input.getMatch(), datapathIdConvertorData);
    final MatchBuilder matchBuilder = matchOptional.map(matchBuilder1 -> new MatchBuilder(matchBuilder1.build())).orElseGet(MatchBuilder::new);
    final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()), MatchPath.PACKET_RECEIVED_MATCH);
    if (matchExtensionWrap != null) {
        matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
    }
    return matchBuilder.build();
}
Also used : PacketInUtil(org.opendaylight.openflowplugin.impl.util.PacketInUtil) ConvertorExecutor(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor) MatchPath(org.opendaylight.openflowplugin.extension.api.path.MatchPath) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MatchExtensionHelper(org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) AugmentTuple(org.opendaylight.openflowplugin.extension.api.AugmentTuple) Optional(java.util.Optional) BigInteger(java.math.BigInteger) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) NodeConnectorRefToPortTranslator(org.opendaylight.openflowplugin.impl.util.NodeConnectorRefToPortTranslator) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 4 with VersionDatapathIdConvertorData

use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.

the class BundleAddMessageConverter method convert.

@Override
public BundleAddMessageOnf convert(BundleAddMessageSal experimenterMessageCase) throws ConversionException {
    final OnfAddMessageGroupingDataBuilder dataBuilder = new OnfAddMessageGroupingDataBuilder();
    dataBuilder.setBundleId(experimenterMessageCase.getSalAddMessageData().getBundleId());
    dataBuilder.setFlags(experimenterMessageCase.getSalAddMessageData().getFlags());
    dataBuilder.setBundleProperty(experimenterMessageCase.getSalAddMessageData().getBundleProperty());
    final BundleInnerMessage innerMessage = experimenterMessageCase.getSalAddMessageData().getBundleInnerMessage();
    final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
    data.setDatapathId(digDatapathId(node));
    if (innerMessage.getImplementedInterface().equals(BundleAddFlowCase.class) || innerMessage.getImplementedInterface().equals(BundleUpdateFlowCase.class) || innerMessage.getImplementedInterface().equals(BundleRemoveFlowCase.class)) {
        dataBuilder.setBundleInnerMessage(convertBundleFlowCase(innerMessage, data));
    } else if (innerMessage.getImplementedInterface().equals(BundleAddGroupCase.class) || innerMessage.getImplementedInterface().equals(BundleUpdateGroupCase.class) || innerMessage.getImplementedInterface().equals(BundleRemoveGroupCase.class)) {
        dataBuilder.setBundleInnerMessage(convertBundleGroupCase(innerMessage, data));
    } else if (innerMessage.getImplementedInterface().equals(BundleUpdatePortCase.class)) {
        dataBuilder.setBundleInnerMessage(convertBundlePortCase(innerMessage, data));
    } else {
        throw new ConversionException("Unsupported inner message");
    }
    return new BundleAddMessageOnfBuilder().setOnfAddMessageGroupingData(dataBuilder.build()).build();
}
Also used : ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) OnfAddMessageGroupingDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.add.message.onf.OnfAddMessageGroupingDataBuilder) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) BundleInnerMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.BundleInnerMessage) BundleAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleAddGroupCase) BundleUpdateGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleUpdateGroupCase) BundleRemoveFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleRemoveFlowCase) BundleAddMessageOnfBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleAddMessageOnfBuilder)

Example 5 with VersionDatapathIdConvertorData

use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translate.

public static Optional<? extends MultipartReplyBody> translate(final OfHeader message, final DeviceInfo deviceInfo, @Nullable final ConvertorExecutor convertorExecutor, @Nullable final TranslatorLibrary translatorLibrary) {
    if (message instanceof MultipartReply) {
        final Optional<ConvertorExecutor> convertor = Optional.ofNullable(convertorExecutor);
        final Optional<TranslatorLibrary> translator = Optional.ofNullable(translatorLibrary);
        final MultipartReply msg = MultipartReply.class.cast(message);
        final OpenflowVersion ofVersion = OpenflowVersion.get(deviceInfo.getVersion());
        final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
        data.setDatapathId(deviceInfo.getDatapathId());
        switch(msg.getType()) {
            case OFPMPFLOW:
                return convertor.flatMap(c -> Optional.of(translateFlow(msg, data, c)));
            case OFPMPAGGREGATE:
                return Optional.of(translateAggregate(msg));
            case OFPMPPORTSTATS:
                return Optional.of(translatePortStats(msg, ofVersion, deviceInfo.getDatapathId()));
            case OFPMPGROUP:
                return convertor.flatMap(c -> Optional.of(translateGroup(msg, data, c)));
            case OFPMPGROUPDESC:
                return convertor.flatMap(c -> Optional.of(translateGroupDesc(msg, data, c)));
            case OFPMPGROUPFEATURES:
                return Optional.of(translateGroupFeatures(msg));
            case OFPMPMETER:
                return convertor.flatMap(c -> Optional.of(translateMeter(msg, data, c)));
            case OFPMPMETERCONFIG:
                return convertor.flatMap(c -> Optional.of(translateMeterConfig(msg, data, c)));
            case OFPMPMETERFEATURES:
                return Optional.of(translateMeterFeatures(msg));
            case OFPMPTABLE:
                return Optional.of(translateTable(msg));
            case OFPMPQUEUE:
                return Optional.of(translateQueue(msg, ofVersion, deviceInfo.getDatapathId()));
            case OFPMPDESC:
                return Optional.of(translateDesc(msg));
            case OFPMPTABLEFEATURES:
                return convertor.flatMap(c -> Optional.of(translateTableFeatures(msg, deviceInfo.getVersion(), c)));
            case OFPMPPORTDESC:
                return translator.flatMap(t -> Optional.of(translatePortDesc(msg, deviceInfo, t)));
            default:
        }
    } else if (message instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) {
        return Optional.of(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply.class.cast(message).getMultipartReplyBody());
    }
    LOG.debug("Failed to translate {} for node {}.", message.getImplementedInterface(), deviceInfo);
    return Optional.empty();
}
Also used : VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) TranslatorLibrary(org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary) ConvertorExecutor(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)

Aggregations

VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)45 Test (org.junit.Test)39 BigInteger (java.math.BigInteger)32 ArrayList (java.util.ArrayList)25 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)22 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)22 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)21 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)20 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder)20 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)18 ArpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch)15 Ipv6Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match)15 SctpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch)14 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)13 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)11 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)9 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)9 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)9 MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)9 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)9