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