@Test public void testInferPlatformFromImage() { assertThat( inferPlatformFromImage("bootflash:/n3000-uk9-kickstart.6.0.2.U3.2.bin"), equalTo(NEXUS_3000)); assertThat( inferPlatformFromImage("bootflash:/n3000-uk9-kickstart.6.0.2.U3.5.bin"), equalTo(NEXUS_3000)); assertThat( inferPlatformFromImage("bootflash:/n3000-uk9-kickstart.6.0.2.U3.7.bin"), equalTo(NEXUS_3000)); assertThat( inferPlatformFromImage("bootflash:/n3000-uk9-kickstart.6.0.2.U6.6.bin"), equalTo(NEXUS_3000)); assertThat(inferPlatformFromImage("bootflash:/n3000-uk9.6.0.2.U3.2.bin"), equalTo(NEXUS_3000)); assertThat(inferPlatformFromImage("bootflash:/n3000-uk9.6.0.2.U3.5.bin"), equalTo(NEXUS_3000)); assertThat(inferPlatformFromImage("bootflash:/n3000-uk9.6.0.2.U3.7.bin"), equalTo(NEXUS_3000)); assertThat(inferPlatformFromImage("bootflash:/n3000-uk9.6.0.2.U6.6.bin"), equalTo(NEXUS_3000)); assertThat( inferPlatformFromImage("bootflash:/n5000-uk9-kickstart.5.1.3.N1.1a.bin"), equalTo(NEXUS_5000)); assertThat( inferPlatformFromImage("bootflash:/n5000-uk9-kickstart.5.1.3.N2.1c.bin"), equalTo(NEXUS_5000)); assertThat( inferPlatformFromImage("bootflash:/n5000-uk9-kickstart.5.2.1.N1.9.bin"), equalTo(NEXUS_5000)); assertThat( inferPlatformFromImage("bootflash:/n5000-uk9-kickstart.6.0.2.N2.5.bin"), equalTo(NEXUS_5000)); assertThat( inferPlatformFromImage("bootflash:/n5000-uk9-kickstart.7.0.6.N1.1.bin"), equalTo(NEXUS_5000)); assertThat(inferPlatformFromImage("bootflash:/n5000-uk9.5.1.3.N1.1a.bin"), equalTo(NEXUS_5000)); assertThat(inferPlatformFromImage("bootflash:/n5000-uk9.5.1.3.N2.1c.bin"), equalTo(NEXUS_5000)); assertThat(inferPlatformFromImage("bootflash:/n5000-uk9.5.2.1.N1.9.bin"), equalTo(NEXUS_5000)); assertThat(inferPlatformFromImage("bootflash:/n5000-uk9.6.0.2.N2.5.bin"), equalTo(NEXUS_5000)); assertThat(inferPlatformFromImage("bootflash:/n5000-uk9.7.0.6.N1.1.bin"), equalTo(NEXUS_5000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.6.0.2.N2.3.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.6.0.2.N2.4.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.0.2.N1.1.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.0.5.N1.1a.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.0.5.N1.1a.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.0.8.N1.1a.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.0.8.N1.1.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.1.0.N1.1b.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.1.4.N1.1.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.3.0.N1.1.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n6000-uk9-kickstart.7.3.2.N1.1.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.6.0.2.N2.3.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.6.0.2.N2.4.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.0.2.N1.1.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.0.5.N1.1a.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.0.5.N1.1a.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.0.8.N1.1a.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.0.8.N1.1.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.1.0.N1.1b.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.1.4.N1.1.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.3.0.N1.1.bin"), equalTo(NEXUS_6000)); assertThat(inferPlatformFromImage("bootflash:/n6000-uk9.7.3.2.N1.1.bin"), equalTo(NEXUS_6000)); assertThat( inferPlatformFromImage("bootflash:/n7000-s2-kickstart.6.2.16.bin"), equalTo(NEXUS_7000)); assertThat( inferPlatformFromImage("bootflash:/n7000-s2-kickstart.6.2.16.bin"), equalTo(NEXUS_7000)); assertThat( inferPlatformFromImage("bootflash:/n7700-s2-kickstart.6.2.16.bin"), equalTo(NEXUS_7000)); assertThat( inferPlatformFromImage("bootflash:/n7700-s2-kickstart.6.2.16.bin"), equalTo(NEXUS_7000)); assertThat( inferPlatformFromImage("bootflash:/titanium-d1-kickstart.7.3.0.D1.1.bin"), equalTo(NEXUS_7000)); assertThat(inferPlatformFromImage("bootflash:/n7000-s2-dk9.6.2.16.bin"), equalTo(NEXUS_7000)); assertThat(inferPlatformFromImage("bootflash:/n7000-s2-dk9.6.2.16.bin"), equalTo(NEXUS_7000)); assertThat(inferPlatformFromImage("bootflash:/n7700-s2-dk9.6.2.16.bin"), equalTo(NEXUS_7000)); assertThat(inferPlatformFromImage("bootflash:/n7700-s2-dk9.6.2.16.bin"), equalTo(NEXUS_7000)); assertThat( inferPlatformFromImage("bootflash:/titanium-d1.7.3.0.D1.1.bin"), equalTo(NEXUS_7000)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I2.2b.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I2.3.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I3.1.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I3.1.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I4.1.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I4.3.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I4.5.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I4.5.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I4.5.comp3048.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I4.5.comp3172.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I5.1.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I5.2.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I7.2.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/nxos.7.0.3.I7.4.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat( inferPlatformFromImage("bootflash:/poap/nxos.7.0.3.I3.1.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat(inferPlatformFromImage("bootflash:/nxos.9.2.1.bin"), equalTo(NexusPlatform.UNKNOWN)); assertThat(inferPlatformFromImage("bootflash:/nxos.9.2.3.bin"), equalTo(NexusPlatform.UNKNOWN)); }
@VisibleForTesting static @Nonnull NexusPlatform inferPlatformFromImage(String image) { if (image.contains("n3000")) { return NexusPlatform.NEXUS_3000; } else if (image.contains("n5000")) { return NexusPlatform.NEXUS_5000; } else if (image.contains("n6000")) { return NexusPlatform.NEXUS_6000; } else if (image.contains("n7000") || image.contains("n7700") || image.contains("titanium")) { return NexusPlatform.NEXUS_7000; } else { return NexusPlatform.UNKNOWN; } }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { @VisibleForTesting static @Nonnull NexusPlatform inferPlatformFromImage(String image) { if (image.contains("n3000")) { return NexusPlatform.NEXUS_3000; } else if (image.contains("n5000")) { return NexusPlatform.NEXUS_5000; } else if (image.contains("n6000")) { return NexusPlatform.NEXUS_6000; } else if (image.contains("n7000") || image.contains("n7700") || image.contains("titanium")) { return NexusPlatform.NEXUS_7000; } else { return NexusPlatform.UNKNOWN; } } }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { @VisibleForTesting static @Nonnull NexusPlatform inferPlatformFromImage(String image) { if (image.contains("n3000")) { return NexusPlatform.NEXUS_3000; } else if (image.contains("n5000")) { return NexusPlatform.NEXUS_5000; } else if (image.contains("n6000")) { return NexusPlatform.NEXUS_6000; } else if (image.contains("n7000") || image.contains("n7700") || image.contains("titanium")) { return NexusPlatform.NEXUS_7000; } else { return NexusPlatform.UNKNOWN; } } CiscoNxosPreprocessor(
      String text,
      CiscoNxosCombinedParser parser,
      Warnings warnings,
      CiscoNxosConfiguration configuration); }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { @VisibleForTesting static @Nonnull NexusPlatform inferPlatformFromImage(String image) { if (image.contains("n3000")) { return NexusPlatform.NEXUS_3000; } else if (image.contains("n5000")) { return NexusPlatform.NEXUS_5000; } else if (image.contains("n6000")) { return NexusPlatform.NEXUS_6000; } else if (image.contains("n7000") || image.contains("n7700") || image.contains("titanium")) { return NexusPlatform.NEXUS_7000; } else { return NexusPlatform.UNKNOWN; } } 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 { @VisibleForTesting static @Nonnull NexusPlatform inferPlatformFromImage(String image) { if (image.contains("n3000")) { return NexusPlatform.NEXUS_3000; } else if (image.contains("n5000")) { return NexusPlatform.NEXUS_5000; } else if (image.contains("n6000")) { return NexusPlatform.NEXUS_6000; } else if (image.contains("n7000") || image.contains("n7700") || image.contains("titanium")) { return NexusPlatform.NEXUS_7000; } else { return NexusPlatform.UNKNOWN; } } 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);  }