Search in sources :

Example 6 with CommunityListLine

use of org.batfish.datamodel.CommunityListLine in project batfish by batfish.

the class Graph method findNamedCommunities.

/*
   * Map named community sets that contain a single match
   * back to the community/regex value. This makes it
   * easier to provide intuitive counter examples.
   */
public Map<String, String> findNamedCommunities() {
    Map<String, String> comms = new HashMap<>();
    for (Configuration conf : getConfigurations().values()) {
        for (Entry<String, CommunityList> entry : conf.getCommunityLists().entrySet()) {
            String name = entry.getKey();
            CommunityList cl = entry.getValue();
            if (cl != null && cl.getLines().size() == 1) {
                CommunityListLine line = cl.getLines().get(0);
                comms.put(line.getRegex(), name);
            }
        }
    }
    return comms;
}
Also used : Configuration(org.batfish.datamodel.Configuration) CommunityListLine(org.batfish.datamodel.CommunityListLine) HashMap(java.util.HashMap) CommunityList(org.batfish.datamodel.CommunityList)

Example 7 with CommunityListLine

use of org.batfish.datamodel.CommunityListLine in project batfish by batfish.

the class NamedCommunitySet method allCommunities.

@Override
public SortedSet<Long> allCommunities(Environment environment) {
    ImmutableSortedSet.Builder<Long> out = ImmutableSortedSet.naturalOrder();
    CommunityList cl = environment.getConfiguration().getCommunityLists().get(_name);
    for (CommunityListLine line : cl.getLines()) {
        Long community = line.toLiteralCommunity();
        out.add(community);
    }
    return out.build();
}
Also used : CommunityListLine(org.batfish.datamodel.CommunityListLine) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) CommunityList(org.batfish.datamodel.CommunityList)

Aggregations

CommunityListLine (org.batfish.datamodel.CommunityListLine)7 CommunityList (org.batfish.datamodel.CommunityList)5 ArrayList (java.util.ArrayList)3 Configuration (org.batfish.datamodel.Configuration)2 CommunityVar (org.batfish.symbolic.CommunityVar)2 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 BoolExpr (com.microsoft.z3.BoolExpr)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 BDD (net.sf.javabdd.BDD)1 BatfishException (org.batfish.common.BatfishException)1 CommunitySetElem (org.batfish.datamodel.routing_policy.expr.CommunitySetElem)1 InlineCommunitySet (org.batfish.datamodel.routing_policy.expr.InlineCommunitySet)1 LiteralCommunitySetElemHalf (org.batfish.datamodel.routing_policy.expr.LiteralCommunitySetElemHalf)1 NamedCommunitySet (org.batfish.datamodel.routing_policy.expr.NamedCommunitySet)1