Bug 3302: fix for GroupTable
[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.groupbasedpolicy.renderer.ofoverlay.OfContext;
17 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfWriter;
18 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.PolicyEnforcer.NetworkElements;
19 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.PolicyEnforcer.PolicyPair;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionName;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Description;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.HasDirection.Direction;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.subject.feature.instances.ActionInstance;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg7;
29
30
31 /**
32  * Allow action
33  */
34 public class AllowAction extends Action {
35
36     protected static final ActionDefinitionId ID = new ActionDefinitionId("f942e8fd-e957-42b7-bd18-f73d11266d17");
37     /**
38      * Access control - allow action-definition
39      */
40     public static final ActionDefinition DEFINITION = new ActionDefinitionBuilder().setId(ID)
41         .setName(new ActionName("allow"))
42         .setDescription(new Description("Allow the specified traffic to pass"))
43         .build();
44
45     // How allow is implemented in the PolicyEnforcer table
46     private final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action allow = nxOutputRegAction(NxmNxReg7.class);
47
48     @Override
49     public ActionDefinitionId getId() {
50         return ID;
51     }
52
53     @Override
54     public ActionDefinition getActionDef() {
55         return DEFINITION;
56     }
57
58     @Override
59     public List<ActionBuilder> updateAction(List<ActionBuilder> actions,
60                                             Map<String, Object> params,
61                                             Integer order,
62                                             NetworkElements netElements,
63                                             PolicyPair policyPair,
64                                             OfWriter ofWriter,
65                                             OfContext ctx,
66                                             Direction direction) {
67         /*
68          * Allow action doesn't use parameters
69          * TODO: check to make sure ActionBuilder w/allow isn't already present
70          */
71         ActionBuilder ab = new ActionBuilder();
72         ab.setAction(allow)
73           .setOrder(order);
74         actions.add(ab);
75         return actions;
76     }
77
78     @Override
79     public boolean isValid(ActionInstance actionInstance) {
80         return true;
81     }
82
83 }