Fixed the use of index NwConstants 53/44853/1
authoryair <yair.zinger@hpe.com>
Thu, 25 Aug 2016 09:52:16 +0000 (12:52 +0300)
committerSam Hague <shague@redhat.com>
Tue, 30 Aug 2016 13:39:22 +0000 (13:39 +0000)
There was a change to support L2 before L3
https://git.opendaylight.org/gerrit/#/c/43126/
Change the use of constnats to the new way of work

Change-Id: I493e80fac8c49d667cf7d9a498d0f7a82892b687
Signed-off-by: yair <yair.zinger@hpe.com>
vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AbstractIngressAclServiceImpl.java
vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/listeners/NodeListener.java
vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/ElanServiceChainUtils.java
vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/VpnServiceChainUtils.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java

index 4b5744c2cfec2dbc633f87c15c9b13e24264e1ae..50528d471858b07aadc546e9cb19d120a50ceb30 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.genius.mdsalutil.MatchInfo;
 import org.opendaylight.genius.mdsalutil.MatchInfoBase;
 import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.genius.utils.ServiceIndex;
 import org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action;
 import org.opendaylight.netvirt.aclservice.utils.AclConstants;
 import org.opendaylight.netvirt.aclservice.utils.AclServiceOFFlowBuilder;
@@ -78,10 +79,12 @@ public abstract class AbstractIngressAclServiceImpl extends AbstractAclServiceIm
         List<Instruction> instructions = new ArrayList<>();
         instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.EGRESS_ACL_TABLE, ++instructionKey));
         BoundServices serviceInfo = AclServiceUtils.getBoundServices(
-                String.format("%s.%s.%s", "vpn", "ingressacl", interfaceName), NwConstants.EGRESS_ACL_SERVICE_INDEX,
+                String.format("%s.%s.%s", "vpn", "ingressacl", interfaceName),
+                ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX),
                 flowPriority, AclConstants.COOKIE_ACL_BASE, instructions);
         InstanceIdentifier<BoundServices> path = AclServiceUtils.buildServiceId(interfaceName,
-                NwConstants.EGRESS_ACL_SERVICE_INDEX, ServiceModeEgress.class);
+                ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME,
+                        NwConstants.EGRESS_ACL_SERVICE_INDEX), ServiceModeEgress.class);
         MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, path, serviceInfo);
     }
 
@@ -93,7 +96,8 @@ public abstract class AbstractIngressAclServiceImpl extends AbstractAclServiceIm
     @Override
     protected void unbindService(String interfaceName) {
         InstanceIdentifier<BoundServices> path = AclServiceUtils.buildServiceId(interfaceName,
-                NwConstants.EGRESS_ACL_SERVICE_INDEX, ServiceModeEgress.class);
+                ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX),
+                ServiceModeEgress.class);
         MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
     }
 
index 6358986fa588d52967005c4920aceab0da09b3bf..699f6feb4b0dc9c71cf9dd1adbc24c10ce3dab7d 100644 (file)
@@ -13,15 +13,16 @@ import java.util.List;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.mdsalutil.AbstractDataChangeListener;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.genius.mdsalutil.MatchInfo;
 import org.opendaylight.genius.mdsalutil.MatchFieldType;
+import org.opendaylight.genius.mdsalutil.MatchInfo;
 import org.opendaylight.genius.mdsalutil.MetaDataUtil;
 import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.genius.utils.ServiceIndex;
 import org.opendaylight.netvirt.cloudservicechain.CloudServiceChainConstants;
 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.Flow;
@@ -114,12 +115,12 @@ public class NodeListener extends AbstractDataChangeListener<Node> implements Au
 
         logger.debug("Installing L3VPN to ELAN default Fallback flow in LPortDispatcher table");
         BigInteger[] metadataToMatch = new BigInteger[] {
-                MetaDataUtil.getServiceIndexMetaData(NwConstants.L3VPN_SERVICE_INDEX),
+                MetaDataUtil.getServiceIndexMetaData(ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)),
                 MetaDataUtil.METADATA_MASK_SERVICE_INDEX
         };
         List<MatchInfo> matches = Arrays.asList(new MatchInfo(MatchFieldType.metadata, metadataToMatch));
 
-        BigInteger metadataToWrite = MetaDataUtil.getServiceIndexMetaData(NwConstants.ELAN_SERVICE_INDEX);
+        BigInteger metadataToWrite = MetaDataUtil.getServiceIndexMetaData(ServiceIndex.getIndex(NwConstants.ELAN_SERVICE_NAME, NwConstants.ELAN_SERVICE_INDEX));
         int instructionKey = 0;
         List<Instruction> instructions =
                 Arrays.asList(MDSALUtil.buildAndGetWriteMetadaInstruction(metadataToWrite,
index 0042d63dfc28fada7230c135689a2c389c325f66..57ee348546a0445658c14083a1cd90e7d33a1418 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.genius.utils.ServiceIndex;
 import org.opendaylight.genius.mdsalutil.MatchFieldType;
 import org.opendaylight.genius.mdsalutil.MatchInfo;
 import java.util.Arrays;
@@ -103,7 +104,7 @@ public class ElanServiceChainUtils {
             List<MatchInfo> matches = Arrays.asList(
                     new MatchInfo(MatchFieldType.metadata,
                             new BigInteger[] { MetaDataUtil.getMetaDataForLPortDispatcher(elanLportTag,
-                                    NwConstants.SCF_SERVICE_INDEX),
+                                    ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX)),
                                     MetaDataUtil.getMetaDataMaskForLPortDispatcher() }));
             int instructionKey = 0;
             List<Instruction> instructions = Arrays.asList(
@@ -145,7 +146,7 @@ public class ElanServiceChainUtils {
             List<MatchInfo> matches = Arrays.asList(
                     new MatchInfo(MatchFieldType.metadata,
                             new BigInteger[] { MetaDataUtil.getMetaDataForLPortDispatcher(elanLportTag,
-                                    NwConstants.ELAN_SERVICE_INDEX),
+                                    ServiceIndex.getIndex(NwConstants.ELAN_SERVICE_NAME, NwConstants.ELAN_SERVICE_INDEX)),
                                     MetaDataUtil.getMetaDataMaskForLPortDispatcher() }));
             int instructionKey = 0;
             List<Instruction> instructions = Arrays.asList(
@@ -220,7 +221,7 @@ public class ElanServiceChainUtils {
     public static List<Instruction> buildSetLportTagAndGotoLportDispInstructions(long lportTag) {
         int instructionKey = 0;
         BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher((int) lportTag,
-                NwConstants.SCF_SERVICE_INDEX);
+                ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX));
         List<Instruction> result =
                 Arrays.asList(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata,
                         MetaDataUtil.getMetaDataMaskForLPortDispatcher(),
index 2ad53cb86796493900f73208f70330adf914f7d1..c9af14039d35f39f9ccddcba52ff52120b9e128f 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.genius.mdsalutil.MatchInfo;
 import org.opendaylight.genius.mdsalutil.MetaDataUtil;
 import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.genius.utils.ServiceIndex;
 import org.opendaylight.netvirt.cloudservicechain.CloudServiceChainConstants;
 import org.opendaylight.netvirt.vpnmanager.VpnConstants;
 import org.opendaylight.netvirt.vpnmanager.VpnUtil;
@@ -232,7 +233,7 @@ public class VpnServiceChainUtils {
                                                         int addOrRemove) {
         logger.info("buildLPortDispFlowForScf vpnId={} dpId={} lportTag={} addOrRemove={} ",
                     vpnId, dpId, lportTag, addOrRemove);
-        List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, NwConstants.L3VPN_SERVICE_INDEX);
+        List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX));
         List<Instruction> instructions = buildSetVrfTagAndGotoFibInstructions(vpnId.intValue());
 
         String flowRef = getScfToL3VpnLportDispatcherFlowRef(lportTag);
@@ -307,7 +308,7 @@ public class VpnServiceChainUtils {
         List<InstructionInfo> instructions = new ArrayList<>();
         instructions.add(new InstructionInfo(InstructionType.write_metadata,
                 new BigInteger[]{
-                       MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, NwConstants.SCF_SERVICE_INDEX),
+                       MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX)),
                        MetaDataUtil.getMetaDataMaskForLPortDispatcher()
                 }));
 
@@ -386,7 +387,7 @@ public class VpnServiceChainUtils {
      */
     public static FlowEntity buildLportFlowDispForVpnToScf(BigInteger dpId, Integer lportTag, int scfTag,
                                                            short gotoTableId) {
-        List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, NwConstants.SCF_SERVICE_INDEX);
+        List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX));
         List<InstructionInfo> instructions = new ArrayList<InstructionInfo>();
         instructions.add(new InstructionInfo(InstructionType.write_metadata, new BigInteger[] {
                 VpnServiceChainUtils.getMetadataSCF(scfTag), CloudServiceChainConstants.METADATA_MASK_SCF_WRITE
@@ -458,7 +459,7 @@ public class VpnServiceChainUtils {
      * @return
      */
     public static Flow buildLPortDispFlowForVpntoVpn(Integer dstLportTag, Integer vpnTag) {
-        List<MatchInfo> matches = buildMatchOnLportTagAndSI(dstLportTag, NwConstants.L3VPN_SERVICE_INDEX);
+        List<MatchInfo> matches = buildMatchOnLportTagAndSI(dstLportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX));
         List<Instruction> instructions = buildSetVrfTagAndGotoFibInstructions(vpnTag);
         String flowRef = getL3VpnToL3VpnLportDispFlowRef(dstLportTag, vpnTag);
         Flow result = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef,
@@ -600,7 +601,7 @@ public class VpnServiceChainUtils {
      */
     public static String getL3VpnToScfLportDispatcherFlowRef(Integer lportTag) {
         return new StringBuffer(64).append(CloudServiceChainConstants.VPN_PSEUDO_VPN2SCF_FLOWID_PREFIX).append(lportTag)
-                                   .append(NwConstants.FLOWID_SEPARATOR).append(NwConstants.SCF_SERVICE_INDEX)
+                                   .append(NwConstants.FLOWID_SEPARATOR).append(ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX))
                                    .append(NwConstants.FLOWID_SEPARATOR)
                                    .append(CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY).toString();
     }
@@ -614,7 +615,7 @@ public class VpnServiceChainUtils {
      */
     public static String getScfToL3VpnLportDispatcherFlowRef(Integer lportTag) {
         return new StringBuffer().append(CloudServiceChainConstants.VPN_PSEUDO_SCF2VPN_FLOWID_PREFIX).append(lportTag)
-                                 .append(NwConstants.FLOWID_SEPARATOR).append(NwConstants.L3VPN_SERVICE_INDEX)
+                                 .append(NwConstants.FLOWID_SEPARATOR).append(ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX))
                                  .append(NwConstants.FLOWID_SEPARATOR)
                                  .append(CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY).toString();
     }
index 601b373a69e7b713033f817f1a5de8f7e01e1e8f..872917358567313a5e89cbb998510d1c5a6e63f7 100644 (file)
@@ -531,18 +531,18 @@ public class VpnInterfaceManager extends AbstractDataChangeListener<VpnInterface
                         BoundServices
                                 serviceInfo =
                                 InterfaceUtils.getBoundServices(String.format("%s.%s.%s", "vpn",vpnInstanceName, vpnInterfaceName),
-                                        NwConstants.L3VPN_SERVICE_INDEX, priority,
+                                        ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX), priority,
                                         NwConstants.COOKIE_VM_INGRESS_TABLE, instructions);
                         writeTxn.put(LogicalDatastoreType.CONFIGURATION,
-                                InterfaceUtils.buildServiceId(vpnInterfaceName, NwConstants.L3VPN_SERVICE_INDEX), serviceInfo, true);
+                                InterfaceUtils.buildServiceId(vpnInterfaceName, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)), serviceInfo, true);
                         List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
                         futures.add(writeTxn.submit());
                         return futures;
                     }
                 });
-        makeArpFlow(dpId, NwConstants.L3VPN_SERVICE_INDEX, lPortTag, vpnInterfaceName,
+        makeArpFlow(dpId, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX), lPortTag, vpnInterfaceName,
                 vpnId, ArpReplyOrRequest.REQUEST, NwConstants.ADD_FLOW, writeInvTxn);
-        makeArpFlow(dpId, NwConstants.L3VPN_SERVICE_INDEX, lPortTag, vpnInterfaceName,
+        makeArpFlow(dpId, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX), lPortTag, vpnInterfaceName,
                 vpnId, ArpReplyOrRequest.REPLY, NwConstants.ADD_FLOW, writeInvTxn);
 
     }
@@ -1256,7 +1256,7 @@ public class VpnInterfaceManager extends AbstractDataChangeListener<VpnInterface
                             WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
                             writeTxn.delete(LogicalDatastoreType.CONFIGURATION,
                                     InterfaceUtils.buildServiceId(vpnInterfaceName,
-                                            NwConstants.L3VPN_SERVICE_INDEX));
+                                            ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)));
 
                             List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
                             futures.add(writeTxn.submit());