Adding FlowRef,MeterRef and GroupRef for the Error message 87/4587/18
authorP Govinda Rajulu <p.govinda.rajulu@ericsson.com>
Fri, 7 Mar 2014 12:33:40 +0000 (18:03 +0530)
committerP Govinda Rajulu <p.govinda.rajulu@ericsson.com>
Fri, 7 Mar 2014 14:16:24 +0000 (19:46 +0530)
Signed-off-by: P Govinda Rajulu <p.govinda.rajulu@ericsson.com>
Change-Id: Ief43d18b2e45dac2bf8f38c226407247d1e3fb4b

15 files changed:
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/SessionContext.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/SessionContextOFImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/TransactionKey.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/AbstractDPNEntity.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/ErrorTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/FlowEntityData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/GroupEntityData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MeterEntityData.java [new file with mode: 0644]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/session/MessageDispatchServiceImplTest.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java [new file with mode: 0644]
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java [new file with mode: 0644]
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestActivator.xtend

index 100eaf94ab27492485ad75f6b66030b8a9c48a6e..1aac6133bda25142e76c72646d663cf52d582581 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.Matc
 import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.core.session.TransactionKey;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
@@ -238,6 +239,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(newFlow.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput.build(), cookie);
         RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null;
 
@@ -293,6 +295,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(groupMod.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput.build(), cookie);
         RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null;
 
@@ -346,6 +349,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(meterMod.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput.build(), cookie);
 
         RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null;
@@ -401,6 +405,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(removeFlow.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput.build(), cookie);
 
         RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null;
@@ -457,6 +462,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(groupMod.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput.build(), cookie);
 
         RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null;
@@ -511,6 +517,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(meterMod.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput.build(), cookie);
 
         RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null;
@@ -608,6 +615,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(updateFlow.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput.build(), cookie);
 
         RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null;
@@ -663,6 +671,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(groupMod.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput.build(), cookie);
 
         RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null;
@@ -716,6 +725,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
             rpcNotificationProviderService.publish(meterMod.build());
         }
 
+        session.getbulkTransactionCache().put(new TransactionKey(xId), input);
         Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput.build(), cookie);
 
         RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null;
index b1b5aa4ab81c2bfafe4f61eb18f29d920f13182f..09c3d94e775f45cd4b349819947c599929d84237 100644 (file)
@@ -13,6 +13,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
+import com.google.common.cache.Cache;
 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
@@ -94,6 +95,11 @@ public interface SessionContext {
      * @return The Set of port ID
      */
     public Set<Long> getPorts();
+    
+    /**
+     * @return the Object for this session xId
+     */
+    public Cache<TransactionKey, Object> getbulkTransactionCache();
 
     /**
      * Returns OFPhysicalPort of the specified portNumber of this switch.
index bef5201d4663b6cbe87300a744ce7fba1cd9cf53..4c42c7f09ac005d55f3dc4083e1db7941248d5af 100644 (file)
@@ -18,6 +18,9 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import java.util.concurrent.TimeUnit;
 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
@@ -37,6 +40,8 @@ public class SessionContextOFImpl implements SessionContext {
     private final AtomicLong xid;
     private final Map<Long, PortGrouping> physicalPorts;
     private final Map<Long, Boolean> portBandwidth;
+    public static Cache<TransactionKey, Object> bulkTransactionCache = CacheBuilder.newBuilder().expireAfterWrite(10000, TimeUnit.MILLISECONDS).concurrencyLevel(1).build();
+
 
     /**
      * default ctor
@@ -71,6 +76,11 @@ public class SessionContextOFImpl implements SessionContext {
     public Set<Entry<SwitchConnectionDistinguisher, ConnectionConductor>> getAuxiliaryConductors() {
         return Collections.unmodifiableSet(auxiliaryConductors.entrySet());
     }
+    
+    @Override
+    public Cache<TransactionKey, Object> getbulkTransactionCache() {
+        return bulkTransactionCache;
+    }
 
     @Override
     public GetFeaturesOutput getFeatures() {
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/TransactionKey.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/TransactionKey.java
new file mode 100644 (file)
index 0000000..bb2fae9
--- /dev/null
@@ -0,0 +1,56 @@
+package org.opendaylight.openflowplugin.openflow.md.core.session;
+
+public class TransactionKey {
+
+    private static final long serialVersionUID = 7805731164917659700L;
+    final private Long _xId;
+
+    public TransactionKey(Long transactionId) {
+        this._xId = transactionId;
+    }
+
+    public Long getXId() {
+        return _xId;
+    }
+
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((_xId == null) ? 0 : _xId.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(java.lang.Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        TransactionKey other = (TransactionKey) obj;
+        if (_xId == null) {
+            if (other._xId != null) {
+                return false;
+            }
+        } else if (!_xId.equals(other._xId)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("TransactionId [_xId=");
+        builder.append(_xId);
+        builder.append("]");
+        return builder.toString();
+    }
+
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/AbstractDPNEntity.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/AbstractDPNEntity.java
new file mode 100644 (file)
index 0000000..b6230c6
--- /dev/null
@@ -0,0 +1,7 @@
+package org.opendaylight.openflowplugin.openflow.md.core.translator;
+
+public abstract class AbstractDPNEntity {
+
+    public abstract Object getBuilder(Object obj);
+
+}
index 8a26264fbe2e9bbd04a01feb6f5cc51a67ea5b03..dbdb8daf8500961e4dfc2424b22eff6e63517194 100644 (file)
@@ -15,11 +15,19 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.core.session.TransactionKey;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotificationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.node.error.notification.object.reference.FlowRefBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.node.error.notification.object.reference.GroupRefBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.node.error.notification.object.reference.MeterRefBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.NodeGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.NodeMeter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -47,6 +55,30 @@ public class ErrorTranslator implements IMDMessageTranslator<OfHeader, List<Data
 
             nodeErrBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(message.getXid())));
 
+            Object object = sc.getbulkTransactionCache().getIfPresent(new TransactionKey(message.getXid()));
+            if (object != null) {
+                nodeErrBuilder.setTransactionUri(((TransactionMetadata) object).getTransactionUri());
+                FlowRefBuilder flowRef = new FlowRefBuilder();
+                GroupRefBuilder groupRef = new GroupRefBuilder();
+                MeterRefBuilder meterRef = new MeterRefBuilder();
+                if (object instanceof NodeFlow) {
+                    FlowEntityData flowEntry = new FlowEntityData();
+                    flowRef = flowEntry.getBuilder(object);
+                    nodeErrBuilder.setObjectReference(flowRef.build());
+                } else if (object instanceof NodeGroup) {
+                    GroupEntityData groupEntry = new GroupEntityData();
+                    groupRef = groupEntry.getBuilder(object);
+                    nodeErrBuilder.setObjectReference(groupRef.build());
+
+                } else if (object instanceof NodeMeter) {
+                    MeterEntityData meterEntry = new MeterEntityData();
+                    meterRef = meterEntry.getBuilder(object);
+                    nodeErrBuilder.setObjectReference(meterRef.build());
+
+                }
+
+            }
+
             nodeErrBuilder.setType(ErrorType.forValue(message.getType()));
 
             nodeErrBuilder.setCode(message.getCode());
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/FlowEntityData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/FlowEntityData.java
new file mode 100644 (file)
index 0000000..384eede
--- /dev/null
@@ -0,0 +1,29 @@
+package org.opendaylight.openflowplugin.openflow.md.core.translator;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.node.error.notification.object.reference.FlowRefBuilder;
+
+public class FlowEntityData extends AbstractDPNEntity {
+
+    FlowRefBuilder flowRef = new FlowRefBuilder();
+
+    @Override
+    public FlowRefBuilder getBuilder(Object object) {
+        // TODO Auto-generated method stub
+        if (object instanceof AddFlowInput) {
+            AddFlowInput addFlowinput = ((AddFlowInput) object);
+            flowRef.setFlowRef(addFlowinput.getFlowRef());
+        } else if (object instanceof RemoveFlowInput) {
+
+            RemoveFlowInput removeFlowinput = ((RemoveFlowInput) object);
+            flowRef.setFlowRef(removeFlowinput.getFlowRef());
+        } else {
+            UpdateFlowInput updateFlowinput = ((UpdateFlowInput) object);
+            flowRef.setFlowRef(updateFlowinput.getFlowRef());
+        }
+        return flowRef;
+    }
+
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/GroupEntityData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/GroupEntityData.java
new file mode 100644 (file)
index 0000000..92e0640
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.openflowplugin.openflow.md.core.translator;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.node.error.notification.object.reference.GroupRefBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
+
+public class GroupEntityData extends AbstractDPNEntity {
+
+    GroupRefBuilder groupRef = new GroupRefBuilder();
+
+    @Override
+    public GroupRefBuilder getBuilder(Object object) {
+        // TODO Auto-generated method stub
+        if (object instanceof AddGroupInput) {
+            AddGroupInput addGroupinput = ((AddGroupInput) object);
+            groupRef.setGroupRef(addGroupinput.getGroupRef());
+        } else if (object instanceof UpdateGroupInput) {
+            UpdateGroupInput updateGroupinput = ((UpdateGroupInput) object);
+            groupRef.setGroupRef(updateGroupinput.getGroupRef());
+        } else {
+            RemoveGroupInput removeGroupinput = ((RemoveGroupInput) object);
+            groupRef.setGroupRef(removeGroupinput.getGroupRef());
+        }
+        return groupRef;
+    }
+
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MeterEntityData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MeterEntityData.java
new file mode 100644 (file)
index 0000000..e46d15a
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.openflowplugin.openflow.md.core.translator;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.node.error.notification.object.reference.MeterRefBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
+
+public class MeterEntityData extends AbstractDPNEntity {
+
+    MeterRefBuilder meterRef = new MeterRefBuilder();
+
+    @Override
+    public MeterRefBuilder getBuilder(Object object) {
+        // TODO Auto-generated method stub
+        if (object instanceof AddMeterInput) {
+            AddMeterInput addMeterinput = ((AddMeterInput) object);
+            meterRef.setMeterRef(addMeterinput.getMeterRef());
+        } else if (object instanceof UpdateMeterInput) {
+            UpdateMeterInput updateMeterinput = ((UpdateMeterInput) object);
+            meterRef.setMeterRef(updateMeterinput.getMeterRef());
+        } else {
+            RemoveMeterInput removeMeterinput = ((RemoveMeterInput) object);
+            meterRef.setMeterRef(removeMeterinput.getMeterRef());
+        }
+        return meterRef;
+    }
+
+}
index d20798b7835ae5cf41ca72101b1562c38a004627..92cfe5ec40c04d2c95e8182cdb53c86252322065 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -26,6 +27,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.core.session.TransactionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
@@ -39,6 +41,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
 /**
  * simple NPE smoke test
  */
@@ -47,7 +52,7 @@ public class ModelDrivenSwitchImplTest {
 
     private ModelDrivenSwitchImpl mdSwitchOF10;
     private ModelDrivenSwitchImpl mdSwitchOF13;
-    
+
     @Mock
     private SessionContext context;
     @Mock
@@ -57,6 +62,9 @@ public class ModelDrivenSwitchImplTest {
     @Mock
     private GetFeaturesOutput features;
 
+    public static Cache<TransactionKey, Object> bulkTransactionCache = CacheBuilder.newBuilder()
+            .expireAfterWrite(10000, TimeUnit.MILLISECONDS).concurrencyLevel(1).build();
+
     /**
      * @throws java.lang.Exception
      */
@@ -64,77 +72,81 @@ public class ModelDrivenSwitchImplTest {
     public void setUp() throws Exception {
         Mockito.when(context.getPrimaryConductor()).thenReturn(conductor);
         Mockito.when(context.getMessageDispatchService()).thenReturn(messageDispatchService);
-        Mockito.when(conductor.getVersion())
-            .thenReturn(OFConstants.OFP_VERSION_1_0)
-            .thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(conductor.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0)
+                .thenReturn(OFConstants.OFP_VERSION_1_3);
         Mockito.when(context.getFeatures()).thenReturn(features);
+        Mockito.when(context.getbulkTransactionCache()).thenReturn(bulkTransactionCache);
         Mockito.when(features.getDatapathId()).thenReturn(BigInteger.valueOf(1));
 
         mdSwitchOF10 = new ModelDrivenSwitchImpl(null, null, context);
         mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
     }
 
-
     /**
-     * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#addFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)}.
+     * Test method for
+     * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#addFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)}
+     * .
      */
     @Test
     public void testAddFlow() {
         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
         updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
         Set<RpcError> errorSet = Collections.emptySet();
-        RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, 
-                updateFlowOutput.build(), errorSet);
-        Mockito.when(messageDispatchService.flowMod(Matchers.any(FlowModInput.class), 
-                Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
-        
+        RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
+        Mockito.when(
+                messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
+                        Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
+
         AddFlowInputBuilder input = new AddFlowInputBuilder();
         input.setMatch(new MatchBuilder().build());
-        
+
         mdSwitchOF10.addFlow(input.build());
         mdSwitchOF13.addFlow(input.build());
     }
 
     /**
-     * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#removeFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)}.
+     * Test method for
+     * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#removeFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)}
+     * .
      */
     @Test
     public void testRemoveFlow() {
         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
         updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
         Set<RpcError> errorSet = Collections.emptySet();
-        RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, 
-                updateFlowOutput.build(), errorSet);
-        Mockito.when(messageDispatchService.flowMod(Matchers.any(FlowModInput.class), 
-                Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
-        
+        RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
+        Mockito.when(
+                messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
+                        Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
+
         RemoveFlowInputBuilder input = new RemoveFlowInputBuilder();
         input.setMatch(new MatchBuilder().build());
-        
+
         mdSwitchOF10.removeFlow(input.build());
         mdSwitchOF13.removeFlow(input.build());
     }
 
     /**
-     * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#updateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)}.
+     * Test method for
+     * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#updateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)}
+     * .
      */
     @Test
     public void testUpdateFlow() {
         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
         updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
         Set<RpcError> errorSet = Collections.emptySet();
-        RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, 
-                updateFlowOutput.build(), errorSet);
-        Mockito.when(messageDispatchService.flowMod(Matchers.any(FlowModInput.class), 
-                Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
-        
+        RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
+        Mockito.when(
+                messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
+                        Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
+
         UpdateFlowInputBuilder input = new UpdateFlowInputBuilder();
         UpdatedFlowBuilder updatedFlow = new UpdatedFlowBuilder();
         updatedFlow.setMatch(new MatchBuilder().build());
         input.setUpdatedFlow(updatedFlow.build());
-        
+
         mdSwitchOF10.updateFlow(input.build());
         mdSwitchOF13.updateFlow(input.build());
     }
-
 }
index 87252be4cc35e3c11516c99ab3839ab0005a56ab..7b7179a398afafef5266a704b3992cd0b99ebe65 100644 (file)
@@ -17,6 +17,7 @@ import java.util.concurrent.Future;
 
 import junit.framework.Assert;
 
+import com.google.common.cache.Cache;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -236,6 +237,11 @@ class MockSessionContext implements SessionContext {
         // TODO Auto-generated method stub
         return null;
     }
+    
+    @Override
+    public Cache<TransactionKey, Object> getbulkTransactionCache() {
+        return null;
+    }
 
     @Override
     public IMessageDispatchService getMessageDispatchService() {
diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java
new file mode 100644 (file)
index 0000000..7eba237
--- /dev/null
@@ -0,0 +1,1053 @@
+package org.opendaylight.openflowplugin.test;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.eclipse.osgi.framework.console.CommandInterpreter;
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
+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.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+//import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.M
+
+public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvider {
+    private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginBulkGroupTransactionProvider.class);
+    private NodeBuilder testNode;
+    private DataBrokerService dataBrokerService;
+    private final BundleContext ctx;
+    private ProviderContext pc;
+    private FlowBuilder testFlow;
+    private final String originalFlowName = "Foo";
+    private final FlowEventListener flowEventListener = new FlowEventListener();
+    private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener1Reg;
+    private Group testGroup;
+    private Group testGroup2;
+    private Node testNode12;
+    private final String originalGroupName = "Foo";
+    private static NotificationService notificationService;
+
+    public OpenflowPluginBulkGroupTransactionProvider(BundleContext ctx) {
+        this.ctx = ctx;
+    }
+
+    public void onSessionInitiated(ProviderContext session) {
+        pc = session;
+        notificationService = session.getSALService(NotificationService.class);
+        listener1Reg = notificationService.registerNotificationListener(flowEventListener);
+        dataBrokerService = session.getSALService(DataBrokerService.class);
+        ctx.registerService(CommandProvider.class.getName(), this, null);
+        createTestFlow(createTestNode(null), null, null);
+    }
+
+    private NodeBuilder createTestNode(String nodeId) {
+        if (nodeId == null) {
+            nodeId = OpenflowpluginTestActivator.NODE_ID;
+        }
+        NodeRef nodeOne = createNodeRef(nodeId);
+        NodeBuilder builder = new NodeBuilder();
+        builder.setId(new NodeId(nodeId));
+        builder.setKey(new NodeKey(builder.getId()));
+        testNode = builder;
+        return builder;
+    }
+
+    final class FlowEventListener implements SalFlowListener {
+
+        List<FlowAdded> addedFlows = new ArrayList<>();
+        List<FlowRemoved> removedFlows = new ArrayList<>();
+        List<FlowUpdated> updatedFlows = new ArrayList<>();
+
+        @Override
+        public void onFlowAdded(FlowAdded notification) {
+            // TODO Auto-generated method stub
+        }
+
+        @Override
+        public void onFlowRemoved(FlowRemoved notification) {
+            // TODO Auto-generated method stub
+
+        };
+
+        @Override
+        public void onFlowUpdated(FlowUpdated notification) {
+            // TODO Auto-generated method stub
+        }
+
+        @Override
+        public void onNodeErrorNotification(NodeErrorNotification notification) {
+            LOG.error("Error notification  flow Xid........................."
+                    + notification.getTransactionId().getValue());
+            LOG.debug("notification Begin-Transaction:" + notification.getTransactionUri().toString()
+                    + "-----------------------------------------------------------------------------------");
+        }
+
+        @Override
+        public void onNodeExperimenterErrorNotification(NodeExperimenterErrorNotification notification) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+        public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
+            LOG.debug("Switch flow removed : Cookies..................." + notification.getCookie().toString());
+            LOG.debug("-----------------------------------------------------------------------------------");
+        }
+    }
+
+    private static NodeRef createNodeRef(String string) {
+        NodeKey key = new NodeKey(new NodeId(string));
+        InstanceIdentifier<Node> path = InstanceIdentifier.builder().node(Nodes.class).node(Node.class, key)
+                .toInstance();
+
+        return new NodeRef(path);
+    }
+
+    @Override
+    public String getHelp() {
+        return "No help";
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createMatch1() {
+        MatchBuilder match = new MatchBuilder();
+        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
+        ipv4Match.setIpv4Destination(prefix);
+        Ipv4Match i4m = ipv4Match.build();
+        match.setLayer3Match(i4m);
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+        return match;
+    }
+
+    /**
+     * @return
+     */
+    private static InstructionsBuilder createDecNwTtlInstructions() {
+        DecNwTtlBuilder ta = new DecNwTtlBuilder();
+        DecNwTtl decNwTtl = ta.build();
+        ActionBuilder ab = new ActionBuilder();
+        ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
+
+        // Add our drop action to a list
+        List<Action> actionList = new ArrayList<Action>();
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+        ib.setKey(new InstructionKey(0));
+        ib.setOrder(0);
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createMatch2() {
+        MatchBuilder match = new MatchBuilder();
+        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
+        ipv4Match.setIpv4Source(prefix);
+        Ipv4Match i4m = ipv4Match.build();
+        match.setLayer3Match(i4m);
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+        return match;
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createMatch3() {
+        MatchBuilder match = new MatchBuilder();
+        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+        EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+        ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
+        ethernetMatch.setEthernetSource(ethSourceBuilder.build());
+        match.setEthernetMatch(ethernetMatch.build());
+
+        return match;
+    }
+
+    private static InstructionsBuilder createDropInstructions() {
+        DropActionBuilder dab = new DropActionBuilder();
+        DropAction dropAction = dab.build();
+        ActionBuilder ab = new ActionBuilder();
+        ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
+
+        // Add our drop action to a list
+        List<Action> actionList = new ArrayList<Action>();
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static MatchBuilder createEthernetMatch() {
+        MatchBuilder match = new MatchBuilder();
+
+        byte[] mask1 = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
+        byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
+
+        EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
+                                                                    // match
+        EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+        EtherType type = new EtherType(0x0800L);
+        ethmatch.setEthernetType(ethtype.setType(type).build());
+
+        EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
+                                                                               // macaddress
+                                                                               // match
+        MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
+        ethdest.setAddress(macdest);
+        // ethdest.setMask(mask1);
+
+        ethmatch.setEthernetDestination(ethdest.build());
+
+        EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
+        MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
+        ethsrc.setAddress(macsrc);
+        // ethsrc.setMask(mask2);
+
+        ethmatch.setEthernetSource(ethsrc.build());
+        match.setEthernetMatch(ethmatch.build());
+        return match;
+
+    }
+
+    /**
+     * @return
+     */
+    private static InstructionsBuilder createMeterInstructions() {
+
+        MeterBuilder aab = new MeterBuilder();
+        aab.setMeterId(new MeterId(new Long(1)));
+
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+        ControllerActionBuilder controller = new ControllerActionBuilder();
+        controller.setMaxLength(5);
+        ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction7() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
+        VlanId a = new VlanId(4012);
+        vl.setVlanId(a);
+        ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction21() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
+        ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction2() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        PushMplsActionBuilder push = new PushMplsActionBuilder();
+        push.setEthernetType(new Integer(0x8847));
+        ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction3() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        PushPbbActionBuilder pbb = new PushPbbActionBuilder();
+        pbb.setEthernetType(new Integer(0x88E7));
+        ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createGotoTableInstructions() {
+
+        GoToTableBuilder aab = new GoToTableBuilder();
+        aab.setTableId((short) 2);
+
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
+
+        FlowBuilder flow = new FlowBuilder();
+        long id = 123;
+
+        String flowType = flowTypeArg;
+        if (flowType == null) {
+            flowType = "f1";
+        }
+
+        switch (flowType) {
+        case "f1":
+            id += 1;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f2":
+            id += 2;
+            flow.setMatch(createMatch2().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f3":
+            id += 3;
+            flow.setMatch(createMatch3().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f4":
+            id += 4;
+            flow.setMatch(createEthernetMatch().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f82":
+            id += 1;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f5":
+            id += 5;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction().build());
+            break;
+        case "f6":
+            id += 6;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createGotoTableInstructions().build());
+            break;
+        case "f7":
+            id += 7;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createMeterInstructions().build());
+            break;
+        case "f8":
+            id += 8;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction7().build());
+            break;
+        case "f9":
+            id += 9;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction2().build());
+            break;
+        case "f10":
+            id += 10;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction3().build());
+            break;
+        case "f14":
+            id += 14;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction7().build());
+            break;
+        case "f29":
+            id += 29;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction21().build());
+            break;
+
+        default:
+            LOG.warn("flow type not understood: {}", flowType);
+        }
+
+        FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
+        if (null == flow.isBarrier()) {
+            flow.setBarrier(Boolean.FALSE);
+        }
+        // flow.setBufferId(new Long(12));
+        BigInteger value = new BigInteger("10", 10);
+        BigInteger outputPort = new BigInteger("4294967295", 10);
+        flow.setCookie(value);
+        flow.setCookieMask(value);
+        flow.setHardTimeout(0);
+        flow.setIdleTimeout(0);
+        flow.setInstallHw(false);
+        flow.setStrict(false);
+        flow.setContainerName(null);
+        flow.setFlags(new FlowModFlags(false, false, false, false, true));
+        flow.setId(new FlowId("12"));
+        flow.setTableId(getTableId(tableId));
+        flow.setOutGroup(new Long("4294967295"));
+        // set outport to OFPP_NONE (65535) to disable remove restriction for
+        // flow
+        flow.setOutPort(outputPort);
+
+        flow.setKey(key);
+        flow.setPriority(2);
+        flow.setFlowName(originalFlowName + "X" + flowType);
+        testFlow = flow;
+        return flow;
+    }
+
+    private short getTableId(String tableId) {
+        short table = 2;
+        try {
+            table = Short.parseShort(tableId);
+        } catch (Exception ex) {
+            // ignore exception and continue with default value
+        }
+
+        return table;
+
+    }
+
+    public void _addGroups(CommandInterpreter ci) {
+        String nref = ci.nextArgument();
+
+        if (nref == null) {
+            ci.println("test node added");
+            createTestNode();
+        } else {
+            ci.println("User node added" + nref);
+            createUserNode(nref);
+        }
+        Integer count = Integer.parseInt(ci.nextArgument());
+        switch (count) {
+        case 1:
+            GroupBuilder group = createTestGroup("a7", "g1", "add", "1");
+            GroupBuilder group1 = createTestGroup("a3", "g1", "add", "2");
+            writeGroup(ci, group.build(), group1.build());
+            break;
+        case 2:
+            GroupBuilder group2 = createTestGroup("a4", "g1", "add", "4");
+            GroupBuilder group3 = createTestGroup("a5", "g1", "add", "5");
+            writeGroup(ci, group2.build(), group3.build());
+            break;
+        case 3:
+            GroupBuilder group4 = createTestGroup("a6", "g1", "add", "6");
+            GroupBuilder group5 = createTestGroup("a7", "g1", "add", "7");
+            writeGroup(ci, group4.build(), group5.build());
+            break;
+        case 4:
+            // -ve
+            GroupBuilder group6 = createTestGroup("a14", "g1", "add", "5");
+            GroupBuilder group7 = createTestGroup("a3", "g1", "add", "6");
+            writeGroup(ci, group6.build(), group7.build());
+            break;
+
+        }
+
+    }
+
+    private void createUserNode(String nodeRef) {
+        NodeRef nodeOne = createNodeRef(nodeRef);
+        NodeBuilder builder = new NodeBuilder();
+        builder.setId(new NodeId(nodeRef));
+        builder.setKey(new NodeKey(builder.getId()));
+        testNode12 = builder.build();
+    }
+
+    public void _modifyGroups(CommandInterpreter ci) {
+        String nref = ci.nextArgument();
+
+        if (nref == null) {
+            ci.println("test node added");
+            createTestNode();
+        } else {
+            ci.println("User node added" + nref);
+            createUserNode(nref);
+        }
+        Integer count = Integer.parseInt(ci.nextArgument());
+        switch (count) {
+        case 1:
+            GroupBuilder group = createTestGroup("a4", "g1", "modify", "1");
+            GroupBuilder group1 = createTestGroup("a5", "g1", "modify", "2");
+            writeGroup(ci, group.build(), group1.build());
+            break;
+        case 2:
+            GroupBuilder group2 = createTestGroup("a1", "g1", "modify", "4");
+            GroupBuilder group3 = createTestGroup("a2", "g1", "modify", "5");
+            writeGroup(ci, group2.build(), group3.build());
+            break;
+        case 3:
+            GroupBuilder group4 = createTestGroup("a9", "g1", "modify", "6");
+            GroupBuilder group5 = createTestGroup("a10", "g1", "modify", "7");
+            writeGroup(ci, group4.build(), group5.build());
+            break;
+
+        case 4:
+            GroupBuilder group6 = createTestGroup("a6", "g1", "modify", "5");
+            GroupBuilder group7 = createTestGroup("a29", "g1", "modify", "6");
+            writeGroup(ci, group6.build(), group7.build());
+            break;
+        }
+    }
+
+    private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
+        return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+    }
+
+    private void createTestNode() {
+        NodeRef nodeOne = createNodeRef(OpenflowpluginTestActivator.NODE_ID);
+        NodeBuilder builder = new NodeBuilder();
+        builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
+        builder.setKey(new NodeKey(builder.getId()));
+        testNode12 = builder.build();
+    }
+
+    public void _removeGroups(CommandInterpreter ci) {
+        String nref = ci.nextArgument();
+
+        if (nref == null) {
+            ci.println("test node added");
+            createTestNode();
+        } else {
+            ci.println("User node added" + nref);
+            createUserNode(nref);
+        }
+
+        Integer count = Integer.parseInt(ci.nextArgument());
+        switch (count) {
+        case 1:
+            GroupBuilder group = createTestGroup("a2", "g1", "remove", "1");
+            GroupBuilder group1 = createTestGroup("a3", "g1", "remove", "2");
+            deleteGroup(ci, group.build(), group1.build());
+            break;
+        case 2:
+            GroupBuilder group2 = createTestGroup("a4", "g1", "remove", "4");
+            GroupBuilder group3 = createTestGroup("a5", "g1", "remove", "5");
+            deleteGroup(ci, group2.build(), group3.build());
+            break;
+        case 3:
+            GroupBuilder group4 = createTestGroup("a6", "g1", "remove", "6");
+            GroupBuilder group5 = createTestGroup("a7", "g1", "remove", "7");
+            deleteGroup(ci, group4.build(), group5.build());
+            break;
+        case 4:
+            GroupBuilder group6 = createTestGroup("a14", "g1", "remove", "5");
+            GroupBuilder group7 = createTestGroup("a3", "g1", "remove", "6");
+            deleteGroup(ci, group6.build(), group7.build());
+            break;
+        case 5:
+            GroupBuilder group8 = createTestGroup("a4", "g1", "modify", "1");
+            GroupBuilder group9 = createTestGroup("a5", "g1", "modify", "2");
+            writeGroup(ci, group8.build(), group9.build());
+            break;
+        case 6:
+            GroupBuilder group10 = createTestGroup("a1", "g1", "modify", "4");
+            GroupBuilder group11 = createTestGroup("a2", "g1", "modify", "5");
+            writeGroup(ci, group10.build(), group11.build());
+            break;
+        case 7:
+            GroupBuilder group12 = createTestGroup("a9", "g1", "modify", "6");
+            GroupBuilder group13 = createTestGroup("a10", "g1", "modify", "7");
+            writeGroup(ci, group12.build(), group13.build());
+            break;
+
+        case 8:
+            GroupBuilder group14 = createTestGroup("a6", "g1", "modify", "5");
+            GroupBuilder group15 = createTestGroup("a29", "g1", "modify", "6");
+            writeGroup(ci, group14.build(), group15.build());
+            break;
+
+        }
+
+    }
+
+    private void writeGroup(CommandInterpreter ci, Group group, Group group1) {
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
+        InstanceIdentifier<Group> path1 = InstanceIdentifier.builder(Nodes.class)
+                .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
+                .child(Group.class, new GroupKey(group.getGroupId())).build();
+        modification.putConfigurationData(nodeToInstanceId(testNode12), testNode12);
+        modification.putConfigurationData(path1, group);
+
+        InstanceIdentifier<Group> path2 = InstanceIdentifier.builder(Nodes.class)
+                .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
+                .child(Group.class, new GroupKey(group1.getGroupId())).build();
+        modification.putConfigurationData(nodeToInstanceId(testNode12), testNode12);
+        modification.putConfigurationData(path2, group1);
+        Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+
+        try {
+            RpcResult<TransactionStatus> result = commitFuture.get();
+            TransactionStatus status = result.getResult();
+            ci.println("Status of Group Data Loaded Transaction: " + status);
+
+        } catch (InterruptedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ExecutionException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    private void deleteGroup(CommandInterpreter ci, Group group, Group group1) {
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
+        InstanceIdentifier<Group> path1 = InstanceIdentifier.builder(Nodes.class)
+                .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
+                .child(Group.class, new GroupKey(group.getGroupId())).build();
+        modification.removeOperationalData(path1);
+        modification.removeConfigurationData(path1);
+        InstanceIdentifier<Group> path2 = InstanceIdentifier.builder(Nodes.class)
+                .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
+                .child(Group.class, new GroupKey(group1.getGroupId())).build();
+        modification.removeOperationalData(path2);
+        modification.removeConfigurationData(path2);
+        Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+        try {
+            RpcResult<TransactionStatus> result = commitFuture.get();
+            TransactionStatus status = result.getResult();
+            ci.println("Status of Group Data Loaded Transaction: " + status);
+            ci.println("Status of Group Data Loaded Transaction: ");
+
+        } catch (InterruptedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ExecutionException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    private GroupBuilder createTestGroup(String actiontype, String type, String mod, String iD) {
+        // Sample data , committing to DataStore
+
+        String GroupType = type;
+        String ActionType = actiontype;
+        String Groupmod = mod;
+
+        long id = Long.parseLong(iD);
+        GroupKey key = new GroupKey(new GroupId(id));
+        GroupBuilder group = new GroupBuilder();
+        BucketBuilder bucket = new BucketBuilder();
+        bucket.setBucketId(new BucketId((long) 12));
+        bucket.setKey(new BucketKey(new BucketId((long) 12)));
+
+        if (GroupType == null) {
+            GroupType = "g1";
+        }
+        if (ActionType == null) {
+            ActionType = "a1";
+        }
+
+        switch (GroupType) {
+        case "g1":
+            group.setGroupType(GroupTypes.GroupSelect);
+            break;
+        case "g2":
+            group.setGroupType(GroupTypes.GroupAll);
+            break;
+        case "g3":
+            group.setGroupType(GroupTypes.GroupIndirect);
+            break;
+        case "g4":
+            group.setGroupType(GroupTypes.GroupFf);
+            break;
+        }
+
+        switch (ActionType) {
+        case "a1":
+            bucket.setAction(createPopVlanAction());
+            break;
+        case "a2":
+            bucket.setAction(createPushVlanAction());
+            break;
+        case "a3":
+            bucket.setAction(createPushMplsAction());
+            break;
+        case "a4":
+            bucket.setAction(createPopMplsAction());
+            break;
+        case "a5":
+            bucket.setAction(createPopPbbAction());
+            break;
+        case "a6":
+            bucket.setAction(createPushPbbAction());
+            break;
+        case "a7":
+            bucket.setAction(createPushPbbAction());
+            break;
+        case "a8":
+            bucket.setAction(createCopyTtlInAction());
+            break;
+        case "a9":
+            bucket.setAction(createCopyTtlOutAction());
+            break;
+        case "a10":
+            bucket.setAction(createDecMplsTtlAction());
+            break;
+        case "a14":
+            bucket.setAction(createGroupAction());
+            break;
+        case "a29":
+            bucket.setAction(createNonAppyPushVlanAction());
+            break;
+
+        }
+
+        if (Groupmod == "add") {
+            bucket.setWatchGroup((long) 14);
+            bucket.setWatchPort((long) 1234);
+            bucket.setWeight(50);
+        } else {
+            bucket.setWatchGroup((long) 13);
+            bucket.setWatchPort((long) 134);
+            bucket.setWeight(30);
+        }
+        group.setKey(key);
+        // group.setInstall(false);
+        group.setGroupId(new GroupId(id));
+        group.setGroupName(originalGroupName);
+        group.setBarrier(false);
+        BucketsBuilder value = new BucketsBuilder();
+        List<Bucket> value1 = new ArrayList<Bucket>();
+        value1.add(bucket.build());
+        value.setBucket(value1);
+        group.setBuckets(value.build());
+        testGroup = group.build();
+        return group;
+    }
+
+    private List<Action> createPopVlanAction() {
+        PopVlanActionBuilder vlanAction = new PopVlanActionBuilder();
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(vlanAction.build()).build());
+        action.setKey(new ActionKey(0));
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createPushVlanAction() {
+        PushVlanActionBuilder vlan = new PushVlanActionBuilder();
+        vlan.setEthernetType(new Integer(0x8100));
+        VlanId v = new VlanId(2);
+        vlan.setVlanId(v);
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createPushMplsAction() {
+        PushMplsActionBuilder push = new PushMplsActionBuilder();
+        push.setEthernetType(new Integer(0x8847));
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createPopMplsAction() {
+        PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
+        popMplsActionBuilder.setEthernetType(0XB);
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createPopPbbAction() {
+        PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createPushPbbAction() {
+        PushPbbActionBuilder pbb = new PushPbbActionBuilder();
+        pbb.setEthernetType(new Integer(0x88E7));
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createCopyTtlInAction() {
+        CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createCopyTtlOutAction() {
+        CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createDecMplsTtlAction() {
+        DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private List<Action> createGroupAction() {
+
+        GroupActionBuilder groupActionB = new GroupActionBuilder();
+        groupActionB.setGroupId(1L);
+        groupActionB.setGroup("0");
+        ActionBuilder action = new ActionBuilder();
+        action.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
+        action.setKey(new ActionKey(0));
+        List<Action> actions = new ArrayList<Action>();
+        actions.add(action.build());
+        return actions;
+    }
+
+    private static List<Action> createNonAppyPushVlanAction() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        GroupActionBuilder groupActionB = new GroupActionBuilder();
+        groupActionB.setGroupId(1L);
+        groupActionB.setGroup("0");
+        ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
+        actionList.add(ab.build());
+
+        return actionList;
+    }
+
+}
diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java
new file mode 100644 (file)
index 0000000..e53f5ef
--- /dev/null
@@ -0,0 +1,1452 @@
+package org.opendaylight.openflowplugin.test;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.eclipse.osgi.framework.console.CommandInterpreter;
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+//import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.M
+
+public class OpenflowPluginBulkTransactionProvider implements CommandProvider {
+
+    private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
+    private DataBrokerService dataBrokerService;
+    private final BundleContext ctx;
+    private NodeBuilder testNode;
+    private ProviderContext pc;
+    private FlowBuilder testFlow;
+    private final String originalFlowName = "Foo";
+    private final FlowEventListener flowEventListener = new FlowEventListener();
+    private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener1Reg;
+    private Node testNode12;
+    private final String originalGroupName = "Foo";
+    private static NotificationService notificationService;
+
+    public OpenflowPluginBulkTransactionProvider(BundleContext ctx) {
+        this.ctx = ctx;
+    }
+
+    public void onSessionInitiated(ProviderContext session) {
+        pc = session;
+        notificationService = session.getSALService(NotificationService.class);
+        listener1Reg = notificationService.registerNotificationListener(flowEventListener);
+        dataBrokerService = session.getSALService(DataBrokerService.class);
+        ctx.registerService(CommandProvider.class.getName(), this, null);
+        createTestFlow(createTestNode(null), null, null);
+    }
+
+    private NodeBuilder createTestNode(String nodeId) {
+        if (nodeId == null) {
+            nodeId = OpenflowpluginTestActivator.NODE_ID;
+        }
+        NodeRef nodeOne = createNodeRef(nodeId);
+        NodeBuilder builder = new NodeBuilder();
+        builder.setId(new NodeId(nodeId));
+        builder.setKey(new NodeKey(builder.getId()));
+        testNode = builder;
+        return builder;
+    }
+
+    final class FlowEventListener implements SalFlowListener {
+
+        List<FlowAdded> addedFlows = new ArrayList<>();
+        List<FlowRemoved> removedFlows = new ArrayList<>();
+        List<FlowUpdated> updatedFlows = new ArrayList<>();
+
+        @Override
+        public void onFlowAdded(FlowAdded notification) {
+            // TODO Auto-generated method stub
+        }
+
+        @Override
+        public void onFlowRemoved(FlowRemoved notification) {
+            // TODO Auto-generated method stub
+
+        };
+
+        @Override
+        public void onFlowUpdated(FlowUpdated notification) {
+            // TODO Auto-generated method stub
+        }
+
+        @Override
+        public void onNodeErrorNotification(NodeErrorNotification notification) {
+            LOG.error("Error notification  flow Xid........................."
+                    + notification.getTransactionId().getValue());
+            LOG.debug("notification Begin-Transaction:" + notification.getTransactionUri().toString()
+                    + "-----------------------------------------------------------------------------------");
+        }
+
+        @Override
+        public void onNodeExperimenterErrorNotification(NodeExperimenterErrorNotification notification) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+        public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
+            LOG.debug("Switch flow removed : Cookies..................." + notification.getCookie().toString());
+            LOG.debug("-----------------------------------------------------------------------------------");
+        }
+    }
+
+    private static NodeRef createNodeRef(String string) {
+        NodeKey key = new NodeKey(new NodeId(string));
+        InstanceIdentifier<Node> path = InstanceIdentifier.builder().node(Nodes.class).node(Node.class, key)
+                .toInstance();
+
+        return new NodeRef(path);
+    }
+
+    @Override
+    public String getHelp() {
+        return "No help";
+    }
+
+    private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
+
+        FlowBuilder flow = new FlowBuilder();
+        long id = 123;
+
+        String flowType = flowTypeArg;
+        if (flowType == null) {
+            flowType = "f1";
+        }
+
+        switch (flowType) {
+        case "f1":
+            id += 1;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f2":
+            id += 2;
+            flow.setMatch(createMatch2().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f3":
+            id += 3;
+            flow.setMatch(createMatch3().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f4":
+            id += 4;
+            flow.setMatch(createEthernetMatch().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f5":
+            id += 5;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction().build());
+            break;
+        case "f6":
+            id += 6;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createGotoTableInstructions().build());
+            break;
+        case "f7":
+            id += 7;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createMeterInstructions().build());
+            break;
+        case "f8":
+            id += 8;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction7().build());
+            break;
+        case "f9":
+            id += 9;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction2().build());
+            break;
+        case "f10":
+            id += 10;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction3().build());
+            break;
+        case "f23":
+            id += 23;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction16().build());
+            break;
+        case "f230":
+            id += 23;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction160().build());
+            break;
+        case "f34":
+            id += 34;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction26().build());
+            break;
+        case "f35":
+            id += 35;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction27().build());
+            break;
+        case "f36":
+            id += 36;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction28().build());
+            break;
+        case "f42":
+            id += 42;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction34().build());
+            break;
+        case "f43":
+            id += 43;
+            flow.setMatch(createICMPv6Match().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f44":
+            id += 44;
+            flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f45":
+            id += 45;
+            flow.setMatch(createMetadataMatch().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f46":
+            id += 46;
+            flow.setMatch(createL3IPv6Match().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f81":
+            id += 81;
+            flow.setMatch(createLLDPMatch().build());
+            flow.setInstructions(createSentToControllerInstructions().build());
+            break;
+
+        case "f82":
+            id += 1;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f83":
+            id += 2;
+            flow.setMatch(createMatch2().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f84":
+            id += 3;
+            flow.setMatch(createMatch3().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f85":
+            id += 4;
+            flow.setMatch(createEthernetMatch().build());
+            flow.setInstructions(createMeterInstructions().build());
+            break;
+        case "f86":
+            id += 6;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f87":
+            id += 12;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction7().build());
+            break;
+        case "f88":
+            id += 13;
+            flow.setMatch(createEthernetMatch().build());
+            flow.setInstructions(createAppyActionInstruction6().build());
+            break;
+        case "f89":
+            id += 14;
+            flow.setMatch(createEthernetMatch().build());
+            flow.setInstructions(createAppyActionInstruction7().build());
+            break;
+        case "f90":
+            id += 15;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction9().build());
+            break;
+        case "f91":
+            id += 7;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction9().build());
+            break;
+        case "f92":
+            id += 8;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction6().build());
+            break;
+        case "f93":
+            id += 9;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f94":
+            id += 10;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f95":
+            id += 42;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createDecNwTtlInstructions().build());
+            break;
+        case "f96":
+            id += 43;
+            flow.setMatch(createICMPv6Match().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        case "f97":
+            id += 44;
+            flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
+            flow.setInstructions(createMeterInstructions().build());
+            break;
+        case "f98":
+            id += 45;
+            flow.setMatch(createMetadataMatch().build());
+            flow.setInstructions(createAppyActionInstruction6().build());
+            break;
+        case "f99":
+            id += 34;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction6().build());
+            break;
+        case "f100":
+            id += 35;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction7().build());
+            break;
+        case "f101":
+            id += 36;
+            flow.setMatch(createMatch1().build());
+            flow.setInstructions(createAppyActionInstruction8().build());
+            break;
+        case "f700":
+            id += 3;
+            flow.setMatch(createMatch3().build());
+            flow.setInstructions(createMeterInstructions().build());
+            break;
+        case "f800":
+            id += 8;
+            flow.setMatch(createMatch1000().build());
+            flow.setInstructions(createAppyActionInstruction6().build());
+            break;
+        case "f900":
+            id += 5;
+            flow.setMatch(createMatch1000().build());
+            flow.setInstructions(createAppyActionInstruction2().build());
+            break;
+        case "f1000":
+            id += 10;
+            flow.setMatch(createMatch1000().build());
+            flow.setInstructions(createAppyActionInstruction3().build());
+            break;
+        default:
+            LOG.warn("flow type not understood: {}", flowType);
+        }
+
+        FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
+        if (null == flow.isBarrier()) {
+            flow.setBarrier(Boolean.FALSE);
+        }
+        // flow.setBufferId(new Long(12));
+        BigInteger value = new BigInteger("10", 10);
+        BigInteger outputPort = new BigInteger("4294967295", 10);
+        flow.setCookie(value);
+        flow.setCookieMask(value);
+        flow.setHardTimeout(0);
+        flow.setIdleTimeout(0);
+        flow.setInstallHw(false);
+        flow.setStrict(false);
+        flow.setContainerName(null);
+        flow.setFlags(new FlowModFlags(false, false, false, false, true));
+        flow.setId(new FlowId("12"));
+        flow.setTableId(getTableId(tableId));
+        flow.setOutGroup(new Long("4294967295"));
+        // set outport to OFPP_NONE (65535) to disable remove restriction for
+        // flow
+        flow.setOutPort(outputPort);
+
+        flow.setKey(key);
+        flow.setPriority(2);
+        flow.setFlowName(originalFlowName + "X" + flowType);
+        testFlow = flow;
+        return flow;
+    }
+
+    private short getTableId(String tableId) {
+        short table = 2;
+        try {
+            table = Short.parseShort(tableId);
+        } catch (Exception ex) {
+            // ignore exception and continue with default value
+        }
+
+        return table;
+
+    }
+
+    private void createTestNode() {
+        NodeRef nodeOne = createNodeRef(OpenflowpluginTestActivator.NODE_ID);
+        NodeBuilder builder = new NodeBuilder();
+        builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
+        builder.setKey(new NodeKey(builder.getId()));
+        testNode12 = builder.build();
+    }
+
+    public void _addFlows(CommandInterpreter ci) {
+        NodeBuilder tn = createTestNode(ci.nextArgument());
+        String flowtype = ci.nextArgument();
+        Integer flowcnt = Integer.parseInt(flowtype);
+        FlowBuilder tf;
+        FlowBuilder tf1;
+        FlowBuilder tf2;
+        FlowBuilder tf3;
+        switch (flowcnt) {
+        case 1:
+            tf = createTestFlow(tn, "f1", "10");
+            tf1 = createTestFlow(tn, "f2", "11");
+            tf2 = createTestFlow(tn, "f3", "12");
+            tf3 = createTestFlow(tn, "f4", "13");
+            break;
+        case 2:
+            tf = createTestFlow(tn, "f3", "3");
+            tf1 = createTestFlow(tn, "f4", "4");
+            tf2 = createTestFlow(tn, "f5", "5");
+            tf3 = createTestFlow(tn, "f6", "6");
+            break;
+        case 3:
+            tf = createTestFlow(tn, "f7", "7");
+            tf1 = createTestFlow(tn, "f8", "8");
+            tf2 = createTestFlow(tn, "f9", "9");
+            tf3 = createTestFlow(tn, "f10", "10");
+            break;
+        case 4:
+            // -ve scenario
+            tf = createTestFlow(tn, "f23", "3");
+            tf1 = createTestFlow(tn, "f34", "4");
+            tf2 = createTestFlow(tn, "f35", "5");
+            tf3 = createTestFlow(tn, "f36", "6");
+            break;
+        case 5:
+            // +ve scenario
+            // modify case 6 -ve
+            tf = createTestFlow(tn, "f230", "3");
+            tf1 = createTestFlow(tn, "f34", "4");
+            tf2 = createTestFlow(tn, "f35", "5");
+            tf3 = createTestFlow(tn, "f36", "6");
+            break;
+
+        default:
+            tf = createTestFlow(tn, "f42", "42");
+            tf1 = createTestFlow(tn, "f43", "43");
+            tf2 = createTestFlow(tn, "f44", "44");
+            tf3 = createTestFlow(tn, "f45", "45");
+
+        }
+        writeFlow(ci, tf, tf1, tf2, tf3, tn);
+    }
+
+    private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
+        return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+    }
+
+    public void _modifyFlows(CommandInterpreter ci) {
+        NodeBuilder tn = createTestNode(ci.nextArgument());
+        String flowtype = ci.nextArgument();
+        Integer flowcnt = Integer.parseInt(flowtype);
+        FlowBuilder tf;
+        FlowBuilder tf1;
+        FlowBuilder tf2;
+        FlowBuilder tf3;
+        switch (flowcnt) {
+        case 1:
+            tf = createTestFlow(tn, "f82", "10");
+            tf1 = createTestFlow(tn, "f83", "11");
+            tf2 = createTestFlow(tn, "f84", "12");
+            tf3 = createTestFlow(tn, "f85", "13");
+            break;
+        case 2:
+            tf = createTestFlow(tn, "f700", "3");
+            tf1 = createTestFlow(tn, "f4", "4");
+            tf2 = createTestFlow(tn, "f900", "5");
+            tf3 = createTestFlow(tn, "f86", "6");
+            break;
+        case 3:
+            // +
+            tf = createTestFlow(tn, "f91", "7");
+            tf1 = createTestFlow(tn, "f92", "8");
+            tf2 = createTestFlow(tn, "f93", "9");
+            tf3 = createTestFlow(tn, "f94", "10");
+            break;
+        case 4:
+            // +ve scenario
+            tf = createTestFlow(tn, "f230", "3");
+            tf1 = createTestFlow(tn, "f99", "4");
+            tf2 = createTestFlow(tn, "f100", "5");
+            tf3 = createTestFlow(tn, "f101", "6");
+            break;
+        case 5:
+            // -
+            tf = createTestFlow(tn, "f23", "3");
+            tf1 = createTestFlow(tn, "f99", "4");
+            tf2 = createTestFlow(tn, "f100", "5");
+            tf3 = createTestFlow(tn, "f101", "6");
+            break;
+
+        default:
+            tf = createTestFlow(tn, "f87", "12");
+            tf1 = createTestFlow(tn, "f88", "13");
+            tf2 = createTestFlow(tn, "f89", "14");
+            tf3 = createTestFlow(tn, "f90", "15");
+
+        }
+
+        writeFlow(ci, tf, tf1, tf2, tf3, tn);
+
+    }
+
+    public void _removeFlows(CommandInterpreter ci) {
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
+        NodeBuilder tn = createTestNode(ci.nextArgument());
+        String flowtype = ci.nextArgument();
+        Integer flowcnt = Integer.parseInt(flowtype);
+        FlowBuilder tf = null;
+        FlowBuilder tf1 = null;
+        FlowBuilder tf2 = null;
+        FlowBuilder tf3 = null;
+        switch (flowcnt) {
+        case 1:
+            // add case 1
+            tf = createTestFlow(tn, "f1", "10");
+            tf1 = createTestFlow(tn, "f2", "11");
+            tf2 = createTestFlow(tn, "f3", "12");
+            tf3 = createTestFlow(tn, "f4", "13");
+            break;
+        case 2:
+            // modify case 1
+            tf = createTestFlow(tn, "f82", "10");
+            tf1 = createTestFlow(tn, "f83", "11");
+            tf2 = createTestFlow(tn, "f84", "12");
+            tf3 = createTestFlow(tn, "f85", "13");
+            break;
+        case 3:
+            // add case 2
+            tf = createTestFlow(tn, "f3", "3");
+            tf1 = createTestFlow(tn, "f4", "4");
+            tf2 = createTestFlow(tn, "f5", "5");
+            tf3 = createTestFlow(tn, "f6", "6");
+            break;
+        case 4:
+            // modify case 2
+            tf = createTestFlow(tn, "f700", "3");
+            tf1 = createTestFlow(tn, "f4", "4");
+            tf2 = createTestFlow(tn, "f900", "5");
+            tf3 = createTestFlow(tn, "f86", "6");
+            break;
+        case 5:
+            // add case 3
+            tf = createTestFlow(tn, "f7", "7");
+            tf1 = createTestFlow(tn, "f8", "8");
+            tf2 = createTestFlow(tn, "f9", "9");
+            tf3 = createTestFlow(tn, "f10", "10");
+            break;
+        case 6:
+            // modify case 3
+            tf = createTestFlow(tn, "f91", "7");
+            tf1 = createTestFlow(tn, "f92", "8");
+            tf2 = createTestFlow(tn, "f93", "9");
+            tf3 = createTestFlow(tn, "f94", "10");
+            break;
+        case 7:
+            // -ve scenario
+            tf = createTestFlow(tn, "f23", "3");
+            tf1 = createTestFlow(tn, "f34", "4");
+            tf2 = createTestFlow(tn, "f35", "5");
+            tf3 = createTestFlow(tn, "f36", "6");
+            break;
+        case 8:
+            // +ve scenario
+            // modify case 6 -ve
+            tf = createTestFlow(tn, "f23", "3");
+            tf1 = createTestFlow(tn, "f99", "4");
+            tf2 = createTestFlow(tn, "f100", "5");
+            tf3 = createTestFlow(tn, "f101", "6");
+            break;
+        case 9:
+            // modify case 6
+            tf = createTestFlow(tn, "f700", "7");
+            tf1 = createTestFlow(tn, "f230", "23");
+            tf2 = createTestFlow(tn, "f900", "9");
+            tf3 = createTestFlow(tn, "f1000", "10");
+            break;
+        }
+
+        InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
+                .child(Flow.class, tf.getKey()).build();
+        modification.removeOperationalData(path1);
+        modification.removeConfigurationData(nodeBuilderToInstanceId(tn));
+        modification.removeConfigurationData(path1);
+        InstanceIdentifier<Flow> path2 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf1.getTableId()))
+                .child(Flow.class, tf1.getKey()).build();
+        modification.removeOperationalData(path2);
+        modification.removeConfigurationData(nodeBuilderToInstanceId(tn));
+        modification.removeConfigurationData(path2);
+
+        InstanceIdentifier<Flow> path3 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf2.getTableId()))
+                .child(Flow.class, tf2.getKey()).build();
+        modification.removeOperationalData(path3);
+        modification.removeConfigurationData(nodeBuilderToInstanceId(tn));
+        modification.removeConfigurationData(path3);
+        InstanceIdentifier<Flow> path4 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf3.getTableId()))
+                .child(Flow.class, tf3.getKey()).build();
+        modification.removeOperationalData(path4);
+        modification.removeConfigurationData(nodeBuilderToInstanceId(tn));
+        modification.removeConfigurationData(path4);
+        Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+        try {
+            RpcResult<TransactionStatus> result = commitFuture.get();
+            TransactionStatus status = result.getResult();
+            ci.println("Status of Flow Data Loaded Transaction: " + status);
+
+        } catch (InterruptedException e) {
+            LOG.error(e.getMessage(), e);
+        } catch (ExecutionException e) {
+            LOG.error(e.getMessage(), e);
+        }
+    }
+
+    private void writeFlow(CommandInterpreter ci, FlowBuilder flow, FlowBuilder flow1, FlowBuilder flow2,
+            FlowBuilder flow3, NodeBuilder nodeBuilder) {
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
+        InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
+                .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
+                .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey()).build();
+        modification.putOperationalData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.putOperationalData(path1, flow.build());
+        modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.putConfigurationData(path1, flow.build());
+        InstanceIdentifier<Flow> path2 = InstanceIdentifier.builder(Nodes.class)
+                .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
+                .child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.getKey()).build();
+        modification.putOperationalData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.putOperationalData(path2, flow1.build());
+        modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.putConfigurationData(path2, flow1.build());
+
+        InstanceIdentifier<Flow> path3 = InstanceIdentifier.builder(Nodes.class)
+                .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
+                .child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.getKey()).build();
+        modification.putOperationalData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.putOperationalData(path3, flow2.build());
+        modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.putConfigurationData(path3, flow2.build());
+
+        InstanceIdentifier<Flow> path4 = InstanceIdentifier.builder(Nodes.class)
+                .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
+                .child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.getKey()).build();
+        modification.putOperationalData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.putOperationalData(path4, flow3.build());
+        modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+        modification.putConfigurationData(path4, flow3.build());
+        Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+        try {
+            RpcResult<TransactionStatus> result = commitFuture.get();
+            TransactionStatus status = result.getResult();
+            ci.println("Status of Flow Data Loaded Transaction: " + status);
+
+        } catch (InterruptedException e) {
+            LOG.error(e.getMessage(), e);
+        } catch (ExecutionException e) {
+            LOG.error(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * @return
+     */
+    private static InstructionsBuilder createDecNwTtlInstructions() {
+        DecNwTtlBuilder ta = new DecNwTtlBuilder();
+        DecNwTtl decNwTtl = ta.build();
+        ActionBuilder ab = new ActionBuilder();
+        ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
+
+        // Add our drop action to a list
+        List<Action> actionList = new ArrayList<Action>();
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+        ib.setKey(new InstructionKey(0));
+        ib.setOrder(0);
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    /**
+     * @return
+     */
+    private static InstructionsBuilder createMeterInstructions() {
+
+        MeterBuilder aab = new MeterBuilder();
+        aab.setMeterId(new MeterId(new Long(1)));
+
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createGotoTableInstructions() {
+
+        GoToTableBuilder aab = new GoToTableBuilder();
+        aab.setTableId((short) 2);
+
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createDropInstructions() {
+        DropActionBuilder dab = new DropActionBuilder();
+        DropAction dropAction = dab.build();
+        ActionBuilder ab = new ActionBuilder();
+        ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
+
+        // Add our drop action to a list
+        List<Action> actionList = new ArrayList<Action>();
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+        ControllerActionBuilder controller = new ControllerActionBuilder();
+        controller.setMaxLength(5);
+        ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createSentToControllerInstructions() {
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        OutputActionBuilder output = new OutputActionBuilder();
+        output.setMaxLength(new Integer(0xffff));
+        Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
+        output.setOutputNodeConnector(value);
+        ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
+        ab.setOrder(0);
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+        ib.setOrder(0);
+        ib.setKey(new InstructionKey(0));
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction2() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        PushMplsActionBuilder push = new PushMplsActionBuilder();
+        push.setEthernetType(new Integer(0x8847));
+        ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction3() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        PushPbbActionBuilder pbb = new PushPbbActionBuilder();
+        pbb.setEthernetType(new Integer(0x88E7));
+        ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction6() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
+        src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
+        ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction7() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
+        VlanId a = new VlanId(4012);
+        vl.setVlanId(a);
+        ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction8() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
+        VlanPcp pcp1 = new VlanPcp((short) 2);
+        pcp.setVlanPcp(pcp1);
+        ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction9() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
+        ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction16() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        GroupActionBuilder groupActionB = new GroupActionBuilder();
+        groupActionB.setGroupId(1L);
+        groupActionB.setGroup("0");
+        ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction160() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        FloodAllActionBuilder fldall = new FloodAllActionBuilder();
+        ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction26() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+        Ipv4Builder ipdst = new Ipv4Builder();
+        Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
+        ipdst.setIpv4Address(prefixdst);
+        setNwDstActionBuilder.setAddress(ipdst.build());
+        ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction27() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
+        Ipv4Builder ipsrc = new Ipv4Builder();
+        Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
+        ipsrc.setIpv4Address(prefixsrc);
+        setNwsrcActionBuilder.setAddress(ipsrc.build());
+        ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction28() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
+        setNwTosActionBuilder.setTos(8);
+        ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static InstructionsBuilder createAppyActionInstruction34() {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        SwPathActionBuilder swPathAction = new SwPathActionBuilder();
+        ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        InstructionBuilder ib = new InstructionBuilder();
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        // Put our Instruction in a list of Instructions
+        InstructionsBuilder isb = new InstructionsBuilder();
+        List<Instruction> instructions = new ArrayList<Instruction>();
+        instructions.add(ib.build());
+        isb.setInstruction(instructions);
+        return isb;
+    }
+
+    private static MatchBuilder createLLDPMatch() {
+        MatchBuilder match = new MatchBuilder();
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x88ccL));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+        return match;
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createMatch1() {
+        MatchBuilder match = new MatchBuilder();
+        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
+        ipv4Match.setIpv4Destination(prefix);
+        Ipv4Match i4m = ipv4Match.build();
+        match.setLayer3Match(i4m);
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+        return match;
+    }
+
+    private static MatchBuilder createMatch1000() {
+        MatchBuilder match = new MatchBuilder();
+        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        Ipv4Prefix prefix = new Ipv4Prefix("10.1.1.1/24");
+        ipv4Match.setIpv4Destination(prefix);
+        Ipv4Match i4m = ipv4Match.build();
+        match.setLayer3Match(i4m);
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+        return match;
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createMatch2() {
+        MatchBuilder match = new MatchBuilder();
+        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
+        ipv4Match.setIpv4Source(prefix);
+        Ipv4Match i4m = ipv4Match.build();
+        match.setLayer3Match(i4m);
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+        return match;
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createMatch3() {
+        MatchBuilder match = new MatchBuilder();
+        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+        EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+        ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
+        ethernetMatch.setEthernetSource(ethSourceBuilder.build());
+        match.setEthernetMatch(ethernetMatch.build());
+
+        return match;
+    }
+
+    private static MatchBuilder createMatch33() {
+
+        MatchBuilder match = new MatchBuilder();
+        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
+        ipv4Match.setIpv4Source(prefix);
+        Ipv4Match i4m = ipv4Match.build();
+        match.setLayer3Match(i4m);
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0xfffeL));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+        return match;
+    }
+
+    private static MatchBuilder createInphyportMatch(NodeId nodeId) {
+        MatchBuilder match = new MatchBuilder();
+        match.setInPort(new NodeConnectorId(nodeId + ":202"));
+        match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
+        return match;
+    }
+
+    private static MatchBuilder createEthernetMatch() {
+        MatchBuilder match = new MatchBuilder();
+
+        byte[] mask1 = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
+        byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
+
+        EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
+                                                                    // match
+        EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+        EtherType type = new EtherType(0x0800L);
+        ethmatch.setEthernetType(ethtype.setType(type).build());
+
+        EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
+                                                                               // macaddress
+                                                                               // match
+        MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
+        ethdest.setAddress(macdest);
+        // ethdest.setMask(mask1);
+
+        ethmatch.setEthernetDestination(ethdest.build());
+
+        EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
+        MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
+        ethsrc.setAddress(macsrc);
+        // ethsrc.setMask(mask2);
+
+        ethmatch.setEthernetSource(ethsrc.build());
+        match.setEthernetMatch(ethmatch.build());
+        return match;
+
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createL3IPv6Match() {
+        MatchBuilder match = new MatchBuilder();
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x86ddL));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+
+        Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
+        Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
+        Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
+        MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
+        MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
+        Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
+        nextheader.setIpv6Exthdr(58);
+        Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
+        Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
+        ipv6label.setIpv6Flabel(label);
+        // ipv6label.setFlabelMask(new byte[] { 0, 1, -1, -1 });
+
+        Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
+                                                                   // match
+        icmpv6match.setIcmpv6Type((short) 135);
+        icmpv6match.setIcmpv6Code((short) 0);
+        match.setIcmpv6Match(icmpv6match.build());
+
+        Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
+        // ipv6match.setIpv6Source(srcip6);
+        // ipv6match.setIpv6Destination(dstip6);
+        // ipv6match.setIpv6ExtHeader(nextheader.build());
+        ipv6match.setIpv6NdSll(ndsll);
+        ipv6match.setIpv6NdTll(ndtll);
+        // ipv6match.setIpv6NdTarget(ndtarget);
+        ipv6match.setIpv6Label(ipv6label.build());
+
+        match.setLayer3Match(ipv6match.build());
+
+        return match;
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createICMPv6Match() {
+
+        MatchBuilder match = new MatchBuilder();
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x86ddL));
+        eth.setEthernetType(ethTypeBuilder.build());
+        match.setEthernetMatch(eth.build());
+
+        IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+        ipmatch.setIpProtocol((short) 58);
+        match.setIpMatch(ipmatch.build());
+
+        Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
+                                                                   // match
+        icmpv6match.setIcmpv6Type((short) 135);
+        icmpv6match.setIcmpv6Code((short) 1);
+        match.setIcmpv6Match(icmpv6match.build());
+
+        return match;
+    }
+
+    /**
+     * @return
+     */
+    private static MatchBuilder createMetadataMatch() {
+        MatchBuilder match = new MatchBuilder();
+        byte[] metamask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
+        MetadataBuilder metadata = new MetadataBuilder(); // metadata match
+        metadata.setMetadata(BigInteger.valueOf(500L));
+        // metadata.setMetadataMask(metamask);
+        match.setMetadata(metadata.build());
+
+        return match;
+    }
+
+}
index 94869beec6f72db3c2733a89b69823ff01629889..8514b825f9458e1d844051bd3a6a828d5bb09c29 100644 (file)
@@ -61,10 +61,12 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
     private ProviderContext pc;
     private final BundleContext ctx;
     private Meter testMeter;
+    private Meter testMeter1;
+    private Meter testMeter2;
     private Node testNode;
     private final String originalMeterName = "Foo";
     private final String updatedMeterName = "Bar";
-    private MeterEventListener meterEventListener = new MeterEventListener();
+    private final MeterEventListener meterEventListener = new MeterEventListener();
     private static NotificationService notificationService;
     private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener1Reg;
 
@@ -79,7 +81,7 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
         notificationService = session.getSALService(NotificationService.class);
         // For switch events
         listener1Reg = notificationService.registerNotificationListener(meterEventListener);
-        
+
         createTestNode();
         createTestMeter();
     }
@@ -106,36 +108,36 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
 
         @Override
         public void onMeterAdded(MeterAdded notification) {
-            LOG.info("Meter to be added.........................."+notification.toString());
-            LOG.info("Meter  Xid........................."+notification.getTransactionId().getValue());
-            LOG.info("-----------------------------------------------------------------------------------");            
+            LOG.info("Meter to be added.........................." + notification.toString());
+            LOG.info("Meter  Xid........................." + notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");
         }
 
         @Override
         public void onMeterRemoved(MeterRemoved notification) {
-            LOG.info("Meter to be removed.........................."+notification.toString());
-            LOG.info("Meter  Xid........................."+notification.getTransactionId().getValue());
-            LOG.info("-----------------------------------------------------------------------------------");            
+            LOG.info("Meter to be removed.........................." + notification.toString());
+            LOG.info("Meter  Xid........................." + notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");
         }
 
         @Override
         public void onMeterUpdated(MeterUpdated notification) {
-            LOG.info("Meter to be updated.........................."+notification.toString());
-            LOG.info("Meter  Xid........................."+notification.getTransactionId().getValue());
-            LOG.info("-----------------------------------------------------------------------------------");            
+            LOG.info("Meter to be updated.........................." + notification.toString());
+            LOG.info("Meter  Xid........................." + notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");
         }
-        
+
     }
-    
+
     private MeterBuilder createTestMeter() {
         // Sample data , committing to DataStore
-        DataModification modification = dataBrokerService.beginTransaction();
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
 
         long id = 12;
         MeterKey key = new MeterKey(new MeterId(id));
         MeterBuilder meter = new MeterBuilder();
-        meter.setContainerName("abcd");     
-        meter.setKey(key);       
+        meter.setContainerName("abcd");
+        meter.setKey(key);
         meter.setMeterId(new MeterId(9L));
         meter.setMeterName(originalMeterName);
         meter.setFlags(new MeterFlags(true, false, false, false));
@@ -154,7 +156,7 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
         bandTypes.setFlags(bandType);
         bandHeader.setMeterBandTypes(bandTypes.build());
         bandHeader.setBandId(new BandId(0L));
-        bandHdr.add(bandHeader.build());       
+        bandHdr.add(bandHeader.build());
         bandHeaders.setMeterBandHeader(bandHdr);
         meter.setMeterBandHeaders(bandHeaders.build());
 
@@ -162,6 +164,62 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
         return meter;
     }
 
+    private MeterBuilder createTestMeters(String s1, String s2) {
+        // Sample data , committing to DataStore
+        long id = Integer.parseInt(s1);
+        MeterKey key = new MeterKey(new MeterId(id));
+        MeterBuilder meter = new MeterBuilder();
+        meter.setContainerName("abcd");
+        meter.setKey(key);
+        meter.setMeterId(new MeterId(9L));
+        MeterBandHeaderBuilder bandHeader = new MeterBandHeaderBuilder();
+        if (s2.equalsIgnoreCase("modify")) {
+            meter.setMeterName(updatedMeterName);
+            bandHeader.setBandRate((long) 234);
+        } else {
+            meter.setMeterName(originalMeterName);
+            bandHeader.setBandRate((long) 123);
+        }
+        meter.setFlags(new MeterFlags(true, false, false, false));
+        MeterBandHeadersBuilder bandHeaders = new MeterBandHeadersBuilder();
+        List<MeterBandHeader> bandHdr = new ArrayList<MeterBandHeader>();
+
+        bandHeader.setBandBurstSize((long) 444);
+        DscpRemarkBuilder dscpRemark = new DscpRemarkBuilder();
+        dscpRemark.setDscpRemarkBurstSize((long) 5);
+        dscpRemark.setPercLevel((short) 1);
+        dscpRemark.setDscpRemarkRate((long) 12);
+        bandHeader.setBandType(dscpRemark.build());
+        MeterBandTypesBuilder bandTypes = new MeterBandTypesBuilder();
+        MeterBandType bandType = new MeterBandType(false, true, false);
+        bandTypes.setFlags(bandType);
+        bandHeader.setMeterBandTypes(bandTypes.build());
+        bandHeader.setBandId(new BandId(0L));
+        bandHdr.add(bandHeader.build());
+        bandHeaders.setMeterBandHeader(bandHdr);
+        meter.setMeterBandHeaders(bandHeaders.build());
+
+        if (Integer.parseInt(s1) == 1) {
+            testMeter1 = meter.build();
+        } else if (Integer.parseInt(s1) == 2) {
+            testMeter2 = meter.build();
+        } else if (Integer.parseInt(s1) == 3) {
+            testMeter1 = meter.build();
+        } else if (Integer.parseInt(s1) == 4) {
+            testMeter2 = meter.build();
+        } else if (Integer.parseInt(s1) == 5) {
+            testMeter1 = meter.build();
+        } else if (Integer.parseInt(s1) == 6) {
+            testMeter2 = meter.build();
+        } else if (Integer.parseInt(s1) == 7) {
+            testMeter1 = meter.build();
+        } else if (Integer.parseInt(s1) == 8) {
+            testMeter2 = meter.build();
+        }
+
+        return meter;
+    }
+
     public void _removeMeter(CommandInterpreter ci) {
         String nref = ci.nextArgument();
 
@@ -173,11 +231,9 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
             createUserNode(nref);
         }
         MeterBuilder mBuilder = createTestMeter();
-        DataModification modification = dataBrokerService.beginTransaction();
-        InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
-                .child(Meter.class, new MeterKey(testMeter.getMeterId()))
-                .build();
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
+        InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
+                .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter.getMeterId())).build();
         modification.removeConfigurationData(path1);
         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
         try {
@@ -194,6 +250,88 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
         }
     }
 
+    public void _removeMeters(CommandInterpreter ci) {
+        String nref = ci.nextArgument();
+
+        if (nref == null) {
+            ci.println("test node added");
+            createTestNode();
+        } else {
+            ci.println("User node added" + nref);
+            createUserNode(nref);
+        }
+
+        Integer count = Integer.parseInt(ci.nextArgument());
+
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
+        switch (count) {
+        case 1:
+            MeterBuilder mBuilder = createTestMeters("1", "remove");
+            InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Meter.class, new MeterKey(testMeter1.getMeterId())).build();
+            modification.removeConfigurationData(path1);
+            MeterBuilder mBuilder1 = createTestMeters("2", "remove");
+            InstanceIdentifier<Meter> path2 = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Meter.class, new MeterKey(testMeter2.getMeterId())).build();
+            modification.removeConfigurationData(path2);
+
+            break;
+        case 2:
+            MeterBuilder mBuilder2 = createTestMeters("3", "remove");
+            InstanceIdentifier<Meter> path3 = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Meter.class, new MeterKey(testMeter1.getMeterId())).build();
+            modification.removeConfigurationData(path3);
+            MeterBuilder mBuilder22 = createTestMeters("4", "remove");
+            InstanceIdentifier<Meter> path4 = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Meter.class, new MeterKey(testMeter2.getMeterId())).build();
+            modification.removeConfigurationData(path4);
+            break;
+        case 3:
+            MeterBuilder mBuilder3 = createTestMeters("5", "remove");
+            InstanceIdentifier<Meter> path5 = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Meter.class, new MeterKey(testMeter1.getMeterId())).build();
+            modification.removeConfigurationData(path5);
+            MeterBuilder mBuilder4 = createTestMeters("6", "remove");
+            InstanceIdentifier<Meter> path6 = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Meter.class, new MeterKey(testMeter2.getMeterId())).build();
+            modification.removeConfigurationData(path6);
+            break;
+        case 4:
+            MeterBuilder mBuilder5 = createTestMeters("7", "remove");
+            InstanceIdentifier<Meter> path7 = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Meter.class, new MeterKey(testMeter1.getMeterId())).build();
+            modification.removeConfigurationData(path7);
+            MeterBuilder mBuilder6 = createTestMeters("8", "remove");
+            InstanceIdentifier<Meter> path8 = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Meter.class, new MeterKey(testMeter2.getMeterId())).build();
+            modification.removeConfigurationData(path8);
+            break;
+
+        }
+
+        Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+        try {
+            RpcResult<TransactionStatus> result = commitFuture.get();
+            TransactionStatus status = result.getResult();
+            ci.println("Status of Meter Data Loaded Transaction: " + status);
+
+        } catch (InterruptedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ExecutionException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
     public void _addMeter(CommandInterpreter ci) {
         String nref = ci.nextArgument();
 
@@ -208,15 +346,79 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
         writeMeter(ci, testMeter);
     }
 
+    public void _addMeters(CommandInterpreter ci) {
+        String nref = ci.nextArgument();
+
+        if (nref == null) {
+            ci.println("test node added");
+            createTestNode();
+        } else {
+            ci.println("User node added" + nref);
+            createUserNode(nref);
+        }
+        Integer count = Integer.parseInt(ci.nextArgument());
+        switch (count) {
+        case 1:
+            createTestMeters("1", "add");
+            createTestMeters("2", "add");
+            writeMeter(ci, testMeter1, testMeter2);
+            break;
+        case 2:
+            createTestMeters("3", "add");
+            createTestMeters("4", "add");
+            writeMeter(ci, testMeter1, testMeter2);
+            break;
+        case 3:
+            createTestMeters("5", "add");
+            createTestMeters("6", "add");
+            writeMeter(ci, testMeter1, testMeter2);
+            break;
+        case 4:
+            createTestMeters("7", "add");
+            createTestMeters("8", "add");
+            writeMeter(ci, testMeter1, testMeter2);
+            break;
+
+        }
+        // createTestMeters();
+        // writeMeter(ci, testMeter);
+    }
+
     private void writeMeter(CommandInterpreter ci, Meter meter) {
-        DataModification modification = dataBrokerService.beginTransaction();
-        InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
-                .child(Meter.class, new MeterKey(meter.getMeterId()))
-                .build();
-        DataObject cls = (DataObject) modification.readConfigurationData(path1);
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
+        InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
+                .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId())).build();
+        DataObject cls = modification.readConfigurationData(path1);
+        modification.putConfigurationData(nodeToInstanceId(testNode), testNode);
+        modification.putConfigurationData(path1, meter);
+        Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+        try {
+            RpcResult<TransactionStatus> result = commitFuture.get();
+            TransactionStatus status = result.getResult();
+            ci.println("Status of Meter Data Loaded Transaction: " + status);
+
+        } catch (InterruptedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ExecutionException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    private void writeMeter(CommandInterpreter ci, Meter meter, Meter meter1) {
+        DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
+        InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
+                .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId())).build();
+        DataObject cls = modification.readConfigurationData(path1);
         modification.putConfigurationData(nodeToInstanceId(testNode), testNode);
         modification.putConfigurationData(path1, meter);
+        InstanceIdentifier<Meter> path2 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
+                .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter1.getMeterId())).build();
+        DataObject cls1 = modification.readConfigurationData(path2);
+        modification.putConfigurationData(nodeToInstanceId(testNode), testNode);
+        modification.putConfigurationData(path2, meter1);
+
         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
         try {
             RpcResult<TransactionStatus> result = commitFuture.get();
@@ -249,6 +451,32 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
         writeMeter(ci, meter.build());
     }
 
+    public void _modifyMeters(CommandInterpreter ci) {
+        String nref = ci.nextArgument();
+
+        if (nref == null) {
+            ci.println("test node added");
+            createTestNode();
+        } else {
+            ci.println("User node added" + nref);
+            createUserNode(nref);
+        }
+
+        Integer count = Integer.parseInt(ci.nextArgument());
+        switch (count) {
+        case 1:
+            createTestMeters("1", "modify");
+            createTestMeters("2", "modify");
+            writeMeter(ci, testMeter1, testMeter2);
+            break;
+        case 2:
+            createTestMeters("3", "modify");
+            createTestMeters("4", "modify");
+            writeMeter(ci, testMeter1, testMeter2);
+            break;
+        }
+    }
+
     @Override
     public String getHelp() {
         StringBuffer help = new StringBuffer();
index 743b0efe907dbcc3dde539a8a75cb531f15fc45b..809a3bb336d5e9b63b3af2dc48610545c5d91ab4 100644 (file)
@@ -26,6 +26,8 @@ class OpenflowpluginTestActivator extends AbstractBindingAwareProvider {
     var OpenflowpluginStatsTestCommandProvider cmdStatsProvider;
     var OpenflowpluginTestNodeConnectorNotification cmdNodeConnectorNotification;
     var OpenflowpluginTestTopologyNotification cmdTopologyNotification;
+    var OpenflowPluginBulkTransactionProvider bulkCmdProvider;
+    var OpenflowPluginBulkGroupTransactionProvider groupCmdProvider;
     public static final String NODE_ID =  "foo:node:1";
 
     override onSessionInitiated(ProviderContext session) {
@@ -43,6 +45,8 @@ class OpenflowpluginTestActivator extends AbstractBindingAwareProvider {
         cmdStatsProvider.onSessionInitiated(session);      
         cmdNodeConnectorNotification.onSessionInitiated(session);
         cmdTopologyNotification.onSessionInitiated(session);
+        bulkCmdProvider.onSessionInitiated(session);
+        groupCmdProvider.onSessionInitiated(session);
     }
     
     override startImpl(BundleContext ctx) {
@@ -54,6 +58,8 @@ class OpenflowpluginTestActivator extends AbstractBindingAwareProvider {
         cmdStatsProvider = new OpenflowpluginStatsTestCommandProvider(ctx);
         cmdNodeConnectorNotification = new OpenflowpluginTestNodeConnectorNotification(ctx);
        cmdTopologyNotification = new OpenflowpluginTestTopologyNotification(ctx);
+       bulkCmdProvider = new OpenflowPluginBulkTransactionProvider(ctx);
+       groupCmdProvider = new OpenflowPluginBulkGroupTransactionProvider(ctx);
     }
 
     override protected stopImpl(BundleContext context) {