Search in sources :

Example 6 with NetworkFactory

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

the class RouteReflectionTest method setup.

/**
 * Initialize builders with values common to all tests
 */
@Before
public void setup() {
    _ab = new BgpAdvertisement.Builder().setClusterList(ImmutableSortedSet.of()).setCommunities(ImmutableSortedSet.of()).setDstVrf(Configuration.DEFAULT_VRF_NAME).setOriginType(OriginType.INCOMPLETE).setSrcProtocol(RoutingProtocol.AGGREGATE).setSrcVrf(Configuration.DEFAULT_VRF_NAME).setType(BgpAdvertisementType.EBGP_SENT);
    _nf = new NetworkFactory();
    _cb = _nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS);
    _ib = _nf.interfaceBuilder().setActive(true);
    _nb = _nf.bgpNeighborBuilder().setLocalAs(2);
    _pb = _nf.bgpProcessBuilder();
    _vb = _nf.vrfBuilder().setName(Configuration.DEFAULT_VRF_NAME);
    If acceptIffBgp = new If();
    Disjunction guard = new Disjunction();
    guard.setDisjuncts(ImmutableList.of(new MatchProtocol(RoutingProtocol.BGP), new MatchProtocol(RoutingProtocol.IBGP)));
    acceptIffBgp.setGuard(guard);
    acceptIffBgp.setTrueStatements(ImmutableList.of(Statements.ExitAccept.toStaticStatement()));
    acceptIffBgp.setFalseStatements(ImmutableList.of(Statements.ExitReject.toStaticStatement()));
    /* Builder that creates default BGP export policy */
    _defaultExportPolicyBuilder = _nf.routingPolicyBuilder().setStatements(ImmutableList.of(acceptIffBgp));
    /* Builder that creates BGP export policy that rejects everything */
    _nullExportPolicyBuilder = _nf.routingPolicyBuilder().setStatements(ImmutableList.of(Statements.ExitReject.toStaticStatement()));
}
Also used : Disjunction(org.batfish.datamodel.routing_policy.expr.Disjunction) NetworkFactory(org.batfish.datamodel.NetworkFactory) If(org.batfish.datamodel.routing_policy.statement.If) MatchProtocol(org.batfish.datamodel.routing_policy.expr.MatchProtocol) Before(org.junit.Before)

Example 7 with NetworkFactory

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

the class VirtualRouterTest method makeIosRouter.

private static Node makeIosRouter(String hostname) {
    NetworkFactory nf = new NetworkFactory();
    Configuration c = nf.configurationBuilder().setHostname(hostname).setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build();
    nf.vrfBuilder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(c).build();
    return new Node(c);
}
Also used : Configuration(org.batfish.datamodel.Configuration) NetworkFactory(org.batfish.datamodel.NetworkFactory)

Example 8 with NetworkFactory

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

the class VirtualRouterTest method setup.

@Before
public void setup() {
    NetworkFactory nf = new NetworkFactory();
    _testVirtualRouter = createEmptyVirtualRouter(nf, TEST_VIRTUAL_ROUTER_NAME);
    BgpProcess bgpProcess = nf.bgpProcessBuilder().setVrf(_testVirtualRouter._vrf).setRouterId(TEST_SRC_IP).build();
    _neighborConfiguration = nf.configurationBuilder().setConfigurationFormat(FORMAT).setHostname(NEIGHBOR_HOST_NAME).build();
    _bgpNeighborBuilder = nf.bgpNeighborBuilder().setOwner(_neighborConfiguration).setPeerAddress(TEST_DEST_IP).setLocalIp(TEST_SRC_IP).setLocalAs(TEST_AS1).setBgpProcess(bgpProcess);
    _bgpRouteBuilder = new BgpRoute.Builder().setNetwork(TEST_NETWORK).setProtocol(RoutingProtocol.BGP).setOriginType(OriginType.INCOMPLETE).setOriginatorIp(TEST_SRC_IP);
    _ipOwners = ImmutableMap.of(TEST_SRC_IP, ImmutableSet.of(TEST_VIRTUAL_ROUTER_NAME));
    _routingPolicyBuilder = nf.routingPolicyBuilder().setOwner(_testVirtualRouter._c);
}
Also used : BgpProcess(org.batfish.datamodel.BgpProcess) NetworkFactory(org.batfish.datamodel.NetworkFactory) BgpRoute(org.batfish.datamodel.BgpRoute) Before(org.junit.Before)

Example 9 with NetworkFactory

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

the class VirtualRouterTest method addInterfaces.

private static void addInterfaces(Configuration c, Map<String, InterfaceAddress> interfaceAddresses) {
    NetworkFactory nf = new NetworkFactory();
    Interface.Builder ib = nf.interfaceBuilder().setActive(true).setOwner(c).setVrf(c.getDefaultVrf());
    interfaceAddresses.forEach((ifaceName, address) -> ib.setName(ifaceName).setAddress(address).build());
}
Also used : NetworkFactory(org.batfish.datamodel.NetworkFactory) Interface(org.batfish.datamodel.Interface)

Example 10 with NetworkFactory

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

the class HostInterfaceTest method setup.

@Before
public void setup() {
    _factory = new NetworkFactory();
    _c = _factory.configurationBuilder().setConfigurationFormat(ConfigurationFormat.HOST).setHostname("hostInterfaceTest").build();
    _w = new Warnings();
}
Also used : NetworkFactory(org.batfish.datamodel.NetworkFactory) Warnings(org.batfish.common.Warnings) Before(org.junit.Before)

Aggregations

NetworkFactory (org.batfish.datamodel.NetworkFactory)15 Configuration (org.batfish.datamodel.Configuration)7 Interface (org.batfish.datamodel.Interface)7 Before (org.junit.Before)7 InterfaceAddress (org.batfish.datamodel.InterfaceAddress)6 StaticRoute (org.batfish.datamodel.StaticRoute)6 Vrf (org.batfish.datamodel.Vrf)6 Prefix (org.batfish.datamodel.Prefix)5 TreeMap (java.util.TreeMap)3 Warnings (org.batfish.common.Warnings)2 Ip (org.batfish.datamodel.Ip)2 OriginateVrf (org.batfish.z3.state.OriginateVrf)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BatfishLogger (org.batfish.common.BatfishLogger)1 BgpProcess (org.batfish.datamodel.BgpProcess)1 BgpRoute (org.batfish.datamodel.BgpRoute)1 IpAccessList (org.batfish.datamodel.IpAccessList)1 IpAccessListLine (org.batfish.datamodel.IpAccessListLine)1 IpWildcard (org.batfish.datamodel.IpWildcard)1 SourceNat (org.batfish.datamodel.SourceNat)1