use of org.opendaylight.netvirt.aclservice.api.utils.AclInterface in project netvirt by opendaylight.
the class AclInterfaceCacheImpl method updateIfPresent.
@Override
public AclInterface updateIfPresent(String interfaceId, BiFunction<AclInterface, AclInterface.Builder, Boolean> updateFunction) {
final AtomicBoolean updated = new AtomicBoolean(false);
AclInterface aclInterface = cache.computeIfPresent(interfaceId, (key, prevAclInterface) -> {
Builder builder = AclInterface.builder(prevAclInterface);
updated.set(updateFunction.apply(prevAclInterface, builder));
return builder.build();
});
return updated.get() ? aclInterface : null;
}
use of org.opendaylight.netvirt.aclservice.api.utils.AclInterface in project netvirt by opendaylight.
the class DisplayAclDataCaches method getAclInterfaceMap.
protected void getAclInterfaceMap() {
if (all == null && uuidStr == null) {
printAclInterfaceMapHelp();
} else if (all == null) {
Uuid uuid;
try {
uuid = Uuid.getDefaultInstance(uuidStr);
} catch (IllegalArgumentException e) {
session.getConsole().println("Invalid uuid" + e.getMessage());
log.error("Invalid uuid", e);
return;
}
Collection<AclInterface> aclInterfaceList = aclDataCache.getInterfaceList(uuid);
if (aclInterfaceList == null || aclInterfaceList.isEmpty()) {
session.getConsole().println("UUID not matched");
} else {
session.getConsole().println(ACL_INT_HEAD);
session.getConsole().print(String.format(KEY_TAB, uuid.toString()));
for (AclInterface aclInterface : aclInterfaceList) {
session.getConsole().println(String.format(ACL_INT_TAB, aclInterface.isPortSecurityEnabled(), aclInterface.getInterfaceId(), aclInterface.getLPortTag(), aclInterface.getDpId(), aclInterface.getElanId(), aclInterface.getSecurityGroups(), aclInterface.getAllowedAddressPairs(), aclInterface.getSubnetIpPrefixes(), aclInterface.isMarkedForDelete()));
}
}
} else if (uuidStr == null) {
if (!validateAll()) {
printAclInterfaceMapHelp();
return;
}
Map<Uuid, Collection<AclInterface>> map = aclDataCache.getAclInterfaceMap();
if (map.isEmpty()) {
session.getConsole().println("No data found");
} else {
session.getConsole().println(ACL_INT_HEAD);
for (Entry<Uuid, Collection<AclInterface>> entry : map.entrySet()) {
session.getConsole().print(String.format(KEY_TAB, entry.getKey().toString()));
for (AclInterface aclInterface : entry.getValue()) {
session.getConsole().println(String.format(ACL_INT_TAB, aclInterface.isPortSecurityEnabled(), aclInterface.getInterfaceId(), aclInterface.getLPortTag(), aclInterface.getDpId(), aclInterface.getElanId(), aclInterface.getSecurityGroups(), aclInterface.getAllowedAddressPairs(), aclInterface.getSubnetIpPrefixes(), aclInterface.isMarkedForDelete()));
}
}
}
}
}
use of org.opendaylight.netvirt.aclservice.api.utils.AclInterface in project netvirt by opendaylight.
the class AclServiceUtils method addAclPortsLookup.
public List<ListenableFuture<Void>> addAclPortsLookup(AclInterface port, List<Uuid> aclList, List<AllowedAddressPairs> allowedAddresses) {
String portId = port.getInterfaceId();
LOG.trace("Adding AclPortsLookup for port={}, acls={}, AAPs={}", portId, aclList, allowedAddresses);
if (aclList == null || allowedAddresses == null || allowedAddresses.isEmpty()) {
LOG.warn("aclList or allowedAddresses is null. port={}, acls={}, AAPs={}", portId, aclList, allowedAddresses);
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
for (Uuid aclId : aclList) {
String aclName = aclId.getValue();
synchronized (aclName.intern()) {
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
for (AllowedAddressPairs aap : allowedAddresses) {
PortIds portIdObj = new PortIdsBuilder().setKey(new PortIdsKey(portId)).setPortId(portId).build();
InstanceIdentifier<PortIds> path = AclServiceUtils.getPortIdsPathInAclPortsLookup(aclName, aap.getIpAddress(), portId);
tx.put(LogicalDatastoreType.OPERATIONAL, path, portIdObj, WriteTransaction.CREATE_MISSING_PARENTS);
}
}));
}
}
return futures;
}
use of org.opendaylight.netvirt.aclservice.api.utils.AclInterface in project netvirt by opendaylight.
the class EgressAclServiceImpl method bindService.
/**
* Bind service.
*
* @param aclInterface the acl interface
*/
@Override
public void bindService(AclInterface aclInterface) {
String interfaceName = aclInterface.getInterfaceId();
jobCoordinator.enqueueJob(interfaceName, () -> {
int instructionKey = 0;
List<Instruction> instructions = new ArrayList<>();
instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(getAclAntiSpoofingTable(), ++instructionKey));
short serviceIndex = ServiceIndex.getIndex(AclConstants.INGRESS_ACL_SERVICE_NAME, AclConstants.INGRESS_ACL_SERVICE_INDEX);
int flowPriority = AclConstants.INGRESS_ACL_SERVICE_INDEX;
BoundServices serviceInfo = AclServiceUtils.getBoundServices(String.format("%s.%s.%s", "acl", "ingressacl", interfaceName), serviceIndex, flowPriority, AclConstants.COOKIE_ACL_BASE, instructions);
InstanceIdentifier<BoundServices> path = AclServiceUtils.buildServiceId(interfaceName, serviceIndex, serviceMode);
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo, WriteTransaction.CREATE_MISSING_PARENTS)));
});
}
use of org.opendaylight.netvirt.aclservice.api.utils.AclInterface in project netvirt by opendaylight.
the class IngressAclServiceImpl method bindService.
/**
* Bind service.
*
* @param aclInterface the acl interface
*/
@Override
public void bindService(AclInterface aclInterface) {
String interfaceName = aclInterface.getInterfaceId();
jobCoordinator.enqueueJob(interfaceName, () -> {
int instructionKey = 0;
List<Instruction> instructions = new ArrayList<>();
instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.EGRESS_ACL_DUMMY_TABLE, ++instructionKey));
int flowPriority = NwConstants.EGRESS_ACL_SERVICE_INDEX;
short serviceIndex = ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX);
BoundServices serviceInfo = AclServiceUtils.getBoundServices(String.format("%s.%s.%s", "acl", "egressacl", interfaceName), serviceIndex, flowPriority, AclConstants.COOKIE_ACL_BASE, instructions);
InstanceIdentifier<BoundServices> path = AclServiceUtils.buildServiceId(interfaceName, ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX), serviceMode);
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo, WriteTransaction.CREATE_MISSING_PARENTS)));
});
}
Aggregations