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