1 package org.opendaylight.groupbasedpolicy.resolver;
3 import java.util.HashMap;
8 import org.opendaylight.groupbasedpolicy.resolver.ContractResolverUtils.ContractMatch;
10 import com.google.common.base.Preconditions;
11 import com.google.common.collect.Table;
13 public class PolicyResolverUtils {
15 private PolicyResolverUtils() {
16 throw new UnsupportedOperationException("Cannot create an instance");
20 * Resolve the policy in three phases: <br>
21 * (1) select contracts that in scope based on contract selectors. <br>
22 * (2) select subjects that are in scope for each contract based on matchers in clauses <br>
23 * (3) resolve the set of in-scope contracts into a list of subjects that apply for each pair of
24 * endpoint groups and the conditions that can apply for for each endpoint in those groups.
26 public static Table<EgKey, EgKey, Policy> resolvePolicy(Set<IndexedTenant> tenants) {
27 return resolvePolicy(tenants, new HashMap<EgKey, Set<ConditionSet>>());
31 * Resolve the policy in three phases: <br>
32 * (1) select contracts that in scope based on contract selectors. <br>
33 * (2) select subjects that are in scope for each contract based on matchers in clauses <br>
34 * (3) resolve the set of in-scope contracts into a list of subjects that apply for each pair of
35 * endpoint groups and the conditions that can apply for for each endpoint in those groups.
37 protected static Table<EgKey, EgKey, Policy> resolvePolicy(Set<IndexedTenant> tenants,
38 Map<EgKey, Set<ConditionSet>> egConditions) {
39 Preconditions.checkNotNull(tenants);
40 Preconditions.checkNotNull(egConditions);
41 // select contracts that apply for the given tenant
42 Table<EgKey, EgKey, List<ContractMatch>> contractMatches = ContractResolverUtils.selectContracts(tenants);
44 // select subjects for the matching contracts and resolve the policy
45 // for endpoint group pairs. This does phase (2) and (3) as one step
46 return SubjectResolverUtils.selectSubjects(contractMatches, egConditions);