Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
  private void populateSnmpCollection(
      final SnmpCollection coll, final Package pkg, final String sysoid) {
    coll.setPackageName(pkg.getName());
    coll.setInitialSleepTime(m_linkdConfig.getInitialSleepTime());
    coll.setPollInterval(
        pkg.hasSnmp_poll_interval()
            ? pkg.getSnmp_poll_interval()
            : m_linkdConfig.getSnmpPollInterval());
    // TODO: Put this logic inside LinkdConfigManager
    if (m_linkdConfig.hasIpRouteClassName(sysoid)) {
      coll.setIpRouteClass(m_linkdConfig.getIpRouteClassName(sysoid));
      LogUtils.debugf(
          this, "populateSnmpCollection: found class to get ipRoute: %s", coll.getIpRouteClass());
    } else {
      coll.setIpRouteClass(m_linkdConfig.getDefaultIpRouteClassName());
      LogUtils.debugf(
          this,
          "populateSnmpCollection: Using default class to get ipRoute: %s",
          coll.getIpRouteClass());
    }

    if (pkg.hasEnableVlanDiscovery()
        && pkg.getEnableVlanDiscovery()
        && m_linkdConfig.hasClassName(sysoid)) {
      coll.setVlanClass(m_linkdConfig.getVlanClassName(sysoid));
      LogUtils.debugf(
          this, "populateSnmpCollection: found class to get Vlans: %s", coll.getVlanClass());
    } else if (!pkg.hasEnableVlanDiscovery()
        && m_linkdConfig.isVlanDiscoveryEnabled()
        && m_linkdConfig.hasClassName(sysoid)) {
      coll.setVlanClass(m_linkdConfig.getVlanClassName(sysoid));
      LogUtils.debugf(
          this, "populateSnmpCollection: found class to get Vlans: %s", coll.getVlanClass());
    } else {
      LogUtils.debugf(
          this,
          "populateSnmpCollection: no class found to get Vlans or VlanDiscoveryDisabled for Package: %s",
          pkg.getName());
    }

    coll.collectCdpTable(
        pkg.hasUseCdpDiscovery() ? pkg.getUseCdpDiscovery() : m_linkdConfig.useCdpDiscovery());

    final boolean useIpRouteDiscovery =
        (pkg.hasUseIpRouteDiscovery()
            ? pkg.getUseIpRouteDiscovery()
            : m_linkdConfig.useIpRouteDiscovery());
    final boolean saveRouteTable =
        (pkg.hasSaveRouteTable() ? pkg.getSaveRouteTable() : m_linkdConfig.saveRouteTable());

    coll.SaveIpRouteTable(saveRouteTable);
    coll.collectIpRouteTable(useIpRouteDiscovery || saveRouteTable);

    final boolean useBridgeDiscovery =
        (pkg.hasUseBridgeDiscovery()
            ? pkg.getUseBridgeDiscovery()
            : m_linkdConfig.useBridgeDiscovery());
    coll.collectBridgeForwardingTable(useBridgeDiscovery);

    final boolean saveStpNodeTable =
        (pkg.hasSaveStpNodeTable() ? pkg.getSaveStpNodeTable() : m_linkdConfig.saveStpNodeTable());

    coll.saveStpNodeTable(saveStpNodeTable);
    coll.collectStpNode(useBridgeDiscovery || saveStpNodeTable);

    final boolean saveStpInterfaceTable =
        (pkg.hasSaveStpInterfaceTable()
            ? pkg.getSaveStpInterfaceTable()
            : m_linkdConfig.saveStpInterfaceTable());

    coll.saveStpInterfaceTable(saveStpInterfaceTable);
    coll.collectStpTable(useBridgeDiscovery || saveStpInterfaceTable);
  }
Ejemplo n.º 3
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());
  }