Move definitions of classifiers and actions to
[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.sf.actions.AllowActionDefinition;
17 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfContext;
18 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfWriter;
19 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.PolicyEnforcer.NetworkElements;
20 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.PolicyEnforcer.PolicyPair;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.HasDirection.Direction;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.subject.feature.instances.ActionInstance;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg7;
27
28 /**
29  * Allow action
30  */
31 public class AllowAction extends Action {
32
33     // How allow is implemented in the PolicyEnforcer table
34     private final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action allow = nxOutputRegAction(NxmNxReg7.class);
35
36     @Override
37     public ActionDefinitionId getId() {
38         return AllowActionDefinition.ID;
39     }
40
41     @Override
42     public ActionDefinition getActionDef() {
43         return AllowActionDefinition.DEFINITION;
44     }
45
46     @Override
47     public List<ActionBuilder> updateAction(List<ActionBuilder> actions,
48                                             Map<String, Object> params,
49                                             Integer order,
50                                             NetworkElements netElements,
51                                             PolicyPair policyPair,
52                                             OfWriter ofWriter,
53                                             OfContext ctx,
54                                             Direction direction) {
55         /*
56          * Allow action doesn't use parameters
57          * TODO: check to make sure ActionBuilder w/allow isn't already present
58          */
59         ActionBuilder ab = new ActionBuilder();
60         ab.setAction(allow)
61           .setOrder(order);
62         actions.add(ab);
63         return actions;
64     }
65
66     @Override
67     public boolean isValid(ActionInstance actionInstance) {
68         return true;
69     }
70 }