package org.opendaylight.groupbasedpolicy.resolver; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.opendaylight.groupbasedpolicy.resolver.ContractResolverUtils.ContractMatch; import com.google.common.base.Preconditions; import com.google.common.collect.Table; public class PolicyResolverUtils { private PolicyResolverUtils() { throw new UnsupportedOperationException("Cannot create an instance"); } /** * Resolve the policy in three phases:
* (1) select contracts that in scope based on contract selectors.
* (2) select subjects that are in scope for each contract based on matchers in clauses
* (3) resolve the set of in-scope contracts into a list of subjects that apply for each pair of * endpoint groups and the conditions that can apply for for each endpoint in those groups. */ public static Table resolvePolicy(Set tenants) { return resolvePolicy(tenants, new HashMap>()); } /** * Resolve the policy in three phases:
* (1) select contracts that in scope based on contract selectors.
* (2) select subjects that are in scope for each contract based on matchers in clauses
* (3) resolve the set of in-scope contracts into a list of subjects that apply for each pair of * endpoint groups and the conditions that can apply for for each endpoint in those groups. */ protected static Table resolvePolicy(Set tenants, Map> egConditions) { Preconditions.checkNotNull(tenants); Preconditions.checkNotNull(egConditions); // select contracts that apply for the given tenant Table> contractMatches = ContractResolverUtils.selectContracts(tenants); // select subjects for the matching contracts and resolve the policy // for endpoint group pairs. This does phase (2) and (3) as one step return SubjectResolverUtils.selectSubjects(contractMatches, egConditions); } }