Exemple #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;
  }
Exemple #2
0
  @Test
  public void testDefaultConfiguration2()
      throws MarshalException, ValidationException, IOException {

    assertEquals(5, m_linkdConfig.getThreads());
    assertEquals(3600000, m_linkdConfig.getInitialSleepTime());
    assertEquals(18000000, m_linkdConfig.getSnmpPollInterval());
    assertEquals(1800000, m_linkdConfig.getDiscoveryLinkInterval());

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

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

    Enumeration<org.opennms.netmgt.config.linkd.Package> iter = m_linkdConfig.enumeratePackage();
    org.opennms.netmgt.config.linkd.Package example1 = iter.nextElement();

    assertEquals(false, iter.hasMoreElements());
    assertEquals("example1", example1.getName());
    assertEquals(false, example1.hasAutoDiscovery());
    assertEquals(false, example1.hasDiscovery_link_interval());
    assertEquals(false, example1.hasEnableVlanDiscovery());
    assertEquals(false, example1.hasForceIpRouteDiscoveryOnEthernet());
    assertEquals(false, example1.hasSaveRouteTable());
    assertEquals(false, example1.hasSaveStpInterfaceTable());
    assertEquals(false, example1.hasSaveStpNodeTable());
    assertEquals(false, example1.hasSnmp_poll_interval());
    assertEquals(false, example1.hasUseBridgeDiscovery());
    assertEquals(false, example1.hasUseCdpDiscovery());
    assertEquals(false, example1.hasUseIpRouteDiscovery());
    assertEquals(false, example1.hasUseIsisDiscovery());

    assertEquals(
        false, m_linkdConfig.isInterfaceInPackage(InetAddressUtils.addr(CISCO_C870_IP), example1));

    m_nodeDao.save(builder.getCiscoC870());
    m_nodeDao.save(builder.getCiscoWsC2948());
    m_nodeDao.flush();

    m_linkdConfig.update();

    assertEquals(
        true, m_linkdConfig.isInterfaceInPackage(InetAddressUtils.addr(CISCO_C870_IP), example1));
    assertEquals(
        true,
        m_linkdConfig.isInterfaceInPackage(InetAddressUtils.addr(CISCO_WS_C2948_IP), example1));

    final OnmsNode ciscorouter = m_nodeDao.findByForeignId("linkd", CISCO_C870_NAME);
    final OnmsNode ciscows = m_nodeDao.findByForeignId("linkd", CISCO_WS_C2948_NAME);
    assertTrue(m_linkd.scheduleNodeCollection(ciscorouter.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(ciscows.getId()));

    LinkableNode lciscorouter =
        m_linkd.removeNode("example1", InetAddressUtils.addr(CISCO_C870_IP));
    assertNotNull(lciscorouter);
    assertEquals(ciscorouter.getId().intValue(), lciscorouter.getNodeId());

    assertEquals(1, m_linkd.getActivePackages().size());
  }