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.action.data.ActionConvertorData;
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
18 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class SalToOfGeneralExtensionGroupingCase extends ConvertorCase<GeneralExtensionGrouping, Action, ActionConvertorData> {
27 private static final Logger LOG = LoggerFactory.getLogger(SalToOfGeneralExtensionGroupingCase.class);
29 public SalToOfGeneralExtensionGroupingCase() {
30 super(GeneralExtensionGrouping.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
35 public Optional<Action> process(@Nonnull final GeneralExtensionGrouping source, final ActionConvertorData data) {
36 final short version = data.getVersion();
38 * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
39 * - we might need sessionContext as converter input
43 Extension extAction = source.getExtension();
44 ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(source.getExtensionKey(), version);
45 ConvertorToOFJava<Action> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
46 return convertor != null ? Optional.of(convertor.convert(extAction)) : Optional.empty();