@Test public void testInferMajorVersion() { CiscoNxosConfiguration vc = new CiscoNxosConfiguration(); assertThat(inferMajorVersion(vc), equalTo(NxosMajorVersion.UNKNOWN)); vc.setBootKickstartSup2("bootflash:/titanium-d1-kickstart.7.3.0.D1.1.bin"); assertThat(inferMajorVersion(vc), equalTo(NXOS7)); vc.setBootKickstartSup1("bootflash:/n7700-s2-kickstart.6.2.16.bin"); assertThat(inferMajorVersion(vc), equalTo(NXOS6)); vc.setBootSystemSup2("bootflash:/titanium-d1.7.3.0.D1.1.bin"); assertThat(inferMajorVersion(vc), equalTo(NXOS7)); vc.setBootSystemSup1("bootflash:/n3000-uk9.6.0.2.U3.2.bin"); assertThat(inferMajorVersion(vc), equalTo(NXOS6)); vc.setBootNxosSup2("bootflash:/nxos.9.2.1.bin"); assertThat(inferMajorVersion(vc), equalTo(NXOS9)); vc.setBootNxosSup1("bootflash:/nxos.7.0.3.I7.2.bin"); assertThat(inferMajorVersion(vc), equalTo(NXOS7)); vc.setVersion("9.2.3 Bios:version"); assertThat(inferMajorVersion(vc), equalTo(NXOS9)); }
public static @Nonnull NxosMajorVersion inferMajorVersion(CiscoNxosConfiguration vc) { String versionString = vc.getVersion(); if (versionString != null) { NxosMajorVersion explicit = inferMajorVersionFromVersion(vc.getVersion()); if (explicit != null) { return explicit; } } return Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .map(CiscoNxosPreprocessor::inferMajorVersionFromImage) .filter(Objects::nonNull) .findFirst() .orElse(NxosMajorVersion.UNKNOWN); }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { public static @Nonnull NxosMajorVersion inferMajorVersion(CiscoNxosConfiguration vc) { String versionString = vc.getVersion(); if (versionString != null) { NxosMajorVersion explicit = inferMajorVersionFromVersion(vc.getVersion()); if (explicit != null) { return explicit; } } return Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .map(CiscoNxosPreprocessor::inferMajorVersionFromImage) .filter(Objects::nonNull) .findFirst() .orElse(NxosMajorVersion.UNKNOWN); } }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { public static @Nonnull NxosMajorVersion inferMajorVersion(CiscoNxosConfiguration vc) { String versionString = vc.getVersion(); if (versionString != null) { NxosMajorVersion explicit = inferMajorVersionFromVersion(vc.getVersion()); if (explicit != null) { return explicit; } } return Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .map(CiscoNxosPreprocessor::inferMajorVersionFromImage) .filter(Objects::nonNull) .findFirst() .orElse(NxosMajorVersion.UNKNOWN); } CiscoNxosPreprocessor(
      String text,
      CiscoNxosCombinedParser parser,
      Warnings warnings,
      CiscoNxosConfiguration configuration); }
CiscoNxosPreprocessor extends CiscoNxosParserBaseListener { public static @Nonnull NxosMajorVersion inferMajorVersion(CiscoNxosConfiguration vc) { String versionString = vc.getVersion(); if (versionString != null) { NxosMajorVersion explicit = inferMajorVersionFromVersion(vc.getVersion()); if (explicit != null) { return explicit; } } return Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .map(CiscoNxosPreprocessor::inferMajorVersionFromImage) .filter(Objects::nonNull) .findFirst() .orElse(NxosMajorVersion.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 { public static @Nonnull NxosMajorVersion inferMajorVersion(CiscoNxosConfiguration vc) { String versionString = vc.getVersion(); if (versionString != null) { NxosMajorVersion explicit = inferMajorVersionFromVersion(vc.getVersion()); if (explicit != null) { return explicit; } } return Stream.of( vc.getBootNxosSup1(), vc.getBootNxosSup2(), vc.getBootSystemSup1(), vc.getBootSystemSup2(), vc.getBootKickstartSup1(), vc.getBootKickstartSup2()) .filter(Objects::nonNull) .map(CiscoNxosPreprocessor::inferMajorVersionFromImage) .filter(Objects::nonNull) .findFirst() .orElse(NxosMajorVersion.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);  }