Search in sources :

Example 1 with AclPortsByIp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.AclPortsByIp in project netvirt by opendaylight.

the class AclServiceUtils method cleanUpStaleEntriesInAclPortsLookup.

private void cleanUpStaleEntriesInAclPortsLookup(String aclName, WriteTransaction tx) {
    AclPortsByIp aclPortsByIp = getAclPortsByIpFromOperDs(aclName);
    if (aclPortsByIp == null) {
        return;
    }
    boolean deleteEntireAcl;
    List<AclIpPrefixes> ipPrefixes = aclPortsByIp.getAclIpPrefixes();
    if (ipPrefixes == null || ipPrefixes.isEmpty()) {
        deleteEntireAcl = true;
    } else {
        boolean deleteMap = true;
        for (AclIpPrefixes ipPrefix : ipPrefixes) {
            if (ipPrefix.getPortIds() != null && !ipPrefix.getPortIds().isEmpty()) {
                deleteMap = false;
                break;
            }
        }
        deleteEntireAcl = deleteMap;
    }
    if (deleteEntireAcl) {
        tx.delete(LogicalDatastoreType.OPERATIONAL, AclServiceUtils.aclPortsByIpPath(aclName));
    } else {
        for (AclIpPrefixes ipPrefix : ipPrefixes) {
            if (ipPrefix.getPortIds() == null || ipPrefix.getPortIds().isEmpty()) {
                InstanceIdentifier<AclIpPrefixes> delPath = AclServiceUtils.getAclIpPrefixesPath(aclName, ipPrefix.getIpPrefix());
                tx.delete(LogicalDatastoreType.OPERATIONAL, delPath);
            }
        }
    }
}
Also used : AclIpPrefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.acl.ports.by.ip.AclIpPrefixes) AclPortsByIp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.AclPortsByIp)

Aggregations

AclPortsByIp (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.AclPortsByIp)1 AclIpPrefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.acl.ports.by.ip.AclIpPrefixes)1