@Test public void matchesDesc() { InterfacesSpecifier specifier = new InterfacesSpecifier("desc:secret.*"); Interface secretInterface = new Interface("Loopback0"); secretInterface.setDescription("secrets are never secrets for long"); Interface nonSecretInterface = new Interface("Ethetnet0/0"); nonSecretInterface.setDescription("this interface couldn't keep its secret"); assertThat(specifier.matches(secretInterface), equalTo(true)); assertThat(specifier.matches(nonSecretInterface), equalTo(false)); }
private org.batfish.datamodel.Interface toInterface(Interface iface) { String name = iface.getName(); org.batfish.datamodel.Interface newIface = new org.batfish.datamodel.Interface(name, _c); newIface.setDeclaredNames(ImmutableSortedSet.of(name)); newIface.setActive(true); // TODO: may have to change newIface.setBandwidth(iface.getBandwidth()); newIface.setDescription(iface.getDescription()); InterfaceAddress address = iface.getAddress(); if (address != null) { newIface.setAddress(iface.getAddress()); } newIface.getAllAddresses().addAll(iface.getAllAddresses()); for (InterfaceAddress p : newIface.getAllAddresses()) { _ipToInterfaceMap.put(p.getIp(), newIface); } return newIface; }
org.batfish.datamodel.Interface newIface = new org.batfish.datamodel.Interface(name, _c); newIface.setDeclaredNames(ImmutableSortedSet.of(name)); newIface.setDescription(iface.getDescription()); Integer mtu = iface.getMtu(); if (mtu != null) {
/** * Convert a non-unit interface to the VI {@link org.batfish.datamodel.Interface}. * * <p>Note that bulk of the configuration is stored at the logical interface level, see {@link * #toInterface(Interface)} for those conversions. Here we convert aggregation and bandwidth * settings; track VRF membership. */ private org.batfish.datamodel.Interface toInterfaceNonUnit(Interface iface) { String name = iface.getName(); org.batfish.datamodel.Interface newIface = new org.batfish.datamodel.Interface(name, _c); newIface.setDeclaredNames(ImmutableSortedSet.of(name)); newIface.setDescription(iface.getDescription()); // 802.3ad link aggregation if (iface.get8023adInterface() != null) { newIface.setChannelGroup(iface.get8023adInterface()); } // Redundant ethernet if (iface.getRedundantParentInterface() != null) { newIface.setChannelGroup(iface.getRedundantParentInterface()); } newIface.setBandwidth(iface.getBandwidth()); newIface.setVrf(_c.getVrfs().get(iface.getRoutingInstance())); return newIface; }
iface1.setDescription("desc desc desc"); iface1.setActive(false); iface2.setDescription("blah blah blah");
newIface.setDescription(iface.getDescription()); newIface.setActive(iface.getActive()); newIface.setChannelGroup(iface.getChannelGroup());
newIface.setAllAddresses(iface.getAllAddresses()); newIface.setActive(iface.getActive()); newIface.setDescription(iface.getComment());
@Test public void matchesCaseInsensitive() { Interface iface = Interface.builder() .setName("Loopback0") .setOwner(new Configuration("c", ConfigurationFormat.CISCO_IOS)) .setVrf(new Vrf("vrfA")) .build(); iface.setDescription("secrets are never secrets for long"); assertTrue(new InterfacesSpecifier("name:LoopBAck.*").matches(iface)); assertTrue(new InterfacesSpecifier("desc:SECrets.*").matches(iface)); assertTrue(new InterfacesSpecifier("type:Loopback").matches(iface)); assertTrue(new InterfacesSpecifier("vrf:vrfa").matches(iface)); }