From 74d4567749f6669cd6d1a8a54f825ae65d01f931 Mon Sep 17 00:00:00 2001 From: yair Date: Thu, 25 Aug 2016 12:52:16 +0300 Subject: [PATCH] Fixed the use of index NwConstants 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 --- .../aclservice/AbstractIngressAclServiceImpl.java | 10 +++++++--- .../cloudservicechain/listeners/NodeListener.java | 9 +++++---- .../utils/ElanServiceChainUtils.java | 7 ++++--- .../utils/VpnServiceChainUtils.java | 13 +++++++------ .../netvirt/vpnmanager/VpnInterfaceManager.java | 10 +++++----- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AbstractIngressAclServiceImpl.java b/vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AbstractIngressAclServiceImpl.java index 4b5744c2cf..50528d4718 100644 --- a/vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AbstractIngressAclServiceImpl.java +++ b/vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AbstractIngressAclServiceImpl.java @@ -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 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 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 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); } diff --git a/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/listeners/NodeListener.java b/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/listeners/NodeListener.java index 6358986fa5..699f6feb4b 100644 --- a/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/listeners/NodeListener.java +++ b/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/listeners/NodeListener.java @@ -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 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 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 instructions = Arrays.asList(MDSALUtil.buildAndGetWriteMetadaInstruction(metadataToWrite, diff --git a/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/ElanServiceChainUtils.java b/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/ElanServiceChainUtils.java index 0042d63dfc..57ee348546 100644 --- a/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/ElanServiceChainUtils.java +++ b/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/ElanServiceChainUtils.java @@ -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 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 instructions = Arrays.asList( @@ -145,7 +146,7 @@ public class ElanServiceChainUtils { List 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 instructions = Arrays.asList( @@ -220,7 +221,7 @@ public class ElanServiceChainUtils { public static List 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 result = Arrays.asList(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, MetaDataUtil.getMetaDataMaskForLPortDispatcher(), diff --git a/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/VpnServiceChainUtils.java b/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/VpnServiceChainUtils.java index 2ad53cb867..c9af14039d 100644 --- a/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/VpnServiceChainUtils.java +++ b/vpnservice/cloud-servicechain/cloud-servicechain-impl/src/main/java/org/opendaylight/netvirt/cloudservicechain/utils/VpnServiceChainUtils.java @@ -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 matches = buildMatchOnLportTagAndSI(lportTag, NwConstants.L3VPN_SERVICE_INDEX); + List matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)); List instructions = buildSetVrfTagAndGotoFibInstructions(vpnId.intValue()); String flowRef = getScfToL3VpnLportDispatcherFlowRef(lportTag); @@ -307,7 +308,7 @@ public class VpnServiceChainUtils { List 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 matches = buildMatchOnLportTagAndSI(lportTag, NwConstants.SCF_SERVICE_INDEX); + List matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX)); List instructions = new ArrayList(); 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 matches = buildMatchOnLportTagAndSI(dstLportTag, NwConstants.L3VPN_SERVICE_INDEX); + List matches = buildMatchOnLportTagAndSI(dstLportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)); List 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(); } diff --git a/vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java b/vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java index 601b373a69..8729173585 100644 --- a/vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java +++ b/vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java @@ -531,18 +531,18 @@ public class VpnInterfaceManager extends AbstractDataChangeListener> futures = new ArrayList>(); 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> futures = new ArrayList>(); futures.add(writeTxn.submit()); -- 2.36.6