support for create/remove terminatingserviceActions
[vpnservice.git] / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / rpcservice / InterfaceManagerRpcService.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.interfacemgr.rpcservice;
10
11 import com.google.common.base.Optional;
12 import com.google.common.util.concurrent.FutureCallback;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import com.google.common.util.concurrent.SettableFuture;
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
18 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
19 import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
20 import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
21 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
22 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
23 import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
24 import org.opendaylight.vpnservice.mdsalutil.*;
25 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.IfIndexesInterfaceMap;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterface;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterfaceKey;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryKey;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntry;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.*;
45 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
46 import org.opendaylight.yangtools.yang.common.RpcError;
47 import org.opendaylight.yangtools.yang.common.RpcResult;
48 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
51
52 import java.math.BigInteger;
53 import java.util.ArrayList;
54 import java.util.Arrays;
55 import java.util.List;
56 import java.util.concurrent.Future;
57
58 public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
59     private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerRpcService.class);
60     DataBroker dataBroker;
61     IMdsalApiManager mdsalMgr;
62     public InterfaceManagerRpcService(DataBroker dataBroker, IMdsalApiManager mdsalMgr) {
63         this.dataBroker = dataBroker;
64         this.mdsalMgr = mdsalMgr;
65     }
66
67     @Override
68     public Future<RpcResult<GetDpidFromInterfaceOutput>> getDpidFromInterface(GetDpidFromInterfaceInput input) {
69         String interfaceName = input.getIntfName();
70         RpcResultBuilder<GetDpidFromInterfaceOutput> rpcResultBuilder;
71         try {
72             BigInteger dpId = null;
73             InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
74             Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
75             if (Tunnel.class.equals(interfaceInfo.getType())) {
76                 ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
77                 dpId = parentRefs.getDatapathNodeIdentifier();
78             } else {
79                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
80                         InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
81                 String lowerLayerIf = ifState.getLowerLayerIf().get(0);
82                 NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
83                 dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
84             }
85             GetDpidFromInterfaceOutputBuilder output = new GetDpidFromInterfaceOutputBuilder().setDpid(
86                     (dpId));
87             rpcResultBuilder = RpcResultBuilder.success();
88             rpcResultBuilder.withResult(output.build());
89         } catch (Exception e) {
90             LOG.error("Retrieval of datapath id for the key {} failed due to {}", interfaceName, e);
91             rpcResultBuilder = RpcResultBuilder.failed();
92         }
93         return Futures.immediateFuture(rpcResultBuilder.build());
94     }
95
96     @Override
97     public Future<RpcResult<Void>> createTerminatingServiceActions(CreateTerminatingServiceActionsInput input) {
98         final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
99         try{
100             List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
101             WriteTransaction t = dataBroker.newWriteOnlyTransaction();
102             LOG.info("create terminatingServiceAction on DpnId = {} for tunnel-key {}", input.getDpid() , input.getTunnelKey());
103
104             // Matching metadata
105             mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {input.getTunnelKey()}));
106             List<Instruction> instructions = input.getInstruction();
107             Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(input.getInterfaceName()),dataBroker);
108             IfTunnel tunnelInfo = interfaceInfo.getAugmentation(IfTunnel.class);
109             if(tunnelInfo != null) {
110                 short tableId = tunnelInfo.isInternal() ? IfmConstants.INTERNAL_TUNNEL_TABLE :
111                         IfmConstants.EXTERNAL_TUNNEL_TABLE;
112                 List<Instruction> instructionSet = new ArrayList<Instruction>();
113                 if (instructions != null && !instructions.isEmpty()) {
114                     for (Instruction info : instructions) {
115                         instructionSet.add(info);
116                     }
117                 }
118                 final String flowRef = getFlowRef(input.getDpid(),tableId, input.getTunnelKey());
119                 Flow terminatingSerFlow = MDSALUtil.buildFlowNew(tableId, flowRef,
120                         5, "TST Flow Entry", 0, 0,
121                         IfmConstants.TUNNEL_TABLE_COOKIE.add(input.getTunnelKey()), mkMatches, instructionSet);
122
123                 ListenableFuture<Void> installFlowResult = mdsalMgr.installFlow(input.getDpid(), terminatingSerFlow);
124                 Futures.addCallback(installFlowResult, new FutureCallback<Void>(){
125
126                     @Override
127                     public void onSuccess(Void aVoid) {
128                         result.set(RpcResultBuilder.<Void>success().build());
129                     }
130
131                     @Override
132                     public void onFailure(Throwable error) {
133                         String msg = String.format("Unable to install terminating service flow %s", flowRef);
134                         LOG.error("create terminating service actions failed. {}. {}", msg, error);
135                         result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
136                     }
137                 });
138                 result.set(RpcResultBuilder.<Void>success().build());
139             } else {
140                 String msg = String.format("Terminating Service Actions cannot be created for a non-tunnel interface %s",input.getInterfaceName());
141                 LOG.error(msg);
142                 result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg).build());
143             }
144         }catch(Exception e){
145             String msg = String.format("create Terminating Service Actions for %s failed",input.getInterfaceName());
146             LOG.error("create Terminating Service Actions for {} failed due to {}" ,input.getDpid(), e);
147             result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, e.getMessage()).build());
148         }
149         return result;
150     }
151
152     @Override
153     public Future<RpcResult<Void>> removeTerminatingServiceActions(RemoveTerminatingServiceActionsInput input) {
154         final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
155         try{
156             WriteTransaction t = dataBroker.newWriteOnlyTransaction();
157             LOG.info("remove terminatingServiceAction on DpnId = {} for tunnel-key {}", input.getDpid() , input.getTunnelKey());
158
159             Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(input.getInterfaceName()),dataBroker);
160             IfTunnel tunnelInfo = interfaceInfo.getAugmentation(IfTunnel.class);
161             if(tunnelInfo != null) {
162                 short tableId = tunnelInfo.isInternal() ? IfmConstants.INTERNAL_TUNNEL_TABLE :
163                         IfmConstants.EXTERNAL_TUNNEL_TABLE;
164                 final String flowRef = getFlowRef(input.getDpid(),tableId, input.getTunnelKey());
165                 FlowEntity flowEntity = MDSALUtil.buildFlowEntity(input.getDpid(), tableId, flowRef,
166                         0, flowRef, 0, 0,
167                         null, null, null);
168                 ListenableFuture<Void> removeFlowResult = mdsalMgr.removeFlow(input.getDpid(), flowEntity);
169                 Futures.addCallback(removeFlowResult, new FutureCallback<Void>(){
170
171                     @Override
172                     public void onSuccess(Void aVoid) {
173                         result.set(RpcResultBuilder.<Void>success().build());
174                     }
175
176                     @Override
177                     public void onFailure(Throwable error) {
178                         String msg = String.format("Unable to install terminating service flow %s", flowRef);
179                         LOG.error("create terminating service actions failed. {}. {}", msg, error);
180                         result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
181                     }
182                 });
183                 result.set(RpcResultBuilder.<Void>success().build());
184             } else {
185                 String msg = String.format("Terminating Service Actions cannot be removed for a non-tunnel interface %s",
186                         input.getInterfaceName());
187                 LOG.error(msg);
188                 result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg).build());
189             }
190         }catch(Exception e){
191             LOG.error("Remove Terminating Service Actions for {} failed due to {}" ,input.getDpid(), e);
192             String msg = String.format("Remove Terminating Service Actions for %d failed.", input.getDpid());
193             result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, e.getMessage()).build());
194         }
195         return result;
196     }
197
198     @Override
199     public Future<RpcResult<GetEndpointIpForDpnOutput>> getEndpointIpForDpn(GetEndpointIpForDpnInput input) {
200         RpcResultBuilder<GetEndpointIpForDpnOutput> rpcResultBuilder;
201         try {
202             BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(input.getDpid());
203             InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
204                     InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
205             BridgeEntry bridgeEntry =
206                     InterfaceMetaUtils.getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier,
207                             dataBroker);
208             // local ip of any of the bridge interface entry will be the dpn end point ip
209             BridgeInterfaceEntry bridgeInterfaceEntry = bridgeEntry.getBridgeInterfaceEntry().get(0);
210             InterfaceKey interfaceKey = new InterfaceKey(bridgeInterfaceEntry.getInterfaceName());
211             Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
212             IfTunnel tunnel = interfaceInfo.getAugmentation(IfTunnel.class);
213             GetEndpointIpForDpnOutputBuilder endpointIpForDpnOutput = new GetEndpointIpForDpnOutputBuilder().setLocalIps(Arrays.asList(tunnel.getTunnelSource()));
214             rpcResultBuilder = RpcResultBuilder.success();
215             rpcResultBuilder.withResult(endpointIpForDpnOutput.build());
216         }catch(Exception e){
217             LOG.error("Retrieval of endpoint of for dpn {} failed due to {}" ,input.getDpid(), e);
218             rpcResultBuilder = RpcResultBuilder.failed();
219         }
220         return Futures.immediateFuture(rpcResultBuilder.build());
221     }
222
223     @Override
224     public Future<RpcResult<GetEgressInstructionsForInterfaceOutput>> getEgressInstructionsForInterface(GetEgressInstructionsForInterfaceInput input) {
225         RpcResultBuilder<GetEgressInstructionsForInterfaceOutput> rpcResultBuilder;
226         try {
227             List<InstructionInfo> instructionInfo = new ArrayList<InstructionInfo>();
228             List<ActionInfo> actionInfo = getEgressActionInfosForInterface(input.getIntfName());
229             instructionInfo.add(new InstructionInfo(InstructionType.write_actions, actionInfo));
230                     GetEgressInstructionsForInterfaceOutputBuilder output = new GetEgressInstructionsForInterfaceOutputBuilder().
231                     setInstruction(buildInstructions(instructionInfo));
232             rpcResultBuilder = RpcResultBuilder.success();
233             rpcResultBuilder.withResult(output.build());
234         }catch(Exception e){
235             LOG.error("Retrieval of egress actions for the key {} failed due to {}" ,input.getIntfName(), e);
236             rpcResultBuilder = RpcResultBuilder.failed();
237         }
238         return Futures.immediateFuture(rpcResultBuilder.build());
239     }
240
241     @Override
242     public Future<RpcResult<GetInterfaceTypeOutput>> getInterfaceType(GetInterfaceTypeInput input) {
243         String interfaceName = input.getIntfName();
244         RpcResultBuilder<GetInterfaceTypeOutput> rpcResultBuilder;
245         try {
246             InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
247             Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
248
249             GetInterfaceTypeOutputBuilder output = new GetInterfaceTypeOutputBuilder().setInterfaceType(interfaceInfo.getType());
250             rpcResultBuilder = RpcResultBuilder.success();
251             rpcResultBuilder.withResult(output.build());
252         } catch (Exception e) {
253             LOG.error("Retrieval of interface type for the key {} failed due to {}", interfaceName, e);
254             rpcResultBuilder = RpcResultBuilder.failed();
255         }
256         return Futures.immediateFuture(rpcResultBuilder.build());
257     }
258
259     @Override
260     public Future<RpcResult<GetEgressActionsForInterfaceOutput>> getEgressActionsForInterface(GetEgressActionsForInterfaceInput input) {
261         RpcResultBuilder<GetEgressActionsForInterfaceOutput> rpcResultBuilder;
262         try {
263             List<Action> actionsList = getEgressActionsForInterface(input.getIntfName());
264             GetEgressActionsForInterfaceOutputBuilder output = new GetEgressActionsForInterfaceOutputBuilder().
265                     setAction(actionsList);
266             rpcResultBuilder = RpcResultBuilder.success();
267             rpcResultBuilder.withResult(output.build());
268         }catch(Exception e){
269             LOG.error("Retrieval of egress actions for the key {} failed due to {}" ,input.getIntfName(), e);
270             rpcResultBuilder = RpcResultBuilder.failed();
271         }
272         return Futures.immediateFuture(rpcResultBuilder.build());
273     }
274
275     @Override
276     public Future<RpcResult<GetPortFromInterfaceOutput>> getPortFromInterface(GetPortFromInterfaceInput input) {
277         RpcResultBuilder<GetPortFromInterfaceOutput> rpcResultBuilder;
278         String interfaceName = input.getIntfName();
279         try {
280             BigInteger dpId = null;
281             long portNo = 0;
282             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
283                         InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
284             String lowerLayerIf = ifState.getLowerLayerIf().get(0);
285             NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
286             dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
287             portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
288             // FIXME Assuming portName and interfaceName are same
289             GetPortFromInterfaceOutputBuilder output = new GetPortFromInterfaceOutputBuilder().setDpid(dpId).
290                     setPortname(interfaceName).setPortno(Long.valueOf(portNo));
291             rpcResultBuilder = RpcResultBuilder.success();
292             rpcResultBuilder.withResult(output.build());
293         }catch(Exception e){
294             LOG.error("Retrieval of lport tag for the key {} failed due to {}" ,input.getIntfName(), e);
295             rpcResultBuilder = RpcResultBuilder.failed();
296         }
297         return Futures.immediateFuture(rpcResultBuilder.build());
298     }
299
300     @Override
301     public Future<RpcResult<GetNodeconnectorIdFromInterfaceOutput>> getNodeconnectorIdFromInterface(GetNodeconnectorIdFromInterfaceInput input) {
302         String interfaceName = input.getIntfName();
303         RpcResultBuilder<GetNodeconnectorIdFromInterfaceOutput> rpcResultBuilder;
304         try {
305             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
306                     InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
307             String lowerLayerIf = ifState.getLowerLayerIf().get(0);
308             NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
309
310             GetNodeconnectorIdFromInterfaceOutputBuilder output = new GetNodeconnectorIdFromInterfaceOutputBuilder().setNodeconnectorId(nodeConnectorId);
311             rpcResultBuilder = RpcResultBuilder.success();
312             rpcResultBuilder.withResult(output.build());
313         } catch (Exception e) {
314             LOG.error("Retrieval of nodeconnector id for the key {} failed due to {}", interfaceName, e);
315             rpcResultBuilder = RpcResultBuilder.failed();
316         }
317         return Futures.immediateFuture(rpcResultBuilder.build());
318     }
319
320     @Override
321     public Future<RpcResult<GetInterfaceFromIfIndexOutput>> getInterfaceFromIfIndex(GetInterfaceFromIfIndexInput input) {
322         Integer ifIndex = input.getIfIndex();
323         RpcResultBuilder<GetInterfaceFromIfIndexOutput> rpcResultBuilder = null;
324         try {
325             InstanceIdentifier<IfIndexInterface> id = InstanceIdentifier.builder(IfIndexesInterfaceMap.class).child(IfIndexInterface.class, new IfIndexInterfaceKey(ifIndex)).build();
326             Optional<IfIndexInterface> ifIndexesInterface = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
327             if(ifIndexesInterface.isPresent()) {
328                 String interfaceName = ifIndexesInterface.get().getInterfaceName();
329                 GetInterfaceFromIfIndexOutputBuilder output = new GetInterfaceFromIfIndexOutputBuilder().setInterfaceName(interfaceName);
330                 rpcResultBuilder = RpcResultBuilder.success();
331                 rpcResultBuilder.withResult(output.build());
332             }
333         } catch (Exception e) {
334             LOG.error("Retrieval of interfaceName for the key {} failed due to {}", ifIndex, e);
335             rpcResultBuilder = RpcResultBuilder.failed();
336         }
337         return Futures.immediateFuture(rpcResultBuilder.build());
338     }
339
340     public List<ActionInfo> getEgressActionInfosForInterface(String interfaceName) {
341         Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName),
342                 dataBroker);
343         List<ActionInfo> listActionInfo = new ArrayList<ActionInfo>();
344         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
345                 InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
346
347         String lowerLayerIf = ifState.getLowerLayerIf().get(0);
348         NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
349         String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
350         Class<? extends InterfaceType> ifType = interfaceInfo.getType();
351         if(L2vlan.class.equals(ifType)){
352             IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
353             LOG.trace("L2Vlan: {}",vlanIface);
354             long vlanVid = (vlanIface == null) ? 0 : vlanIface.getVlanId().getValue();
355             if (vlanVid != 0) {
356                 listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[] {}));
357                 listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
358                         new String[] { Long.toString(vlanVid) }));
359             }
360             listActionInfo.add(new ActionInfo(ActionType.output, new String[] {portNo}));
361         }else if(Tunnel.class.equals(ifType)){
362             listActionInfo.add(new ActionInfo(ActionType.output, new String[] { portNo}));
363         }
364         return listActionInfo;
365     }
366
367     public List<Action> getEgressActionsForInterface(String interfaceName) {
368             List<ActionInfo> listActionInfo = getEgressActionInfosForInterface(interfaceName);
369             List<Action> actionsList = new ArrayList<>();
370             for (ActionInfo actionInfo : listActionInfo) {
371                 actionsList.add(actionInfo.buildAction());
372             }
373             return actionsList;
374     }
375
376     protected static List<Instruction> buildInstructions(List<InstructionInfo> listInstructionInfo) {
377         if (listInstructionInfo != null) {
378             List<Instruction> instructions = new ArrayList<Instruction>();
379             int instructionKey = 0;
380
381             for (InstructionInfo instructionInfo : listInstructionInfo) {
382                 instructions.add(instructionInfo.buildInstruction(instructionKey));
383                 instructionKey++;
384             }
385             return instructions;
386         }
387
388         return null;
389     }
390
391     private String getFlowRef(BigInteger dpnId, short tableId, BigInteger tunnelKey) {
392         return new StringBuffer().append(IfmConstants.TUNNEL_TABLE_FLOWID_PREFIX).append(dpnId).append(NwConstants.FLOWID_SEPARATOR)
393                 .append(tableId).append(NwConstants.FLOWID_SEPARATOR).append(tunnelKey).toString();
394     }
395 }