@Override protected CiscoFamily featureValueOf(VendorFamily actual) { return actual.getCisco(); } }
/** * Provides a matcher that matches if the provided {@code subMatcher} matches the VendorFamily's * cisco */ public static HasCisco hasCisco(Matcher<? super CiscoFamily> subMatcher) { return new HasCisco(subMatcher); }
/** Concatenates all non-null family pointers */ @Override public String toString() { return String.join( " ", Stream.of(_aws, _cisco, _juniper) .filter(f -> f != null) .map(f -> Objects.toString(toFamilyType(f))) .collect(Collectors.toList())); } }
@Override public List<Configuration> toVendorIndependentConfigurations() { final Configuration c = new Configuration(_hostname, _vendor); c.getVendorFamily().setCisco(_cf); c.setDefaultInboundAction(LineAction.PERMIT); c.setDefaultCrossZoneAction(LineAction.PERMIT); c.setTacacsSourceInterface(_tacacsSourceInterface); c.setNtpSourceInterface(_ntpSourceInterface); if (_cf.getNtp() != null) { c.setNtpServers(new TreeSet<>(_cf.getNtp().getServers().keySet())); if (_cf.getLogging() != null) { c.setLoggingSourceInterface(_cf.getLogging().getSourceInterface()); c.setLoggingServers(new TreeSet<>(_cf.getLogging().getHosts().keySet())); for (Line line : _cf.getLines().values()) { String list = line.getLoginAuthentication(); if (list == null) { Aaa aaa = _cf.getAaa(); if (aaa != null) { AaaAuthentication authentication = aaa.getAuthentication(); if (authentication != null) { AaaAuthenticationLogin login = authentication.getLogin(); if (login != null && login.getLists().containsKey(list)) { found = true;
@Test public void toStringMulitipleFamilies() { VendorFamily family = new VendorFamily(); family.setCisco(new CiscoFamily()); family.setJuniper(new JuniperFamily()); assertThat( family.toString(), equalTo(String.join(" ", Arrays.asList(Type.CISCO.toString(), Type.JUNIPER.toString())))); }
@Test public void toStringOneFamily() { VendorFamily family = new VendorFamily(); family.setCisco(new CiscoFamily()); assertThat(family.toString(), equalTo(Type.CISCO.toString())); } }
@Override public TableAnswerElement answer() { AaaAuthenticationLoginQuestion question = (AaaAuthenticationLoginQuestion) _question; TableAnswerElement answerElement = create(question); Set<String> specifiedNodes = question.getNodes().getMatchingNodes(_batfish); SortedMap<String, Configuration> configs = _batfish.loadConfigurations(); configs.forEach( (configName, config) -> { if (specifiedNodes.contains(configName)) { Row row = null; if (config.getVendorFamily().getCisco() != null) { row = getRow(configName, config.getVendorFamily().getCisco().getLines().values()); } else if (config.getVendorFamily().getJuniper() != null) { row = getRow(configName, config.getVendorFamily().getJuniper().getLines().values()); } if (row != null) { answerElement.addRow(row); } } }); answerElement.setSummary(answerElement.computeSummary(question.getAssertion())); return answerElement; }
public Configuration toConfigurationNode( AwsConfiguration awsConfiguration, Region region, Warnings warnings) { Configuration cfgNode = Utils.newAwsConfiguration(_vpcId, "aws"); cfgNode.getVendorFamily().getAws().setRegion(region.getName()); cfgNode.getVendorFamily().getAws().setVpcId(_vpcId); cfgNode .getDefaultVrf() .getStaticRoutes() .add( StaticRoute.builder() .setAdministrativeCost(Route.DEFAULT_STATIC_ROUTE_ADMIN) .setMetric(Route.DEFAULT_STATIC_ROUTE_COST) .setNetwork(_cidrBlock) .setNextHopInterface(Interface.NULL_INTERFACE_NAME) .build()); // we only create a node here // interfaces are added to this node as we traverse subnets and // internetgateways return cfgNode; } }
if (configuration.getVendorFamily().getAws().getSubnetId() != null) { String subnetId = configuration.getVendorFamily().getAws().getSubnetId(); Aggregate subnetAggregate = pojoTopology.getOrCreateAggregate(subnetId, AggregateType.SUBNET); subnetAggregate.getContents().add(pojoNode.getId()); String vpcId = configuration.getVendorFamily().getAws().getVpcId(); Aggregate vpcAggregate = pojoTopology.getOrCreateAggregate(vpcId, AggregateType.VNET); vpcAggregate.getContents().add(subnetAggregate.getId()); } else if (configuration.getVendorFamily().getAws().getVpcId() != null) { String vpcId = configuration.getVendorFamily().getAws().getVpcId(); Aggregate vpcAggregate = pojoTopology.getOrCreateAggregate(vpcId, AggregateType.VNET); vpcAggregate.getContents().add(pojoNode.getId()); String region = configuration.getVendorFamily().getAws().getRegion(); Aggregate regionAggregate = pojoTopology.getOrCreateAggregate(region, AggregateType.REGION); regionAggregate.getContents().add(vpcAggregate.getId()); } else if (configuration.getVendorFamily().getAws().getRegion() != null) { String region = configuration.getVendorFamily().getAws().getRegion(); Aggregate regionAggregate = pojoTopology.getOrCreateAggregate(region, AggregateType.REGION);
public Configuration toConfigurationNode( AwsConfiguration awsConfiguration, Region region, Warnings warnings) { Configuration cfgNode = Utils.newAwsConfiguration(_natGatewayId, "aws"); cfgNode.getVendorFamily().getAws().setRegion(region.getName()); // TODO: Configure forwarding for this NAT // for (NatGatewayAddress natAddress : _natGatewayAddresses) { // foreach natgatewayaddress create interfaces for public and private IPs, configure NAT rules // also connect the nat to the VPC router // } return cfgNode; } }
@Test public void toStringNoFamily() { VendorFamily family = new VendorFamily(); assertThat(family.toString(), equalTo("")); }
_tacacsServers = new TreeSet<>(); _trackingGroups = new TreeMap<>(); _vendorFamily = new VendorFamily(); _vrfs = new TreeMap<>(); _zones = new TreeMap<>();
public static Configuration newAwsConfiguration(String name, String domainName) { Configuration c = FACTORY .configurationBuilder() .setHostname(name) .setDomainName(domainName) .setConfigurationFormat(ConfigurationFormat.AWS) .setDefaultInboundAction(LineAction.PERMIT) .setDefaultCrossZoneAction(LineAction.PERMIT) .build(); FACTORY.vrfBuilder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(c).build(); c.getVendorFamily().setAws(new AwsFamily()); return c; }
_c.setNtpServers(_masterLogicalSystem.getNtpServers()); _c.setTacacsServers(_masterLogicalSystem.getTacplusServers()); _c.getVendorFamily().setJuniper(_masterLogicalSystem.getJf()); for (String riName : _masterLogicalSystem.getRoutingInstances().keySet()) { _c.getVrfs().put(riName, new Vrf(riName));