Beispiel #1
0
  /** {@inheritDoc} */
  public DiscoveryLink getDiscoveryLink(final String pkgName) {
    final Package pkg = m_linkdConfig.getPackage(pkgName);

    if (pkg == null) return null;

    final DiscoveryLink discoveryLink = new DiscoveryLink();
    discoveryLink.setLinkd(this);
    discoveryLink.setPackageName(pkg.getName());
    discoveryLink.setInitialSleepTime(m_linkdConfig.getInitialSleepTime());

    discoveryLink.setSnmpPollInterval(
        pkg.hasSnmp_poll_interval()
            ? pkg.getSnmp_poll_interval()
            : m_linkdConfig.getSnmpPollInterval());
    discoveryLink.setDiscoveryInterval(
        pkg.hasDiscovery_link_interval()
            ? pkg.getDiscovery_link_interval()
            : m_linkdConfig.getDiscoveryLinkInterval());
    discoveryLink.setDiscoveryUsingBridge(
        pkg.hasUseBridgeDiscovery()
            ? pkg.getUseBridgeDiscovery()
            : m_linkdConfig.useBridgeDiscovery());
    discoveryLink.setDiscoveryUsingCdp(
        pkg.hasUseCdpDiscovery() ? pkg.getUseCdpDiscovery() : m_linkdConfig.useCdpDiscovery());
    discoveryLink.setDiscoveryUsingRoutes(
        pkg.hasUseIpRouteDiscovery()
            ? pkg.getUseIpRouteDiscovery()
            : m_linkdConfig.useIpRouteDiscovery());
    discoveryLink.setEnableDownloadDiscovery(
        pkg.hasEnableDiscoveryDownload()
            ? pkg.getEnableDiscoveryDownload()
            : m_linkdConfig.enableDiscoveryDownload());
    discoveryLink.setForceIpRouteDiscoveryOnEtherNet(
        pkg.hasForceIpRouteDiscoveryOnEthernet()
            ? pkg.getForceIpRouteDiscoveryOnEthernet()
            : m_linkdConfig.forceIpRouteDiscoveryOnEthernet());

    return discoveryLink;
  }
Beispiel #2
0
  @Test
  @Transactional
  public void testDefaultConfiguration() throws Exception {
    m_nodeDao.save(builder1.getExampleCom());
    m_nodeDao.save(builder1.getLaptop());
    m_nodeDao.save(builder1.getCisco7200a());
    m_nodeDao.save(builder1.getCisco7200b());
    m_nodeDao.save(builder1.getCisco3700());
    m_nodeDao.save(builder1.getCisco2691());
    m_nodeDao.save(builder1.getCisco1700());
    m_nodeDao.save(builder1.getCisco3600());
    m_nodeDao.flush();

    assertEquals(true, m_linkdConfig.useBridgeDiscovery());
    assertEquals(true, m_linkdConfig.useOspfDiscovery());
    assertEquals(true, m_linkdConfig.useIpRouteDiscovery());
    assertEquals(true, m_linkdConfig.useLldpDiscovery());
    assertEquals(true, m_linkdConfig.useCdpDiscovery());
    assertEquals(true, m_linkdConfig.useIsIsDiscovery());

    assertEquals(true, m_linkdConfig.saveRouteTable());
    assertEquals(true, m_linkdConfig.saveStpNodeTable());
    assertEquals(true, m_linkdConfig.saveStpInterfaceTable());

    assertEquals(true, m_linkdConfig.isVlanDiscoveryEnabled());

    assertEquals(false, m_linkdConfig.isAutoDiscoveryEnabled());
    assertEquals(false, m_linkdConfig.forceIpRouteDiscoveryOnEthernet());

    assertEquals(false, m_linkdConfig.hasClassName(".1.3.6.1.4.1.2636.1.1.1.1.9"));

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ThreeComVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.43.1.9.13.3.1"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ThreeComVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.43.10.27.4.1.2.4"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ThreeComVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.43.10.27.4.1.2.2"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ThreeComVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.43.10.27.4.1.2.11"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ThreeComVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.43.1.16.4.3.5"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ThreeComVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.43.1.16.4.3.6"));

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.43.1.8.43"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.43.1.8.61"));

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.RapidCityVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.45.3.61.1"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.RapidCityVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.45.3.35.1"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.RapidCityVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.45.3.53.1"));

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.IntelVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.343.5.1.5"));

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.11.2.3.7.11.1"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.11.2.3.7.11.3"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.11.2.3.7.11.7"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.11.2.3.7.11.8"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.11.2.3.7.11.11"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.11.2.3.7.11.6"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.Dot1qStaticVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.11.2.3.7.11.50"));

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.CiscoVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.9.1.300"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.CiscoVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.9.1.122"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.CiscoVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.9.1.616"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.CiscoVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.9.5.42"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.CiscoVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.9.5.59"));

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ExtremeNetworkVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.1916.2.11"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ExtremeNetworkVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.1916.2.14"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.ExtremeNetworkVlanTable",
        m_linkdConfig.getVlanClassName(".1.3.6.1.4.1.1916.2.63"));

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.IpCidrRouteTable",
        m_linkdConfig.getDefaultIpRouteClassName());
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.IpRouteTable",
        m_linkdConfig.getIpRouteClassName(".1.3.6.1.4.1.3224.1.51"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.IpRouteTable",
        m_linkdConfig.getIpRouteClassName(".1.3.6.1.4.1.9.1.569"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.IpRouteTable",
        m_linkdConfig.getIpRouteClassName(".1.3.6.1.4.1.9.5.42"));
    assertEquals(
        "org.opennms.netmgt.linkd.snmp.IpRouteTable",
        m_linkdConfig.getIpRouteClassName(".1.3.6.1.4.1.8072.3.2.255"));

    final OnmsNode laptop = m_nodeDao.findByForeignId("linkd", "laptop");
    final OnmsNode cisco3600 = m_nodeDao.findByForeignId("linkd", "cisco3600");

    assertTrue(m_linkd.scheduleNodeCollection(laptop.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(cisco3600.getId()));

    SnmpCollection snmpCollLaptop =
        m_linkd.getSnmpCollection(
            laptop.getId(),
            laptop.getPrimaryInterface().getIpAddress(),
            laptop.getSysObjectId(),
            "example1");
    assertEquals(true, snmpCollLaptop.getCollectBridge());
    assertEquals(true, snmpCollLaptop.getCollectStp());
    assertEquals(true, snmpCollLaptop.getCollectCdp());
    assertEquals(true, snmpCollLaptop.getCollectIpRoute());
    assertEquals(true, snmpCollLaptop.getCollectOspf());
    assertEquals(true, snmpCollLaptop.getCollectLldp());

    assertEquals(false, snmpCollLaptop.collectVlanTable());

    assertEquals("org.opennms.netmgt.linkd.snmp.IpRouteTable", snmpCollLaptop.getIpRouteClass());
    assertEquals("example1", snmpCollLaptop.getPackageName());
    assertEquals(true, m_linkd.saveRouteTable("example1"));
    assertEquals(true, m_linkd.saveStpNodeTable("example1"));
    assertEquals(true, m_linkd.saveStpInterfaceTable("example1"));

    SnmpCollection snmpCollcisco3600 =
        m_linkd.getSnmpCollection(
            cisco3600.getId(),
            cisco3600.getPrimaryInterface().getIpAddress(),
            cisco3600.getSysObjectId(),
            "example1");

    assertEquals(true, snmpCollcisco3600.getCollectBridge());
    assertEquals(true, snmpCollcisco3600.getCollectStp());
    assertEquals(true, snmpCollcisco3600.getCollectCdp());
    assertEquals(true, snmpCollcisco3600.getCollectIpRoute());
    assertEquals(true, snmpCollcisco3600.getCollectOspf());
    assertEquals(true, snmpCollcisco3600.getCollectLldp());

    assertEquals(true, snmpCollcisco3600.collectVlanTable());
    assertEquals("org.opennms.netmgt.linkd.snmp.CiscoVlanTable", snmpCollcisco3600.getVlanClass());

    assertEquals(
        "org.opennms.netmgt.linkd.snmp.IpCidrRouteTable", snmpCollcisco3600.getIpRouteClass());
    assertEquals("example1", snmpCollcisco3600.getPackageName());

    Package example1 = m_linkdConfig.getPackage("example1");
    assertEquals(false, example1.getForceIpRouteDiscoveryOnEthernet());

    final Enumeration<Package> pkgs = m_linkdConfig.enumeratePackage();
    example1 = pkgs.nextElement();
    assertEquals("example1", example1.getName());
    assertEquals(false, pkgs.hasMoreElements());
  }