Introducing Openflow NX Extension infrastructure and NX_RESUBMIT action in ovsdb...
[ovsdb.git] / of-extension / nx-sal / src / main / java / org / opendaylight / ovs / nx / sal / convertor / action / ActionUtil.java
1 /*
2  * Copyright (C) 2014 Red Hat, Inc.
3  *
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
7  *
8  * Authors : Madhu Venugopal
9  */
10 package org.opendaylight.ovs.nx.sal.convertor.action;
11
12 import org.opendaylight.openflowjava.nx.api.NiciraConstants;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.ovs.nx.action.rev140421.OfjAugNxAction;
21
22 public class ActionUtil {
23
24     private final static ExperimenterIdActionBuilder EXPERIMENTER_ID_ACTION_BUILDER;
25
26     static {
27         EXPERIMENTER_ID_ACTION_BUILDER = new ExperimenterIdActionBuilder();
28         EXPERIMENTER_ID_ACTION_BUILDER.setExperimenter(new ExperimenterId(NiciraConstants.NX_VENDOR_ID));
29     }
30
31     /**
32      * @param augNxAction
33      * @param subType
34      * @return OFJava action with augmentation containing action subtype and experimenter type
35      */
36     public static Action createNiciraAction(OfjAugNxAction augNxAction,
37             Class<? extends ExperimenterActionSubType> subType) {
38         ActionBuilder actionBuilder = new ActionBuilder();
39         actionBuilder.setType(Experimenter.class);
40         actionBuilder.addAugmentation(ExperimenterIdAction.class, EXPERIMENTER_ID_ACTION_BUILDER.setSubType(subType)
41                 .build());
42         actionBuilder.addAugmentation(OfjAugNxAction.class, augNxAction);
43         return actionBuilder.build();
44     }
45 }