@Test public void testInferPlatform() { { CiscoNxosConfiguration vc = new CiscoNxosConfiguration(); assertThat(inferPlatform(vc, NxosMajorVersion.UNKNOWN, 0, 0), equalTo(NexusPlatform.UNKNOWN)); vc.setBootNxosSup2("bootflash:/nxos.9.2.3.bin"); assertThat(inferPlatform(vc, NXOS7, 0, 0), equalTo(NEXUS_3000)); assertThat(inferPlatform(vc, NXOS7, 0, 0), equalTo(NEXUS_3000)); assertThat(inferPlatform(vc, NXOS7, 0, 1), equalTo(NEXUS_9000)); assertThat(inferPlatform(vc, NXOS7, 1, 0), equalTo(NEXUS_3000)); assertThat(inferPlatform(vc, NXOS7, 1, 1), equalTo(NEXUS_3000)); assertThat(inferPlatform(vc, NXOS9, 0, 0), equalTo(NEXUS_9000)); assertThat(inferPlatform(vc, NXOS9, 0, 0), equalTo(NEXUS_9000)); assertThat(inferPlatform(vc, NXOS9, 0, 1), equalTo(NEXUS_9000)); assertThat(inferPlatform(vc, NXOS9, 1, 0), equalTo(NEXUS_9000)); assertThat(inferPlatform(vc, NXOS9, 1, 1), equalTo(NEXUS_9000)); } { CiscoNxosConfiguration vc = new CiscoNxosConfiguration(); assertThat(inferPlatform(vc, NxosMajorVersion.UNKNOWN, 0, 0), equalTo(NexusPlatform.UNKNOWN)); vc.setBootKickstartSup2("bootflash:/n7000-s2-kickstart.6.2.16.bin"); assertThat(inferPlatform(vc, NXOS6, 0, 0), equalTo(NEXUS_7000)); vc.setBootKickstartSup1("bootflash:/n6000-uk9-kickstart.6.0.2.N2.3.bin"); assertThat(inferPlatform(vc, NXOS6, 0, 0), equalTo(NEXUS_6000)); vc.setBootSystemSup2("bootflash:/n5000-uk9.5.1.3.N1.1a.bin"); assertThat(inferPlatform(vc, NXOS5, 0, 0), equalTo(NEXUS_5000)); vc.setBootSystemSup1("bootflash:/n3000-uk9.6.0.2.U3.2.bin"); assertThat(inferPlatform(vc, NXOS6, 0, 0), equalTo(NEXUS_3000)); } }
public static @Nonnull NexusPlatform inferPlatform( CiscoNxosConfiguration vc, NxosMajorVersion majorVersion, int numLayer3ExplicitShutdown, int numLayer3ExplicitNoShutdown) { Optional<NexusPlatform> initialGuessOrNoInformation = Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .findFirst() .map(CiscoNxosPreprocessor::inferPlatformFromImage); if (!initialGuessOrNoInformation.isPresent()) { return NexusPlatform.UNKNOWN; } NexusPlatform initialGuess = initialGuessOrNoInformation.get(); if (initialGuess != NexusPlatform.UNKNOWN) { return initialGuess; } if (majorVersion == NxosMajorVersion.NXOS9) { return NexusPlatform.NEXUS_9000; } if (numLayer3ExplicitNoShutdown == 0 && numLayer3ExplicitShutdown > 0) { return NexusPlatform.NEXUS_3000; } if (numLayer3ExplicitNoShutdown > 0 && numLayer3ExplicitShutdown == 0) { return NexusPlatform.NEXUS_9000; } return NexusPlatform.NEXUS_3000; }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { public static @Nonnull NexusPlatform inferPlatform( CiscoNxosConfiguration vc, NxosMajorVersion majorVersion, int numLayer3ExplicitShutdown, int numLayer3ExplicitNoShutdown) { Optional<NexusPlatform> initialGuessOrNoInformation = Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .findFirst() .map(CiscoNxosPreprocessor::inferPlatformFromImage); if (!initialGuessOrNoInformation.isPresent()) { return NexusPlatform.UNKNOWN; } NexusPlatform initialGuess = initialGuessOrNoInformation.get(); if (initialGuess != NexusPlatform.UNKNOWN) { return initialGuess; } if (majorVersion == NxosMajorVersion.NXOS9) { return NexusPlatform.NEXUS_9000; } if (numLayer3ExplicitNoShutdown == 0 && numLayer3ExplicitShutdown > 0) { return NexusPlatform.NEXUS_3000; } if (numLayer3ExplicitNoShutdown > 0 && numLayer3ExplicitShutdown == 0) { return NexusPlatform.NEXUS_9000; } return NexusPlatform.NEXUS_3000; } }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { public static @Nonnull NexusPlatform inferPlatform( CiscoNxosConfiguration vc, NxosMajorVersion majorVersion, int numLayer3ExplicitShutdown, int numLayer3ExplicitNoShutdown) { Optional<NexusPlatform> initialGuessOrNoInformation = Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .findFirst() .map(CiscoNxosPreprocessor::inferPlatformFromImage); if (!initialGuessOrNoInformation.isPresent()) { return NexusPlatform.UNKNOWN; } NexusPlatform initialGuess = initialGuessOrNoInformation.get(); if (initialGuess != NexusPlatform.UNKNOWN) { return initialGuess; } if (majorVersion == NxosMajorVersion.NXOS9) { return NexusPlatform.NEXUS_9000; } if (numLayer3ExplicitNoShutdown == 0 && numLayer3ExplicitShutdown > 0) { return NexusPlatform.NEXUS_3000; } if (numLayer3ExplicitNoShutdown > 0 && numLayer3ExplicitShutdown == 0) { return NexusPlatform.NEXUS_9000; } return NexusPlatform.NEXUS_3000; } CiscoNxosPreprocessor(
      String text,
      CiscoNxosCombinedParser parser,
      Warnings warnings,
      CiscoNxosConfiguration configuration); }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { public static @Nonnull NexusPlatform inferPlatform( CiscoNxosConfiguration vc, NxosMajorVersion majorVersion, int numLayer3ExplicitShutdown, int numLayer3ExplicitNoShutdown) { Optional<NexusPlatform> initialGuessOrNoInformation = Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .findFirst() .map(CiscoNxosPreprocessor::inferPlatformFromImage); if (!initialGuessOrNoInformation.isPresent()) { return NexusPlatform.UNKNOWN; } NexusPlatform initialGuess = initialGuessOrNoInformation.get(); if (initialGuess != NexusPlatform.UNKNOWN) { return initialGuess; } if (majorVersion == NxosMajorVersion.NXOS9) { return NexusPlatform.NEXUS_9000; } if (numLayer3ExplicitNoShutdown == 0 && numLayer3ExplicitShutdown > 0) { return NexusPlatform.NEXUS_3000; } if (numLayer3ExplicitNoShutdown > 0 && numLayer3ExplicitShutdown == 0) { return NexusPlatform.NEXUS_9000; } return NexusPlatform.NEXUS_3000; } CiscoNxosPreprocessor(
      String text,
      CiscoNxosCombinedParser parser,
      Warnings warnings,
      CiscoNxosConfiguration configuration); static @Nonnull NxosMajorVersion inferMajorVersion(CiscoNxosConfiguration vc); static @Nonnull NexusPlatform inferPlatform(
      CiscoNxosConfiguration vc,
      NxosMajorVersion majorVersion,
      int numLayer3ExplicitShutdown,
      int numLayer3ExplicitNoShutdown); static boolean getDefaultDefaultSwitchport(
      CiscoNxosConfiguration vc,
      NexusPlatform platform,
      NxosMajorVersion majorVersion,
      int defaultLayer2EvidenceCount,
      int defaultLayer3EvidenceCount); static boolean getNonSwitchportDefaultShutdown(
      NexusPlatform platform, NxosMajorVersion majorVersion); @Override void exitCisco_nxos_configuration(Cisco_nxos_configurationContext ctx); @Override void exitS_version(S_versionContext ctx); @Override void exitBoot_kickstart(Boot_kickstartContext ctx); @Override void exitBoot_nxos(Boot_nxosContext ctx); @Override void exitBoot_system(Boot_systemContext ctx); @Override void enterS_interface_regular(S_interface_regularContext ctx); @Override void exitS_interface_regular(S_interface_regularContext ctx); @Override void exitI_shutdown(I_shutdownContext ctx); @Override void exitI_no_shutdown(I_no_shutdownContext ctx); @Override void exitInos_switchport(Inos_switchportContext ctx); @Override void exitI_switchport_switchport(I_switchport_switchportContext ctx); @Override void exitNo_sysds_switchport(No_sysds_switchportContext ctx); @Override void exitSysds_switchport(Sysds_switchportContext ctx); @Override void exitI_switchport(I_switchportContext ctx); @Override void exitI_ip_address(I_ip_addressContext ctx); @Override void exitI_vrf_member(I_vrf_memberContext ctx); }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { public static @Nonnull NexusPlatform inferPlatform( CiscoNxosConfiguration vc, NxosMajorVersion majorVersion, int numLayer3ExplicitShutdown, int numLayer3ExplicitNoShutdown) { Optional<NexusPlatform> initialGuessOrNoInformation = Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .findFirst() .map(CiscoNxosPreprocessor::inferPlatformFromImage); if (!initialGuessOrNoInformation.isPresent()) { return NexusPlatform.UNKNOWN; } NexusPlatform initialGuess = initialGuessOrNoInformation.get(); if (initialGuess != NexusPlatform.UNKNOWN) { return initialGuess; } if (majorVersion == NxosMajorVersion.NXOS9) { return NexusPlatform.NEXUS_9000; } if (numLayer3ExplicitNoShutdown == 0 && numLayer3ExplicitShutdown > 0) { return NexusPlatform.NEXUS_3000; } if (numLayer3ExplicitNoShutdown > 0 && numLayer3ExplicitShutdown == 0) { return NexusPlatform.NEXUS_9000; } return NexusPlatform.NEXUS_3000; } CiscoNxosPreprocessor(
      String text,
      CiscoNxosCombinedParser parser,
      Warnings warnings,
      CiscoNxosConfiguration configuration); static @Nonnull NxosMajorVersion inferMajorVersion(CiscoNxosConfiguration vc); static @Nonnull NexusPlatform inferPlatform(
      CiscoNxosConfiguration vc,
      NxosMajorVersion majorVersion,
      int numLayer3ExplicitShutdown,
      int numLayer3ExplicitNoShutdown); static boolean getDefaultDefaultSwitchport(
      CiscoNxosConfiguration vc,
      NexusPlatform platform,
      NxosMajorVersion majorVersion,
      int defaultLayer2EvidenceCount,
      int defaultLayer3EvidenceCount); static boolean getNonSwitchportDefaultShutdown(
      NexusPlatform platform, NxosMajorVersion majorVersion); @Override void exitCisco_nxos_configuration(Cisco_nxos_configurationContext ctx); @Override void exitS_version(S_versionContext ctx); @Override void exitBoot_kickstart(Boot_kickstartContext ctx); @Override void exitBoot_nxos(Boot_nxosContext ctx); @Override void exitBoot_system(Boot_systemContext ctx); @Override void enterS_interface_regular(S_interface_regularContext ctx); @Override void exitS_interface_regular(S_interface_regularContext ctx); @Override void exitI_shutdown(I_shutdownContext ctx); @Override void exitI_no_shutdown(I_no_shutdownContext ctx); @Override void exitInos_switchport(Inos_switchportContext ctx); @Override void exitI_switchport_switchport(I_switchport_switchportContext ctx); @Override void exitNo_sysds_switchport(No_sysds_switchportContext ctx); @Override void exitSysds_switchport(Sysds_switchportContext ctx); @Override void exitI_switchport(I_switchportContext ctx); @Override void exitI_ip_address(I_ip_addressContext ctx); @Override void exitI_vrf_member(I_vrf_memberContext ctx);  }