2 * Copyright (c) 2015 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
8 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action;
10 import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
11 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
12 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
13 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNshc1;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNshc1Builder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.set.nshc._1.grouping.NxActionSetNshc1;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.set.nshc._1.grouping.NxActionSetNshc1Builder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.NxActionSetNshc1Grouping;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionSetNshc1NotifFlowsStatisticsUpdateApplyActionsCaseBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionSetNshc1NotifFlowsStatisticsUpdateWriteActionsCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionSetNshc1NotifGroupDescStatsUpdatedCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionSetNshc1NodesNodeTableFlowWriteActionsCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._1.grouping.NxSetNshc1;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._1.grouping.NxSetNshc1Builder;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 import com.google.common.base.Preconditions;
31 public class SetNshc1Convertor implements
32 ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action>,
33 ConvertorActionFromOFJava<Action, ActionPath> {
34 private static final Logger LOG = LoggerFactory.getLogger(SetNshc1Convertor.class);
38 public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(Action input, ActionPath path) {
39 NxActionSetNshc1 action = ((ActionSetNshc1) input.getActionChoice()).getNxActionSetNshc1();
40 NxSetNshc1Builder builder = new NxSetNshc1Builder();
41 builder.setNshc(action.getNshc());
42 return resolveAction(builder.build(), path);
45 private static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action resolveAction(NxSetNshc1 value, ActionPath path) {
47 case NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION:
48 return new NxActionSetNshc1NodesNodeTableFlowWriteActionsCaseBuilder().setNxSetNshc1(value).build();
49 case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION:
50 return new NxActionSetNshc1NotifFlowsStatisticsUpdateWriteActionsCaseBuilder().setNxSetNshc1(value).build();
51 case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION:
52 return new NxActionSetNshc1NotifFlowsStatisticsUpdateApplyActionsCaseBuilder().setNxSetNshc1(value).build();
53 case GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION:
54 return new NxActionSetNshc1NotifGroupDescStatsUpdatedCaseBuilder().setNxSetNshc1(value).build();
56 throw new CodecPreconditionException(path);
61 public Action convert(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
62 Preconditions.checkArgument(nxActionArg instanceof NxActionSetNshc1Grouping);
63 NxActionSetNshc1Grouping nxAction = (NxActionSetNshc1Grouping) nxActionArg;
64 ActionSetNshc1Builder builder = new ActionSetNshc1Builder();
65 NxActionSetNshc1Builder nxActionSetnsc1Builder = new NxActionSetNshc1Builder();
66 nxActionSetnsc1Builder.setNshc(nxAction.getNxSetNshc1().getNshc());
67 builder.setNxActionSetNshc1(nxActionSetnsc1Builder.build());
68 return ActionUtil.createAction(builder.build());