2 * Copyright (C) 2018 Redhat, 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 com.google.common.base.Preconditions;
11 import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
12 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
13 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
14 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.aug.nx.action.ActionCtClearBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.ct.clear.grouping.NxActionCtClearBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.NxActionCtClearGrouping;
19 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.NxActionCtClearNotifFlowsStatisticsUpdateApplyActionsCaseBuilder;
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.write.actions._case.write.actions.action.action.NxActionCtClearNotifFlowsStatisticsUpdateWriteActionsCaseBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.get.flow.statistics.output.flow.and.statistics.map.list.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionCtClearNotifDirectStatisticsUpdateApplyActionsCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.get.flow.statistics.output.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionCtClearNotifDirectStatisticsUpdateWriteActionsCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionCtClearNotifGroupDescStatsUpdatedCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionCtClearNodesNodeTableFlowApplyActionsCaseBuilder;
25 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.NxActionCtClearNodesNodeTableFlowWriteActionsCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.ct.clear.grouping.NxCtClear;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.ct.clear.grouping.NxCtClearBuilder;
29 public class CtClearConvertor implements
30 ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action,
31 Action>, ConvertorActionFromOFJava<Action, ActionPath> {
33 private static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action resolveAction(
34 final NxCtClear value, final ActionPath path) {
36 case INVENTORY_FLOWNODE_TABLE_WRITE_ACTIONS:
37 return new NxActionCtClearNodesNodeTableFlowWriteActionsCaseBuilder().setNxCtClear(value).build();
38 case FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS:
39 return new NxActionCtClearNotifFlowsStatisticsUpdateWriteActionsCaseBuilder().setNxCtClear(value)
41 case FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS:
42 return new NxActionCtClearNotifFlowsStatisticsUpdateApplyActionsCaseBuilder().setNxCtClear(value)
44 case GROUP_DESC_STATS_UPDATED_BUCKET_ACTION:
45 return new NxActionCtClearNotifGroupDescStatsUpdatedCaseBuilder().setNxCtClear(value).build();
46 case FLOWS_STATISTICS_RPC_WRITE_ACTIONS:
47 return new NxActionCtClearNotifDirectStatisticsUpdateWriteActionsCaseBuilder()
48 .setNxCtClear(value).build();
49 case FLOWS_STATISTICS_RPC_APPLY_ACTIONS:
50 return new NxActionCtClearNotifDirectStatisticsUpdateApplyActionsCaseBuilder()
51 .setNxCtClear(value).build();
52 case INVENTORY_FLOWNODE_TABLE_APPLY_ACTIONS:
53 return new NxActionCtClearNodesNodeTableFlowApplyActionsCaseBuilder().setNxCtClear(value).build();
55 throw new CodecPreconditionException(path);
60 public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(
61 final Action input, final ActionPath path) {
62 NxCtClearBuilder builder = new NxCtClearBuilder();
63 return resolveAction(builder.build(), path);
67 public Action convert(
68 final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
69 Preconditions.checkArgument(nxActionArg instanceof NxActionCtClearGrouping);
70 ActionCtClearBuilder builder = new ActionCtClearBuilder();
71 NxActionCtClearBuilder nxActionCtClearBuilder = new NxActionCtClearBuilder();
72 builder.setNxActionCtClear(nxActionCtClearBuilder.build());
73 return ActionUtil.createAction(builder.build());