Esempio n. 1
0
  /**
   * Send a newSuspect event for the interface construct event with 'linkd' as source
   *
   * @param ipInterface The interface for which the newSuspect event is to be generated
   * @param ipowner The host that hold this ipInterface information
   * @pkgName The package Name of the ready runnable involved
   */
  void sendNewSuspectEvent(InetAddress ipaddress, InetAddress ipowner, String pkgName) {

    if (m_newSuspectEventsIpAddr.contains(ipaddress)) {
      LogUtils.infof(
          this,
          "sendNewSuspectEvent: nothing to send, suspect event previously sent for IP address: %s",
          str(ipaddress));
      return;
    } else if (!isInterfaceInPackageRange(ipaddress, pkgName)) {
      LogUtils.infof(
          this,
          "sendNewSuspectEvent: nothing to send for IP address: %s, not in package: %s",
          str(ipaddress),
          pkgName);
      return;
    }

    org.opennms.netmgt.config.linkd.Package pkg = m_linkdConfig.getPackage(pkgName);

    boolean autodiscovery = false;
    if (pkg.hasAutoDiscovery()) autodiscovery = pkg.getAutoDiscovery();
    else autodiscovery = m_linkdConfig.isAutoDiscoveryEnabled();

    if (autodiscovery) {

      EventBuilder bldr = new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, "linkd");

      bldr.setHost(str(ipowner));
      bldr.setInterface(ipaddress);

      m_eventForwarder.sendNow(bldr.getEvent());

      m_newSuspectEventsIpAddr.add(ipaddress);
    }
  }
Esempio n. 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());
  }