@Immutable FlowEntity
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / MDSALUtil.java
index 949050c0f36c3e3df186b4ad344d572be32b2a8d..ebbf828a0d86bb9319279fa5e8523677196b6e04 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.genius.mdsalutil;
 
 import com.google.common.base.Optional;
+import com.google.common.net.InetAddresses;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -20,6 +21,8 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
+import org.opendaylight.genius.mdsalutil.actions.ActionDrop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
@@ -93,6 +96,8 @@ import org.slf4j.LoggerFactory;
 @SuppressWarnings("checkstyle:AbbreviationAsWordInName")
 public class MDSALUtil {
 
+    private static final Logger LOG = LoggerFactory.getLogger(MDSALUtil.class);
+
     public enum MdsalOp {  CREATION_OP, UPDATE_OP, REMOVAL_OP }
 
     public static final String NODE_PREFIX = "openflow";
@@ -100,34 +105,37 @@ public class MDSALUtil {
     public static final long WATCH_PORT = 0xffffffffL;
     public static final long WATCH_GROUP = 0xffffffffL;
     public static final String SEPARATOR = ":";
-    private static final Buckets EMPTY_Buckets = new BucketsBuilder().build();
-    private static final Instructions EMPTY_Instructions = new InstructionsBuilder().setInstruction(
+    private static final Buckets EMPTY_BUCKETS = new BucketsBuilder().build();
+    private static final Instructions EMPTY_INSTRUCTIONS = new InstructionsBuilder().setInstruction(
             new ArrayList<>()).build();
-    private static final Match EMPTY_Matches = new MatchBuilder().build();
-    private static final Logger logger = LoggerFactory.getLogger(MDSALUtil.class);
-
-    public static FlowEntity buildFlowEntity(BigInteger dpnId, short tableId, String flowId, int priority, String flowName,
-            int idleTimeOut, int hardTimeOut, BigInteger cookie, List<? extends MatchInfoBase>  listMatchInfoBase,
-            List<InstructionInfo> listInstructionInfo) {
-
-        FlowEntity flowEntity = new FlowEntity(dpnId);
-
-        flowEntity.setTableId(tableId);
-        flowEntity.setFlowId(flowId);
-        flowEntity.setPriority(priority);
-        flowEntity.setFlowName(flowName);
-        flowEntity.setIdleTimeOut(idleTimeOut);
-        flowEntity.setHardTimeOut(hardTimeOut);
-        flowEntity.setCookie(cookie);
-        flowEntity.setMatchInfoList(listMatchInfoBase);
-        flowEntity.setInstructionInfoList(listInstructionInfo);
-
-        return flowEntity;
+    private static final Match EMPTY_MATCHES = new MatchBuilder().build();
+
+    public static FlowEntity buildFlowEntity(BigInteger dpnId, short tableId, String flowId, int priority,
+            String flowName, int idleTimeOut, int hardTimeOut, BigInteger cookie,
+            List<? extends MatchInfoBase> listMatchInfoBase, List<InstructionInfo> listInstructionInfo) {
+
+        FlowEntityBuilder builder = new FlowEntityBuilder()
+            .setDpnId(dpnId)
+            .setTableId(tableId)
+            .setFlowId(flowId)
+            .setPriority(priority)
+            .setFlowName(flowName)
+            .setIdleTimeOut(idleTimeOut)
+            .setHardTimeOut(hardTimeOut)
+            .setCookie(cookie);
+        if (listMatchInfoBase != null) {
+            builder.addAllMatchInfoList(listMatchInfoBase);
+        }
+        if (listInstructionInfo != null) {
+            builder.addAllInstructionInfoList(listInstructionInfo);
+        }
+        return builder.build();
     }
 
     // TODO: CHECK IF THIS IS USED
     public static Flow buildFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
-            int hardTimeOut, BigInteger cookie, List<? extends MatchInfoBase> listMatchInfoBase, List<InstructionInfo> listInstructionInfo) {
+            int hardTimeOut, BigInteger cookie, List<? extends MatchInfoBase> listMatchInfoBase,
+            List<InstructionInfo> listInstructionInfo) {
         return MDSALUtil.buildFlow(tableId, flowId, priority, flowName, idleTimeOut, hardTimeOut, cookie,
                 listMatchInfoBase, listInstructionInfo, true);
     }
@@ -148,7 +156,8 @@ public class MDSALUtil {
     }
 
     public static Flow buildFlowNew(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
-                                 int hardTimeOut, BigInteger cookie, List<? extends MatchInfoBase>  listMatchInfoBase, List<Instruction> listInstructionInfo) {
+            int hardTimeOut, BigInteger cookie, List<? extends MatchInfoBase> listMatchInfoBase,
+            List<Instruction> listInstructionInfo) {
         return MDSALUtil.buildFlowNew(tableId, flowId, priority, flowName, idleTimeOut, hardTimeOut, cookie,
                 listMatchInfoBase, listInstructionInfo, true);
     }
@@ -158,7 +167,8 @@ public class MDSALUtil {
                                   List<Instruction> listInstructionInfo, boolean isStrict) {
         FlowKey key = new FlowKey(new FlowId(flowId));
         return new FlowBuilder().setMatch(buildMatches(listMatchInfoBase)).setKey(key)
-                .setPriority(priority).setInstructions(new InstructionsBuilder().setInstruction(listInstructionInfo).build())
+                .setPriority(priority)
+                .setInstructions(new InstructionsBuilder().setInstruction(listInstructionInfo).build())
                 .setBarrier(false).setInstallHw(true).setHardTimeout(hardTimeOut).setIdleTimeout(idleTimeOut)
                 .setFlowName(flowName).setTableId(tableId).setStrict(isStrict)
                 .setCookie(new FlowCookie(cookie)).build();
@@ -179,11 +189,12 @@ public class MDSALUtil {
 
     public static Group buildGroup(long groupId, String groupName, GroupTypes groupType, Buckets buckets) {
         GroupId groupIdentifier = new GroupId(groupId);
-        return new GroupBuilder().setGroupId(groupIdentifier).setKey(new GroupKey(groupIdentifier)).setGroupName(groupName)
-                .setGroupType(groupType).setBuckets(buckets).build();
+        return new GroupBuilder().setGroupId(groupIdentifier).setKey(new GroupKey(groupIdentifier))
+                .setGroupName(groupName).setGroupType(groupType).setBuckets(buckets).build();
     }
 
-    public static TransmitPacketInput getPacketOutDefault(List<ActionInfo> actionInfos, byte[] payload, BigInteger dpnId) {
+    public static TransmitPacketInput getPacketOutDefault(List<ActionInfo> actionInfos, byte[] payload,
+            BigInteger dpnId) {
         return new TransmitPacketInputBuilder()
                 .setAction(buildActions(actionInfos))
                 .setPayload(payload)
@@ -215,6 +226,23 @@ public class MDSALUtil {
                 .setIngress(ingress).setEgress(ingress).build();
     }
 
+    public static TransmitPacketInput getPacketOut(List<ActionInfo> actionInfos, byte[] payload, BigInteger dpnId,
+            NodeConnectorRef nodeConnRef) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public static TransmitPacketInput getPacketOut(List<Action> actions, byte[] payload, BigInteger dpnId) {
+        NodeConnectorRef ncRef = getDefaultNodeConnRef(dpnId);
+        return new TransmitPacketInputBuilder()
+                .setAction(actions)
+                .setPayload(payload)
+                .setNode(
+                        new NodeRef(InstanceIdentifier.builder(Nodes.class)
+                                .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance()))
+                .setIngress(ncRef).setEgress(ncRef).build();
+    }
+
     public static Action retrieveSetTunnelIdAction(BigInteger tunnelId, int actionKey) {
         return new ActionBuilder().setAction(
                 new SetFieldCaseBuilder().setSetField(new SetFieldBuilder().setTunnel(new TunnelBuilder()
@@ -231,18 +259,25 @@ public class MDSALUtil {
     }
 
     public static String longToIp(long ip, long mask) {
-        return ((ip & 0xFF000000) >> 3 * 8) + "." +
-               ((ip & 0x00FF0000) >> 2 * 8) + "." +
-               ((ip & 0x0000FF00) >>     8) + "." +
-                (ip & 0x000000FF) +
-                (mask == 0 ? "" : "/" + mask);
+        return ((ip & 0xFF000000) >> 3 * 8) + "."
+               + ((ip & 0x00FF0000) >> 2 * 8) + "."
+               + ((ip & 0x0000FF00) >>     8) + "."
+               + (ip & 0x000000FF)
+               + (mask == 0 ? "" : "/" + mask);
     }
 
+    public static BigInteger getBigIntIpFromIpAddress(IpAddress ipAddr) {
+        String ipString = ipAddr.getIpv4Address().getValue();
+        int ipInt = InetAddresses.coerceToInteger(InetAddresses.forString(ipString));
+        return BigInteger.valueOf(ipInt & 0xffffffffL);
+    }
 
-    public static Bucket buildBucket(List<Action> actionsList, int weight, int bucketId, long watchPort, long watchGroup) {
-        return  new BucketBuilder().setAction(actionsList).setWeight(weight)
-                .setWatchGroup(watchGroup).setWatchPort(watchPort).setBucketId(new BucketId(Long.valueOf(bucketId))).setKey(new BucketKey(new BucketId(Long.valueOf(bucketId)))).build();
 
+    public static Bucket buildBucket(List<Action> actionsList, int weight, int bucketId, long watchPort,
+            long watchGroup) {
+        return new BucketBuilder().setAction(actionsList).setWeight(weight).setWatchGroup(watchGroup)
+                .setWatchPort(watchPort).setBucketId(new BucketId(Long.valueOf(bucketId)))
+                .setKey(new BucketKey(new BucketId(Long.valueOf(bucketId)))).build();
     }
 
     public static Buckets buildBucketLists(List<Bucket> bucketList) {
@@ -250,7 +285,7 @@ public class MDSALUtil {
     }
 
     protected static Buckets buildBuckets(List<BucketInfo> listBucketInfo) {
-        long i = 0;
+        long index = 0;
         if (listBucketInfo != null) {
             BucketsBuilder bucketsBuilder = new BucketsBuilder();
             List<Bucket> bucketList = new ArrayList<>();
@@ -259,7 +294,7 @@ public class MDSALUtil {
                 BucketBuilder bucketBuilder = new BucketBuilder();
                 bucketBuilder.setAction(bucketInfo.buildActions());
                 bucketBuilder.setWeight(bucketInfo.getWeight());
-                bucketBuilder.setBucketId(new BucketId(i++));
+                bucketBuilder.setBucketId(new BucketId(index++));
                 bucketBuilder.setWeight(bucketInfo.getWeight()).setWatchPort(bucketInfo.getWatchPort())
                         .setWatchGroup(bucketInfo.getWatchGroup());
                 bucketList.add(bucketBuilder.build());
@@ -269,7 +304,7 @@ public class MDSALUtil {
             return bucketsBuilder.build();
         }
 
-        return EMPTY_Buckets;
+        return EMPTY_BUCKETS;
     }
 
     public static Instructions buildInstructions(List<InstructionInfo> listInstructionInfo) {
@@ -285,7 +320,7 @@ public class MDSALUtil {
             return new InstructionsBuilder().setInstruction(instructions).build();
         }
 
-        return EMPTY_Instructions;
+        return EMPTY_INSTRUCTIONS;
     }
 
     public static Match buildMatches(List<? extends MatchInfoBase> listMatchInfoBase) {
@@ -293,61 +328,46 @@ public class MDSALUtil {
             MatchBuilder matchBuilder = new MatchBuilder();
             Map<Class<?>, Object> mapMatchBuilder = new HashMap<>();
 
-            for (MatchInfoBase MatchInfoBase : listMatchInfoBase) {
-                MatchInfoBase.createInnerMatchBuilder(mapMatchBuilder);
+            for (MatchInfoBase matchInfoBase : listMatchInfoBase) {
+                matchInfoBase.createInnerMatchBuilder(mapMatchBuilder);
             }
 
-            for (MatchInfoBase MatchInfoBase : listMatchInfoBase) {
-                MatchInfoBase.setMatch(matchBuilder, mapMatchBuilder);
+            for (MatchInfoBase matchInfoBase : listMatchInfoBase) {
+                matchInfoBase.setMatch(matchBuilder, mapMatchBuilder);
             }
 
             return matchBuilder.build();
         }
 
-        return EMPTY_Matches;
+        return EMPTY_MATCHES;
     }
 
     // TODO: Check the port const
-    public static NodeConnectorRef getDefaultNodeConnRef(BigInteger nDpId) {
-        return getNodeConnRef(NODE_PREFIX + SEPARATOR + nDpId, "0xfffffffd");
-    }
-
-    public static NodeConnectorRef getNodeConnRef(BigInteger nDpId, String port) {
-        return getNodeConnRef(NODE_PREFIX + SEPARATOR + nDpId, port);
-    }
-
-    public static NodeConnectorRef getNodeConnRef(String sNodeId, String port) {
-        String sNodeConnectorKey;
-        StringBuilder sbTmp;
-        NodeId nodeId;
-        NodeKey nodeKey;
-        NodeConnectorId nodeConnectorId;
-        NodeConnectorKey nodeConnectorKey;
-        InstanceIdentifierBuilder<Nodes> nodesInstanceIdentifierBuilder;
-        InstanceIdentifierBuilder<Node> nodeInstanceIdentifierBuilder;
-        InstanceIdentifierBuilder<NodeConnector> nodeConnectorInstanceIdentifierBuilder;
-        InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier;
-        NodeConnectorRef nodeConnectorRef;
-
-        sbTmp = new StringBuilder();
-
-        sbTmp.append(sNodeId);
-        sbTmp.append(SEPARATOR);
-        sbTmp.append(port);
-
-        sNodeConnectorKey = sbTmp.toString();
-        nodeConnectorId = new NodeConnectorId(sNodeConnectorKey);
-        nodeConnectorKey = new NodeConnectorKey(nodeConnectorId);
-
-        nodeId = new NodeId(sNodeId);
-        nodeKey = new NodeKey(nodeId);
-
-        nodesInstanceIdentifierBuilder = InstanceIdentifier.builder(Nodes.class);
-        nodeInstanceIdentifierBuilder = nodesInstanceIdentifierBuilder.child(Node.class, nodeKey);
-        nodeConnectorInstanceIdentifierBuilder = nodeInstanceIdentifierBuilder.child(
-                NodeConnector.class, nodeConnectorKey);
-        nodeConnectorInstanceIdentifier = nodeConnectorInstanceIdentifierBuilder.toInstance();
-        nodeConnectorRef = new NodeConnectorRef(nodeConnectorInstanceIdentifier);
+    public static NodeConnectorRef getDefaultNodeConnRef(BigInteger dpId) {
+        return getNodeConnRef(NODE_PREFIX + SEPARATOR + dpId, "0xfffffffd");
+    }
+
+    public static NodeConnectorRef getNodeConnRef(BigInteger dpId, String port) {
+        return getNodeConnRef(NODE_PREFIX + SEPARATOR + dpId, port);
+    }
+
+    public static NodeConnectorRef getNodeConnRef(String nodeId, String port) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(nodeId);
+        sb.append(SEPARATOR);
+        sb.append(port);
+        String nodeConnectorKeyAsString = sb.toString();
+        NodeConnectorId nodeConnectorId = new NodeConnectorId(nodeConnectorKeyAsString);
+        NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(nodeConnectorId);
+
+        NodeKey nodeKey = new NodeKey(new NodeId(nodeId));
+        InstanceIdentifierBuilder<Node> nodeInstanceIdentifierBuilder
+            = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey);
+        InstanceIdentifierBuilder<NodeConnector> nodeConnectorInstanceIdentifierBuilder
+            = nodeInstanceIdentifierBuilder.child(NodeConnector.class, nodeConnectorKey);
+        InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier
+            = nodeConnectorInstanceIdentifierBuilder.toInstance();
+        NodeConnectorRef nodeConnectorRef = new NodeConnectorRef(nodeConnectorInstanceIdentifier);
         return nodeConnectorRef;
     }
 
@@ -355,34 +375,40 @@ public class MDSALUtil {
         return getDpnIdFromNodeName(nodeId.getValue());
     }
 
-    public static BigInteger getDpnIdFromNodeName(String sMdsalNodeName) {
-        String sDpId = sMdsalNodeName.substring(sMdsalNodeName.lastIndexOf(":") + 1);
-        return new BigInteger(sDpId);
+    public static BigInteger getDpnIdFromNodeName(String mdsalNodeName) {
+        String dpId = mdsalNodeName.substring(mdsalNodeName.lastIndexOf(":") + 1);
+        return new BigInteger(dpId);
     }
 
     public static long getOfPortNumberFromPortName(NodeConnectorId nodeConnectorId) {
         return getOfPortNumberFromPortName(nodeConnectorId.getValue());
     }
 
+    public static long getOfPortNumberFromPortName(String mdsalPortName) {
+        String portNumber = mdsalPortName.substring(mdsalPortName.lastIndexOf(":") + 1);
+        return Long.parseLong(portNumber);
+    }
+
     public static long getDpnIdFromPortName(NodeConnectorId nodeConnectorId) {
+        if (nodeConnectorId == null || nodeConnectorId.getValue() == null) {
+            return -1;
+        }
         try {
             String ofPortName = nodeConnectorId.getValue();
-            return Long.parseLong(ofPortName.substring(ofPortName.indexOf(":")+1,
+            return Long.parseLong(ofPortName.substring(ofPortName.indexOf(":") + 1,
                     ofPortName.lastIndexOf(":")));
-        } catch (Exception e) {
-            logger.error("NodeConnectorId not of expected format openflow:dpnid:portnum");
+        } catch (NumberFormatException | IndexOutOfBoundsException e) {
+            LOG.error("NodeConnectorId not of expected format openflow:dpnid:portnum");
             return -1;
         }
     }
 
-    public static long getOfPortNumberFromPortName(String sMdsalPortName) {
-        String sPortNumber = sMdsalPortName.substring(sMdsalPortName.lastIndexOf(":") + 1);
-        return Long.parseLong(sPortNumber);
-    }
-
-    public static TransmitPacketInput getPacketOut(List<ActionInfo> actionInfos, byte[] payload, BigInteger dpnId,
-                    NodeConnectorRef nodeConnRef) {
-        // TODO Auto-generated method stub
+    public static BigInteger getDpnId(String datapathId) {
+        if (datapathId != null) {
+            String dpIdStr = datapathId.replace(":", "");
+            BigInteger dpnId =  new BigInteger(dpIdStr, 16);
+            return dpnId;
+        }
         return null;
     }
 
@@ -390,7 +416,7 @@ public class MDSALUtil {
         Action popVlanAction = new ActionBuilder().setAction(
                 new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build())
                 .setKey(new ActionKey(actionKey)).build();
-        List<Action> listAction = new ArrayList<> ();
+        List<Action> listAction = new ArrayList<>();
         listAction.add(popVlanAction);
         return buildApplyActionsInstruction(listAction, instructionKey);
     }
@@ -406,9 +432,10 @@ public class MDSALUtil {
         nxRegLoadBuilder.setDst(dst);
         nxRegLoadBuilder.setValue(new BigInteger(Long.toString(value)));
         ActionBuilder ab = new ActionBuilder();
-        ab.setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(nxRegLoadBuilder.build()).build());
+        ab.setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder()
+                .setNxRegLoad(nxRegLoadBuilder.build()).build());
         ab.setKey(new ActionKey(actionKey));
-        List<Action> listAction = new ArrayList<> ();
+        List<Action> listAction = new ArrayList<>();
         listAction.add(ab.build());
         return buildApplyActionsInstruction(listAction, instructionKey);
     }
@@ -417,16 +444,6 @@ public class MDSALUtil {
         return buildApplyActionsInstruction(actions, 0);
     }
 
-    public static Instruction buildWriteActionsInstruction(List<Action> actions) {
-        WriteActions writeActions = new WriteActionsBuilder().setAction(actions).build();
-        WriteActionsCase writeActionsCase = new WriteActionsCaseBuilder().setWriteActions(writeActions).build();
-        InstructionBuilder instructionBuilder = new InstructionBuilder();
-
-        instructionBuilder.setInstruction(writeActionsCase);
-        instructionBuilder.setKey(new InstructionKey(0));
-        return instructionBuilder.build();
-    }
-
     public static Instruction buildApplyActionsInstruction(List<Action> listAction, int instructionKey) {
         ApplyActions applyActions = new ApplyActionsBuilder().setAction(listAction).build();
         ApplyActionsCase applyActionsCase = new ApplyActionsCaseBuilder().setApplyActions(applyActions).build();
@@ -437,6 +454,16 @@ public class MDSALUtil {
         return instructionBuilder.build();
     }
 
+    public static Instruction buildWriteActionsInstruction(List<Action> actions) {
+        WriteActions writeActions = new WriteActionsBuilder().setAction(actions).build();
+        WriteActionsCase writeActionsCase = new WriteActionsCaseBuilder().setWriteActions(writeActions).build();
+        InstructionBuilder instructionBuilder = new InstructionBuilder();
+
+        instructionBuilder.setInstruction(writeActionsCase);
+        instructionBuilder.setKey(new InstructionKey(0));
+        return instructionBuilder.build();
+    }
+
     public static List<Instruction> buildInstructionsDrop() {
         return buildInstructionsDrop(0);
     }
@@ -444,7 +471,7 @@ public class MDSALUtil {
     public static List<Instruction> buildInstructionsDrop(int instructionKey) {
         List<Instruction> mkInstructions = new ArrayList<>();
         List<Action> actionsInfos = new ArrayList<>();
-        actionsInfos.add(new ActionInfo(ActionType.drop_action, new String[]{}).buildAction());
+        actionsInfos.add(new ActionDrop().buildAction());
         mkInstructions.add(getWriteActionsInstruction(actionsInfos, instructionKey));
         return mkInstructions;
     }
@@ -514,7 +541,8 @@ public class MDSALUtil {
      * Deprecated write.
      *
      * @deprecated Use
-     *             {@link SingleTransactionDataBroker#syncWrite(DataBroker, LogicalDatastoreType, InstanceIdentifier, DataObject)}
+     *             {@link SingleTransactionDataBroker#syncWrite(
+     *                     DataBroker, LogicalDatastoreType, InstanceIdentifier, DataObject)}
      */
     @Deprecated
     public static <T extends DataObject> void syncWrite(DataBroker broker,
@@ -523,7 +551,7 @@ public class MDSALUtil {
         try {
             SingleTransactionDataBroker.syncWrite(broker, datastoreType, path, data);
         } catch (TransactionCommitFailedException e) {
-            logger.error("Error writing to datastore (path, data) : ({}, {})", path, data);
+            LOG.error("Error writing to datastore (path, data) : ({}, {})", path, data);
             throw new RuntimeException(e);
         }
     }
@@ -532,7 +560,8 @@ public class MDSALUtil {
      * Deprecated update.
      *
      * @deprecated Use
-     *             {@link SingleTransactionDataBroker#syncUpdate(DataBroker, LogicalDatastoreType, InstanceIdentifier, DataObject)}
+     *             {@link SingleTransactionDataBroker#syncUpdate(
+     *                          DataBroker, LogicalDatastoreType, InstanceIdentifier, DataObject)}
      */
     @Deprecated
     public static <T extends DataObject> void syncUpdate(DataBroker broker,
@@ -541,7 +570,7 @@ public class MDSALUtil {
         try {
             SingleTransactionDataBroker.syncUpdate(broker, datastoreType, path, data);
         } catch (TransactionCommitFailedException e) {
-            logger.error("Error writing to datastore (path, data) : ({}, {})", path, data);
+            LOG.error("Error writing to datastore (path, data) : ({}, {})", path, data);
             throw new RuntimeException(e);
         }
     }
@@ -558,7 +587,7 @@ public class MDSALUtil {
         try {
             SingleTransactionDataBroker.syncDelete(broker, datastoreType, path);
         } catch (TransactionCommitFailedException e) {
-            logger.error("Error deleting from datastore (path) : ({})", path, e);
+            LOG.error("Error deleting from datastore (path) : ({})", path, e);
             throw new RuntimeException(e);
         }
     }
@@ -567,7 +596,7 @@ public class MDSALUtil {
             InstanceIdentifier<NodeConnector> nodeConnectorId)  {
         Optional<NodeConnector> optNc = MDSALDataStoreUtils.read(broker,
                 LogicalDatastoreType.OPERATIONAL, nodeConnectorId);
-        if(optNc.isPresent()) {
+        if (optNc.isPresent()) {
             NodeConnector nc = optNc.get();
             FlowCapableNodeConnector fcnc = nc.getAugmentation(FlowCapableNodeConnector.class);
             MacAddress macAddress = fcnc.getHardwareAddress();
@@ -590,7 +619,7 @@ public class MDSALUtil {
                 .child(NodeConnector.class,
                         new NodeConnectorKey(nodeConnectorId)).build();
         return read(dataBroker, LogicalDatastoreType.OPERATIONAL, ncIdentifier).transform(
-                nc -> nc.getAugmentation(FlowCapableNodeConnector.class).getName()).orNull();
+            nc -> nc.getAugmentation(FlowCapableNodeConnector.class).getName()).orNull();
     }
 
     public static NodeConnectorId getNodeConnectorId(DataBroker dataBroker,
@@ -599,25 +628,15 @@ public class MDSALUtil {
                 NodeConnector::getId).orNull();
     }
 
-    public static TransmitPacketInput getPacketOut(List<Action> actions, byte[] payload, BigInteger dpnId) {
-        NodeConnectorRef ncRef = getDefaultNodeConnRef(dpnId);
-        return new TransmitPacketInputBuilder()
-                .setAction(actions)
-                .setPayload(payload)
-                .setNode(
-                        new NodeRef(InstanceIdentifier.builder(Nodes.class)
-                                .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance()))
-                .setIngress(ncRef).setEgress(ncRef).build();
-    }
-
     public static Action createNxOfInPortAction(final int actionKey, final int inPortVal) {
-
-        NxRegLoad r = new NxRegLoadBuilder().setDst(new DstBuilder().setDstChoice(new DstNxOfInPortCaseBuilder().setOfInPort(Boolean.TRUE).build())
-                .setStart(0).setEnd(15).build()).setValue(BigInteger.valueOf(inPortVal)).build();
+        NxRegLoad regLoad = new NxRegLoadBuilder()
+                .setDst(new DstBuilder().setDstChoice(new DstNxOfInPortCaseBuilder().setOfInPort(Boolean.TRUE).build())
+                        .setStart(0).setEnd(15).build())
+                .setValue(BigInteger.valueOf(inPortVal)).build();
         ActionBuilder abExt = new ActionBuilder();
         abExt.setKey(new ActionKey(actionKey));
         abExt.setOrder(actionKey);
-        abExt.setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(r).build());
+        abExt.setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(regLoad).build());
         return abExt.build();
     }