Search in sources :

Example 41 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class InitInfoAnswerElementTest method testSetErrors.

@Test
public void testSetErrors() {
    BatfishException exception = new BatfishException("sample exception");
    BatfishStackTrace stackTrace = new BatfishStackTrace(exception);
    List<BatfishStackTrace> errors = new ArrayList<>();
    errors.add(stackTrace);
    SortedMap<String, List<BatfishStackTrace>> error = new TreeMap<>();
    error.put("error", errors);
    _element.setErrors(error);
    assertThat(_element.getErrors().get("error"), is(errors));
}
Also used : BatfishException(org.batfish.common.BatfishException) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 42 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class ParseVendorConfigurationAnswerElementTest method testSetErrors.

@Test
public void testSetErrors() {
    BatfishException exception = new BatfishException("sample exception");
    BatfishStackTrace stackTrace = new BatfishStackTrace(exception);
    SortedMap<String, BatfishStackTrace> errors = new TreeMap<>();
    errors.put("error", stackTrace);
    _element.setErrors(errors);
    assertThat(_element.getErrors().get("error"), is(stackTrace));
}
Also used : BatfishException(org.batfish.common.BatfishException) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 43 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class ParseVendorConfigurationAnswerElementTest method checkNonEmptyErrors.

@Test
public void checkNonEmptyErrors() {
    BatfishException exception = new BatfishException("sample exception");
    _element.getErrors().put("error", new BatfishStackTrace(exception));
    assertThat(_element.getErrors().size(), is(1));
}
Also used : BatfishException(org.batfish.common.BatfishException) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace) Test(org.junit.Test)

Example 44 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class CiscoControlPlaneExtractor method enterExtended_access_list_stanza.

@Override
public void enterExtended_access_list_stanza(Extended_access_list_stanzaContext ctx) {
    String name;
    int definitionLine;
    if (ctx.name != null) {
        name = ctx.name.getText();
        definitionLine = ctx.name.getStart().getLine();
    } else if (ctx.shortname != null) {
        name = ctx.shortname.getText();
        definitionLine = ctx.shortname.getStart().getLine();
    } else if (ctx.num != null) {
        name = ctx.num.getText();
        definitionLine = ctx.num.getLine();
    } else {
        throw new BatfishException("Could not determine acl name");
    }
    ExtendedAccessList list = _configuration.getExtendedAcls().computeIfAbsent(name, n -> new ExtendedAccessList(n, definitionLine));
    _currentExtendedAcl = list;
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) ExtendedAccessList(org.batfish.representation.cisco.ExtendedAccessList)

Example 45 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitRedistribute_ospf_bgp_tail.

@Override
public void exitRedistribute_ospf_bgp_tail(Redistribute_ospf_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        RoutingProtocol sourceProtocol = RoutingProtocol.OSPF;
        BgpRedistributionPolicy r = new BgpRedistributionPolicy(sourceProtocol);
        proc.getRedistributionPolicies().put(sourceProtocol, r);
        if (ctx.metric != null) {
            int metric = toInteger(ctx.metric);
            r.setMetric(metric);
        }
        if (ctx.map != null) {
            String map = ctx.map.getText();
            int mapLine = ctx.map.getStart().getLine();
            r.setRouteMap(map);
            r.setRouteMapLine(mapLine);
        }
        int procNum = toInteger(ctx.procnum);
        r.getSpecialAttributes().put(BgpRedistributionPolicy.OSPF_PROCESS_NUMBER, procNum);
    } else if (_currentIpPeerGroup != null || _currentNamedPeerGroup != null) {
        throw new BatfishException("do not currently handle per-neighbor redistribution policies");
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) RoutingProtocol(org.batfish.datamodel.RoutingProtocol) BgpProcess(org.batfish.representation.cisco.BgpProcess) BgpRedistributionPolicy(org.batfish.representation.cisco.BgpRedistributionPolicy)

Aggregations

BatfishException (org.batfish.common.BatfishException)264 IOException (java.io.IOException)61 Path (java.nio.file.Path)54 CleanBatfishException (org.batfish.common.CleanBatfishException)35 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)34 TreeMap (java.util.TreeMap)31 ArrayList (java.util.ArrayList)30 JSONException (org.codehaus.jettison.json.JSONException)30 Ip (org.batfish.datamodel.Ip)25 JSONObject (org.codehaus.jettison.json.JSONObject)25 Configuration (org.batfish.datamodel.Configuration)24 Map (java.util.Map)23 Prefix (org.batfish.datamodel.Prefix)22 HashMap (java.util.HashMap)20 HashSet (java.util.HashSet)20 TreeSet (java.util.TreeSet)20 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)18 Test (org.junit.Test)18 Set (java.util.Set)17 SortedMap (java.util.SortedMap)17