ELAN FT Support for BE
[vpnservice.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / vpnservice / mdsalutil / MDSALUtil.java
index 1d10a69aca89c0432ba754c4cd27936ac1c1ec45..27afd5c35c72ff6987db65c35aa625dd207fa231 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -38,9 +38,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M
 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.ApplyActionsCase;
 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.WriteMetadataCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions;
 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.write.metadata._case.WriteMetadataBuilder;
 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;
@@ -244,7 +246,7 @@ public class MDSALUtil {
         return EMPTY_Instructions;
     }
 
-    protected static Match buildMatches(List<MatchInfo> listMatchInfo) {
+    public static Match buildMatches(List<MatchInfo> listMatchInfo) {
         if (listMatchInfo != null) {
             MatchBuilder matchBuilder = new MatchBuilder();
             Map<Class<?>, Object> mapMatchBuilder = new HashMap<Class<?>, Object>();
@@ -361,6 +363,14 @@ public class MDSALUtil {
                                 .build()).setKey(new InstructionKey(instructionKey)).build();
     }
 
+    public static Instruction buildAndGetGotoTableInstruction(short tableId, int instructionKey) {
+        return new InstructionBuilder()
+            .setInstruction(
+                new GoToTableCaseBuilder().setGoToTable(
+                    new GoToTableBuilder().setTableId(tableId).build()).build())
+            .setKey(new InstructionKey(instructionKey)).build();
+    }
+
     public static <T extends DataObject> Optional<T> read(LogicalDatastoreType datastoreType,
                                                           InstanceIdentifier<T> path, DataBroker broker) {
 
@@ -473,8 +483,11 @@ public class MDSALUtil {
             NodeConnectorRef ref) {
         Optional<NodeConnector> nc = (Optional<NodeConnector>) read(
                 dataBroker,
-                LogicalDatastoreType.CONFIGURATION, ref.getValue());
-        return nc.get().getId();
+                LogicalDatastoreType.OPERATIONAL, ref.getValue());
+        if(nc.isPresent()){
+            return nc.get().getId();
+        }
+        return null;
     }
 
 }