@JsonIgnore public @Nonnull InterfaceSpecifier getInterfacesSpecifier() { return InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(_interfaces); }
@JsonIgnore public InterfaceSpecifier getInterfaceSpecifier() { checkNotNull(_interfaceSpecifierFactory, PROP_INTERFACE_SPECIFIER_FACTORY + " is null"); return InterfaceSpecifierFactory.load(_interfaceSpecifierFactory) .buildInterfaceSpecifier(_interfaceSpecifierInput); }
@Test public void testLoad() { assertThat( InterfaceSpecifierFactory.load(InterfaceWithConnectedIpsSpecifier.NAME), instanceOf(InterfaceWithConnectedIpsSpecifier.Factory.class)); }
@Test public void testLoad() { InterfaceSpecifierFactory loaded = load(new FlexibleInterfaceSpecifierFactory().getName()); assertThat(loaded, instanceOf(FlexibleInterfaceSpecifierFactory.class)); } }
@Test public void testLoad() { assertTrue( InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) instanceof FlexibleInterfaceSpecifierFactory); }
@Test public void testTryAddInterfaceToVlansTrunk() { int vlan = 1; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(null); boolean excludeShutInterfaces = false; IntegerSpace vlans = IntegerSpace.of(Range.closed(1, 3)); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); Interface iface = _ib.build(); iface.setSwitchport(true); iface.setSwitchportMode(SwitchportMode.TRUNK); iface.setNativeVlan(vlan); iface.setAllowedVlans(vlans); tryAddInterfaceToVlans( _specifierContext, interfacesSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, NODE, iface); assertThat(switchedVlanInterfaces.keySet(), containsInAnyOrder(1, 2, 3)); switchedVlanInterfaces .values() .forEach(b -> assertThat(b.build(), contains(new NodeInterfacePair(NODE, INTERFACE)))); }
String.format("A Batfish %s must be a JSON string", expectedType.getName())); InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(value.textValue()); break;
@Test public void testComputeNodeVlanProperties() { int vlan = 1; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(null); boolean excludeShutInterfaces = false; IntegerSpace vlans = IntegerSpace.of(vlan); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder = ImmutableMap.builder(); Interface iface = _ib.build(); iface.setSwitchport(true); iface.setSwitchportMode(SwitchportMode.ACCESS); iface.setAccessVlan(vlan); Configuration c = _configurations.values().iterator().next(); int vni = 10000; c.getDefaultVrf().getVniSettings().put(vni, _vnb.setVlan(vlan).setVni(vni).build()); computeNodeVlanProperties( _specifierContext, c, interfacesSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, vlanVnisBuilder); assertThat(switchedVlanInterfaces, hasKey(vlan)); assertThat( switchedVlanInterfaces.get(vlan).build(), contains(new NodeInterfacePair(NODE, INTERFACE))); assertThat(vlanVnisBuilder.build(), equalTo(ImmutableMap.of(vlan, vni))); }
@Test public void testTryAddInterfaceToVlansAccess() { int vlan = 1; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(null); boolean excludeShutInterfaces = false; IntegerSpace vlans = IntegerSpace.of(vlan); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); Interface iface = _ib.build(); iface.setSwitchport(true); iface.setSwitchportMode(SwitchportMode.ACCESS); iface.setAccessVlan(vlan); tryAddInterfaceToVlans( _specifierContext, interfacesSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, NODE, iface); assertThat(switchedVlanInterfaces, hasKey(vlan)); assertThat( switchedVlanInterfaces.get(vlan).build(), contains(new NodeInterfacePair(NODE, INTERFACE))); }
@Test public void testTryAddInterfaceToVlansIrb() { int vlan = 1; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(null); boolean excludeShutInterfaces = false; IntegerSpace vlans = IntegerSpace.of(vlan); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); Interface iface = _ib.build(); iface.setInterfaceType(InterfaceType.VLAN); iface.setSwitchport(false); iface.setVlan(vlan); tryAddInterfaceToVlans( _specifierContext, interfacesSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, NODE, iface); assertThat(switchedVlanInterfaces, hasKey(vlan)); assertThat( switchedVlanInterfaces.get(vlan).build(), contains(new NodeInterfacePair(NODE, INTERFACE))); }
@Test public void testTryAddInterfaceToVlansIncludeShutWithFlag() { int vlan = 1; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(null); boolean excludeShutInterfaces = false; IntegerSpace vlans = IntegerSpace.of(vlan); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); Interface iface = _ib.setActive(false).build(); iface.setInterfaceType(InterfaceType.VLAN); iface.setSwitchport(false); iface.setVlan(vlan); tryAddInterfaceToVlans( _specifierContext, interfacesSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, NODE, iface); assertThat(switchedVlanInterfaces, hasKey(vlan)); assertThat( switchedVlanInterfaces.get(vlan).build(), contains(new NodeInterfacePair(NODE, INTERFACE))); }
@Test public void testTryAddInterfaceToVlansExcludedInterfaceByType() { int vlan = 1; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(null); boolean excludeShutInterfaces = true; IntegerSpace vlans = IntegerSpace.of(vlan); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); Interface iface = _ib.setActive(false).build(); iface.setSwitchport(false); tryAddInterfaceToVlans( _specifierContext, interfacesSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, NODE, iface); assertThat(switchedVlanInterfaces, anEmptyMap()); }
@Test public void testTryAddInterfaceToVlansExcludedInterfaceBySpecifier() { int vlan = 1; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(""); boolean excludeShutInterfaces = false; IntegerSpace vlans = IntegerSpace.of(vlan); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); Interface iface = _ib.build(); iface.setSwitchport(true); iface.setSwitchportMode(SwitchportMode.ACCESS); iface.setAccessVlan(vlan); tryAddInterfaceToVlans( _specifierContext, interfacesSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, NODE, iface); assertThat(switchedVlanInterfaces, anEmptyMap()); }
@Test public void testTryAddInterfaceToVlansExcludedInterfaceByShutdown() { int vlan = 1; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(null); boolean excludeShutInterfaces = true; IntegerSpace vlans = IntegerSpace.of(vlan); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); Interface iface = _ib.setActive(false).build(); iface.setSwitchport(true); iface.setSwitchportMode(SwitchportMode.ACCESS); iface.setAccessVlan(vlan); tryAddInterfaceToVlans( _specifierContext, interfacesSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, NODE, iface); assertThat(switchedVlanInterfaces, anEmptyMap()); }
int vni = 10000; InterfaceSpecifier interfacesSpecifier = InterfaceSpecifierFactory.load(FlexibleInterfaceSpecifierFactory.NAME) .buildInterfaceSpecifier(null); boolean excludeShutInterfaces = false;