2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
11 import java.util.Optional;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.openflowplugin.api.OFConstants;
14 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
15 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
18 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
19 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 public class SalToOfGeneralExtensionGroupingCase
28 extends ConvertorCase<GeneralExtensionGrouping, Action, ActionConvertorData> {
29 private static final Logger LOG = LoggerFactory.getLogger(SalToOfGeneralExtensionGroupingCase.class);
31 public SalToOfGeneralExtensionGroupingCase() {
32 super(GeneralExtensionGrouping.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
37 public Optional<Action> process(@Nonnull final GeneralExtensionGrouping source, final ActionConvertorData data,
38 ConvertorExecutor convertorExecutor) {
39 final short version = data.getVersion();
42 * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
43 * - we might need sessionContext as converter input
46 Extension extAction = source.getExtension();
47 ConverterExtensionKey<? extends ExtensionKey> key =
48 new ConverterExtensionKey<>(source.getExtensionKey(), version);
49 ConvertorToOFJava<Action> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
50 return convertor != null ? Optional.of(convertor.convert(extAction)) : Optional.empty();