87bad604888f811f93ca0cac4de2231550e0464e
[groupbasedpolicy.git] / renderers / ofoverlay / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / sf / AllowAction.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
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
9 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf;
10
11 import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxOutputRegAction;
12
13 import java.util.List;
14 import java.util.Map;
15
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionName;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Description;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg7;
23
24
25 /**
26  * Allow action
27  */
28 public class AllowAction extends Action {
29     public static final ActionDefinitionId ID =
30             new ActionDefinitionId("f942e8fd-e957-42b7-bd18-f73d11266d17");
31     protected static final String TYPE = "type";
32     protected static final ActionDefinition DEF =
33             new ActionDefinitionBuilder()
34                 .setId(ID)
35                 .setName(new ActionName("allow"))
36                 .setDescription(new Description("Allow the specified traffic to pass"))
37                 .build();
38
39     // How allow is implemented in the PolicyEnforcer table
40         private final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action allow = 
41                         nxOutputRegAction(NxmNxReg7.class);
42
43     @Override
44     public ActionDefinitionId getId() {
45         return ID;
46     }
47
48     @Override
49     public ActionDefinition getActionDef() {
50         return DEF;
51     }
52
53     @Override
54     public List<ActionBuilder> updateAction(List<ActionBuilder> actions,
55                                             Map<String, Object> params,
56                                             Integer order) {
57         /*
58          * Allow action doesn't use parameters
59          * TODO: check to make sure ActionBuilder w/allow isn't already present
60          */
61         ActionBuilder ab = new ActionBuilder();
62         ab.setAction(allow)
63           .setOrder(order);
64         actions.add(ab);
65         return actions;
66     }
67
68 }