*/
package org.opendaylight.netvirt.aclservice;
+import com.google.common.util.concurrent.ListenableFuture;
+
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
import org.opendaylight.genius.mdsalutil.ActionInfo;
import org.opendaylight.genius.mdsalutil.InstructionInfo;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MatchInfo;
import org.opendaylight.genius.mdsalutil.MatchInfoBase;
+import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.actions.ActionDrop;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
int instructionKey = 0;
List<Instruction> instructions = new ArrayList<>();
+ Long elanTag = AclServiceUtils.getElanIdFromInterface(interfaceName, dataBroker);
+ instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(MetaDataUtil.getElanTagMetadata(elanTag),
+ MetaDataUtil.METADATA_MASK_SERVICE, ++instructionKey));
instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.INGRESS_ACL_TABLE, ++instructionKey));
short serviceIndex = ServiceIndex.getIndex(NwConstants.ACL_SERVICE_NAME, NwConstants.ACL_SERVICE_INDEX);
BoundServices serviceInfo =
- AclServiceUtils.getBoundServices(String.format("%s.%s.%s", "vpn", "egressacl", interfaceName),
+ AclServiceUtils.getBoundServices(String.format("%s.%s.%s", "acl", "egressacl", interfaceName),
serviceIndex, flowPriority, AclConstants.COOKIE_ACL_BASE, instructions);
InstanceIdentifier<BoundServices> path =
AclServiceUtils.buildServiceId(interfaceName, serviceIndex, ServiceModeIngress.class);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, path, serviceInfo);
+
+ DataStoreJobCoordinator dataStoreCoordinator = DataStoreJobCoordinator.getInstance();
+ dataStoreCoordinator.enqueueJob(interfaceName,
+ () -> {
+ WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
+ writeTxn.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo, true);
+
+ List<ListenableFuture<Void>> futures = new ArrayList<>();
+ futures.add(writeTxn.submit());
+ return futures;
+ });
}
/**
AclServiceUtils.buildServiceId(interfaceName,
ServiceIndex.getIndex(NwConstants.ACL_SERVICE_NAME, NwConstants.ACL_SERVICE_INDEX),
ServiceModeIngress.class);
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
+
+ DataStoreJobCoordinator dataStoreCoordinator = DataStoreJobCoordinator.getInstance();
+ dataStoreCoordinator.enqueueJob(interfaceName,
+ () -> {
+ WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
+ writeTxn.delete(LogicalDatastoreType.CONFIGURATION, path);
+
+ List<ListenableFuture<Void>> futures = new ArrayList<>();
+ futures.add(writeTxn.submit());
+ return futures;
+ });
}
@Override
aclUuidList, dpId);
return false;
}
- for (Uuid sgUuid :aclUuidList ) {
+ for (Uuid sgUuid :aclUuidList) {
Acl acl = AclServiceUtils.getAcl(dataBroker, sgUuid.getValue());
if (null == acl) {
LOG.warn("The ACL is empty");
if (syncAllowedAddresses != null) {
flowMap = AclServiceUtils.getFlowForAllowedAddresses(syncAllowedAddresses, flowMap, false);
} else if (aceAttr.getRemoteGroupId() != null) {
- flowMap = aclServiceUtils.getFlowForRemoteAcl(aceAttr.getRemoteGroupId(), portId, flowMap,
- false);
+ flowMap = aclServiceUtils.getFlowForRemoteAcl(aceAttr.getRemoteGroupId(), portId, flowMap, false);
}
}
if (null == flowMap) {
LOG.error("Failed to apply ACL {} lportTag {}", ace.getKey(), lportTag);
return;
}
- int priority = this.aclDataUtil.getAclFlowPriority(aclName);
- // The flow map contains list of flows if port range is selected.
for (String flowName : flowMap.keySet()) {
- flowName = syncSpecificAclFlow(dpId, lportTag, addOrRemove, priority, ace, portId, flowMap, flowName);
+ syncSpecificAclFlow(dpId, lportTag, addOrRemove, ace, portId, flowMap, flowName);
}
}
- protected abstract String syncSpecificAclFlow(BigInteger dpId, int lportTag, int addOrRemove, int priority, Ace ace,
+ protected abstract String syncSpecificAclFlow(BigInteger dpId, int lportTag, int addOrRemove, Ace ace,
String portId, Map<String, List<MatchInfoBase>> flowMap, String flowName);
/**
List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions(new ArrayList<>());
- String flowName = "Egress_ARP_" + dpId + "_" + attachMac.getValue();
+ String flowName = "Egress_ARP_" + dpId + "_" + lportTag + "_" + attachMac.getValue();
syncFlow(dpId, NwConstants.INGRESS_ACL_TABLE, flowName,
AclConstants.PROTO_ARP_TRAFFIC_MATCH_PRIORITY, "ACL", 0, 0,
AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);