Ejemplo 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);
    }
  }
Ejemplo n.º 2
0
  /**
   * This method is used to establish package against IP list mapping, with which, the IP list is
   * selected per package via the configured filter rules from the database.
   */
  protected void updatePackageIpListMap() {
    m_pkgIpMap.clear();
    try {
      getWriteLock().lock();
      for (final org.opennms.netmgt.config.linkd.Package pkg : m_config.getPackageCollection()) {
        //
        // Get a list of IP addresses per package against the filter rules from
        // database and populate the package, IP list map.
        //
        try {
          final List<InetAddress> ipList = getIpList(pkg);
          LOG.trace(
              "createPackageIpMap: package {}: ipList size = {}", pkg.getName(), ipList.size());

          if (ipList != null && ipList.size() > 0) {
            m_pkgIpMap.put(pkg, ipList);
          }
        } catch (final Throwable t) {
          LOG.error(
              "createPackageIpMap: failed to map package: {} to an IP list", pkg.getName(), t);
        }
      }
    } finally {
      getWriteLock().unlock();
    }
  }
Ejemplo n.º 3
0
 protected void updateUrlIpMap() {
   m_urlIPMap.clear();
   for (final org.opennms.netmgt.config.linkd.Package pkg : m_config.getPackageCollection()) {
     if (pkg == null) continue;
     for (final String urlname : pkg.getIncludeUrlCollection()) {
       final java.util.List<String> iplist = IpListFromUrl.fetch(urlname);
       if (iplist.size() > 0) {
         m_urlIPMap.put(urlname, iplist);
       }
     }
   }
 }
Ejemplo n.º 4
0
  @Before
  public void setUp() throws Exception {
    Properties p = new Properties();
    p.setProperty("log4j.logger.org.hibernate.SQL", "WARN");
    p.setProperty("log4j.logger.org.hibernate.cfg", "WARN");
    p.setProperty("log4j.logger.org.springframework", "WARN");
    p.setProperty("log4j.logger.com.mchange.v2.resourcepool", "WARN");
    MockLogAppender.setupLogging(p);

    super.setNodeDao(m_nodeDao);
    super.setSnmpInterfaceDao(m_snmpInterfaceDao);

    for (Package pkg : Collections.list(m_linkdConfig.enumeratePackage())) {
      pkg.setForceIpRouteDiscoveryOnEthernet(true);
    }
  }
Ejemplo n.º 5
0
  /**
   * This method is used to determine if the named interface is included in the passed package
   * definition. If the interface belongs to the package then a value of true is returned. If the
   * interface does not belong to the package a false value is returned.
   *
   * <p><strong>Note: </strong>Evaluation of the interface against a package filter will only work
   * if the IP is already in the database.
   *
   * @param iface The interface to test against the package.
   * @param pkg The package to check for the inclusion of the interface.
   * @return True if the interface is included in the package, false otherwise.
   */
  @Override
  public boolean isInterfaceInPackage(
      final InetAddress iface, final org.opennms.netmgt.config.linkd.Package pkg) {
    boolean filterPassed = false;

    try {
      getReadLock().lock();

      // get list of IPs in this package
      final List<InetAddress> ipList = m_pkgIpMap.get(pkg);
      if (ipList != null && ipList.size() > 0) {
        filterPassed = ipList.contains(iface);
      }

      LOG.debug(
          "interfaceInPackage: Interface {} passed filter for package {}?: {}",
          str(iface),
          pkg.getName(),
          (filterPassed ? "True" : "False"));

      if (!filterPassed) return false;

      return isInterfaceInPackageRange(iface, pkg);
    } finally {
      getReadLock().unlock();
    }
  }
Ejemplo n.º 6
0
 /** {@inheritDoc} */
 @Override
 public org.opennms.netmgt.config.linkd.Package getPackage(final String name) {
   try {
     getReadLock().lock();
     for (final org.opennms.netmgt.config.linkd.Package thisPackage :
         m_config.getPackageCollection()) {
       final String n = thisPackage.getName();
       if (n != null && n.equals(name)) {
         return thisPackage;
       }
     }
   } finally {
     getReadLock().unlock();
   }
   return null;
 }
Ejemplo n.º 7
0
  /**
   * {@inheritDoc}
   *
   * <p>Returns a list of package names that the IP belongs to, null if none.
   *
   * <p><strong>Note: </strong>Evaluation of the interface against a package filter will only work
   * if the IP is already in the database.
   */
  @Override
  public List<String> getAllPackageMatches(final InetAddress ipaddr) {
    final List<String> matchingPkgs = new ArrayList<String>();

    try {
      getReadLock().lock();
      for (final org.opennms.netmgt.config.linkd.Package pkg : m_config.getPackageCollection()) {
        final String pkgName = pkg.getName();
        if (isInterfaceInPackage(ipaddr, pkg)) {
          matchingPkgs.add(pkgName);
        }
      }
    } finally {
      getReadLock().unlock();
    }
    return matchingPkgs;
  }
Ejemplo n.º 8
0
  /** {@inheritDoc} */
  @Override
  public List<InetAddress> getIpList(final Package pkg) {
    try {
      getReadLock().lock();

      if (pkg == null) return null;

      final Filter filter = pkg.getFilter();
      if (filter == null) return null;

      final StringBuffer filterRules = new StringBuffer(filter.getContent());

      LOG.debug("getIpList: package is {}. filter rules are: {}", pkg.getName(), filterRules);
      FilterDaoFactory.getInstance().flushActiveIpAddressListCache();
      return FilterDaoFactory.getInstance().getActiveIPAddressList(filterRules.toString());
    } finally {
      getReadLock().unlock();
    }
  }
Ejemplo n.º 9
0
  /*
   * We want to test that the next hop router discovered
   * links can be discovered using the ospf neb table
   */
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(host = PENROSE_IP, port = 161, resource = PENROSE_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = DELAWARE_IP, port = 161, resource = DELAWARE_SNMP_RESOURCE)
      })
  public void testNetwork1055StpLinks() throws Exception {
    m_nodeDao.save(builder.getPenrose());
    m_nodeDao.save(builder.getDelaware());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseBridgeDiscovery(true);
    example1.setUseLldpDiscovery(false);
    example1.setUseCdpDiscovery(false);
    example1.setUseIpRouteDiscovery(false);
    example1.setUseOspfDiscovery(false);
    example1.setUseIsisDiscovery(false);

    example1.setSaveRouteTable(false);
    example1.setSaveStpInterfaceTable(false);
    example1.setSaveStpNodeTable(false);

    final OnmsNode penrose = m_nodeDao.findByForeignId("linkd", PENROSE_NAME);
    final OnmsNode delaware = m_nodeDao.findByForeignId("linkd", DELAWARE_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(penrose.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(delaware.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(penrose.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(delaware.getId()));

    assertEquals(0, m_dataLinkInterfaceDao.countAll());

    assertTrue(m_linkd.runSingleLinkDiscovery("example1"));

    assertEquals(1, m_dataLinkInterfaceDao.countAll());
  }
Ejemplo n.º 10
0
  @Override
  public boolean isInterfaceInPackageRange(
      final InetAddress iface, final org.opennms.netmgt.config.linkd.Package pkg) {
    if (pkg == null) return false;

    //
    // Ensure that the interface is in the specific list or
    // that it is in the include range and is not excluded
    //
    boolean has_specific = false;
    boolean has_range_include = false;
    boolean has_range_exclude = false;

    try {
      getReadLock().lock();
      byte[] addr = iface.getAddress();

      // if there are NO include ranges then treat act as if the user include
      // the range 0.0.0.0 - 255.255.255.255
      has_range_include = pkg.getIncludeRangeCount() == 0 && pkg.getSpecificCount() == 0;

      // Specific wins; if we find one, return immediately.
      for (final String spec : pkg.getSpecificCollection()) {
        final byte[] speca = toIpAddrBytes(spec);
        if (new ByteArrayComparator().compare(addr, speca) == 0) {
          has_specific = true;
          break;
        }
      }
      if (has_specific) return true;

      for (final String url : pkg.getIncludeUrlCollection()) {
        has_specific = isInterfaceInUrl(iface, url);
        if (has_specific) break;
      }
      if (has_specific) return true;

      if (!has_range_include) {
        for (final IncludeRange rng : pkg.getIncludeRangeCollection()) {
          if (isInetAddressInRange(iface.getAddress(), rng.getBegin(), rng.getEnd())) {
            has_range_include = true;
            break;
          }
        }
      }

      for (final ExcludeRange rng : pkg.getExcludeRangeCollection()) {
        if (isInetAddressInRange(iface.getAddress(), rng.getBegin(), rng.getEnd())) {
          has_range_exclude = true;
          break;
        }
      }

      return has_range_include && !has_range_exclude;
    } finally {
      getReadLock().unlock();
    }
  }
Ejemplo n.º 11
0
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(host = RDeEssnBrue_IP, port = 161, resource = RDeEssnBrue_SNMP_RESOURCE),
        @JUnitSnmpAgent(
            host = SDeEssnBrue081_IP,
            port = 161,
            resource = SDeEssnBrue081_SNMP_RESOURCE),
        @JUnitSnmpAgent(
            host = SDeEssnBrue121_IP,
            port = 161,
            resource = SDeEssnBrue121_SNMP_RESOURCE),
        @JUnitSnmpAgent(
            host = SDeEssnBrue142_IP,
            port = 161,
            resource = SDeEssnBrue142_SNMP_RESOURCE),
        @JUnitSnmpAgent(
            host = SDeEssnBrue165_IP,
            port = 161,
            resource = SDeEssnBrue165_SNMP_RESOURCE)
      })
  public void testCiscoAlcatelEssnBrueLldp() {

    m_nodeDao.save(builder.getRDeEssnBrue());
    m_nodeDao.save(builder.getSDeEssnBrue081());
    m_nodeDao.save(builder.getSDeEssnBrue121());
    m_nodeDao.save(builder.getSDeEssnBrue142());
    m_nodeDao.save(builder.getSDeEssnBrue165());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseIsisDiscovery(false);
    example1.setUseIpRouteDiscovery(false);
    example1.setUseOspfDiscovery(false);
    example1.setUseLldpDiscovery(true);
    example1.setUseCdpDiscovery(false);
    example1.setUseBridgeDiscovery(false);

    example1.setEnableVlanDiscovery(false);

    example1.setSaveStpNodeTable(false);
    example1.setSaveStpInterfaceTable(false);
    example1.setSaveRouteTable(false);

    HibernateEventWriter queryManager = (HibernateEventWriter) m_linkd.getQueryManager();

    assertEquals(
        107,
        queryManager.getFromSysnameIfName(RDeEssnBrue_NAME, "Gi1/3/11").getIfIndex().intValue());
    assertEquals(
        260,
        queryManager.getFromSysnameIfName(RDeEssnBrue_NAME, "Gi2/3/11").getIfIndex().intValue());

    assertEquals(
        1025,
        queryManager.getFromSysnameIfIndex(SDeEssnBrue165_NAME, 1025).getIfIndex().intValue());
    assertEquals(
        2025,
        queryManager.getFromSysnameIfName(SDeEssnBrue165_NAME, "2/25").getIfIndex().intValue());

    final OnmsNode routerCisco = m_nodeDao.findByForeignId("linkd", RDeEssnBrue_NAME);
    final OnmsNode swicthAlu081 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue081_NAME);
    final OnmsNode swicthAlu121 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue121_NAME);
    final OnmsNode swicthAlu142 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue142_NAME);
    final OnmsNode swicthAlu165 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue165_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(routerCisco.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(swicthAlu081.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(swicthAlu121.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(swicthAlu142.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(swicthAlu165.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(routerCisco.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu081.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu121.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu142.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu165.getId()));

    assertEquals(0, m_dataLinkInterfaceDao.countAll());

    assertTrue(m_linkd.runSingleLinkDiscovery("example1"));

    for (DataLinkInterface link : m_dataLinkInterfaceDao.findAll()) {
      printLink(link);
    }

    assertEquals(6, m_dataLinkInterfaceDao.countAll());
  }
Ejemplo n.º 12
0
  /*
   * We want to test that the next hop router discovered
   * links can be discovered using the ospf neb table
   */
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(host = PENROSE_IP, port = 161, resource = PENROSE_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = DELAWARE_IP, port = 161, resource = DELAWARE_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = PHOENIX_IP, port = 161, resource = PHOENIX_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = AUSTIN_IP, port = 161, resource = AUSTIN_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = SANJOSE_IP, port = 161, resource = SANJOSE_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = RIOVISTA_IP, port = 161, resource = RIOVISTA_SNMP_RESOURCE)
      })
  public void testNetwork1055OspfLinks() throws Exception {
    m_nodeDao.save(builder.getPenrose());
    m_nodeDao.save(builder.getDelaware());
    m_nodeDao.save(builder.getPhoenix());
    m_nodeDao.save(builder.getAustin());
    m_nodeDao.save(builder.getSanjose());
    m_nodeDao.save(builder.getRiovista());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseBridgeDiscovery(false);
    example1.setUseLldpDiscovery(false);
    example1.setUseCdpDiscovery(false);
    example1.setUseIpRouteDiscovery(false);
    example1.setUseOspfDiscovery(true);
    example1.setUseIsisDiscovery(false);

    example1.setSaveRouteTable(false);
    example1.setSaveStpInterfaceTable(false);
    example1.setSaveStpNodeTable(false);
    m_linkdConfig.update();

    final OnmsNode penrose = m_nodeDao.findByForeignId("linkd", PENROSE_NAME);
    final OnmsNode delaware = m_nodeDao.findByForeignId("linkd", DELAWARE_NAME);
    final OnmsNode phoenix = m_nodeDao.findByForeignId("linkd", PHOENIX_NAME);
    final OnmsNode austin = m_nodeDao.findByForeignId("linkd", AUSTIN_NAME);
    final OnmsNode sanjose = m_nodeDao.findByForeignId("linkd", SANJOSE_NAME);
    final OnmsNode riovista = m_nodeDao.findByForeignId("linkd", RIOVISTA_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(penrose.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(delaware.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(phoenix.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(austin.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(sanjose.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(riovista.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(penrose.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(delaware.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(phoenix.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(austin.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(sanjose.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(riovista.getId()));

    assertEquals(0, m_dataLinkInterfaceDao.countAll());

    assertTrue(m_linkd.runSingleLinkDiscovery("example1"));

    assertEquals(5, m_dataLinkInterfaceDao.countAll());
    final List<DataLinkInterface> links = m_dataLinkInterfaceDao.findAll();

    final int start = getStartPoint(links);
    for (final DataLinkInterface datalinkinterface : links) {
      Integer linkid = datalinkinterface.getId();
      if (linkid == start) {
        // penrose  -> delaware --ip route next hop
        checkLink(delaware, penrose, 598, 535, datalinkinterface);
      } else if (linkid == start + 1) {
        // penrose   -> phoenix     --ip route next hop
        checkLink(phoenix, penrose, 564, 644, datalinkinterface);
      } else if (linkid == start + 2) {
        // phoenix  -> austin --ip route next hop
        checkLink(austin, phoenix, 554, 565, datalinkinterface);
      } else if (linkid == start + 3) {
        // phoenix  -> sanjose --ip route next hop
        checkLink(sanjose, phoenix, 564, 566, datalinkinterface);
      } else if (linkid == start + 4) {
        // austin  -> sanjose --ip route next hop
        checkLink(sanjose, austin, 8562, 586, datalinkinterface);
      } else {
        // error
        checkLink(penrose, penrose, -1, -1, datalinkinterface);
      }
    }
  }
Ejemplo n.º 13
0
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(
            host = CISCO_WS_C2948_IP,
            port = 161,
            resource = "classpath:linkd/nms7467/" + CISCO_WS_C2948_IP + "-walk.txt")
      })
  public void testCiscoWsC2948Collection() throws Exception {

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

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseLldpDiscovery(false);
    example1.setUseOspfDiscovery(false);
    example1.setUseIsisDiscovery(false);
    example1.setForceIpRouteDiscoveryOnEthernet(true);

    final OnmsNode ciscosw = m_nodeDao.findByForeignId("linkd", CISCO_WS_C2948_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(ciscosw.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(ciscosw.getId()));

    // linkd has 1 linkable node
    assertEquals(1, m_linkd.getLinkableNodesOnPackage("example1").size());
    LinkableNode linkNode = m_linkd.getLinkableNodesOnPackage("example1").iterator().next();

    // linkabble node is not null
    assertTrue(linkNode != null);

    // has only one route with valid next hop must be valid but type is ethernet so skipped
    // but it is itself so 0
    assertEquals(0, linkNode.getRouteInterfaces().size());
    // has 5
    assertEquals(2, m_ipRouteInterfaceDao.countAll());

    assertEquals(5, m_vlanDao.countAll());

    String packageName =
        m_linkdConfig.getFirstPackageMatch(InetAddressUtils.addr(CISCO_WS_C2948_IP)).getName();

    assertEquals("example1", packageName);

    assertEquals(1, linkNode.getBridgeIdentifiers().size());

    // has 1 stp node entry check the bridge identifier and protocol
    assertEquals(CISCO_WS_C2948_BRIDGEID, linkNode.getBridgeIdentifier(1));

    // has 50 stp entry che ifIndex must be different then -1
    //
    assertEquals(50, linkNode.getStpInterfaces().get(1).size());

    // no cdp inteface also if the walk return several interfaces
    assertEquals(
        "No cdp interface because no other node is there", 0, linkNode.getCdpInterfaces().size());

    for (OnmsStpInterface stpiface : linkNode.getStpInterfaces().get(1)) {
      assertTrue("should have a valid ifindex", stpiface.getIfIndex().intValue() > 0);
      assertTrue("should have a valid bridgeport", stpiface.getBridgePort().intValue() > 0);
    }

    // This make shure that the ip/mac association is saved
    /*
     * nodelabel:ip:mac:ifindex:ifdescr
     *
     * CISCO_WS_C2948_IP:172.20.1.7:0002baaacffe:3:me1
     */

    final List<AtInterface> atInterfaces = m_linkd.getAtInterfaces(packageName, "0002baaacffe");
    assertNotNull(atInterfaces);
    assertEquals(1, atInterfaces.size());
    AtInterface at = atInterfaces.get(0);
    assertEquals(CISCO_WS_C2948_IP, at.getIpAddress().getHostAddress());
    assertEquals(3, at.getIfIndex().intValue());
    // Now Let's test the database
    final Criteria criteria = new Criteria(OnmsIpRouteInterface.class);
    criteria.setAliases(Arrays.asList(new Alias[] {new Alias("node", "node", JoinType.LEFT_JOIN)}));
    criteria.addRestriction(new EqRestriction("node.id", ciscosw.getId()));

    // 2 route entry in database
    assertEquals(2, m_ipRouteInterfaceDao.findMatching(criteria).size());
    // 0 atinterface in database
    assertEquals(0, m_atInterfaceDao.findAll().size());

    // 5 entry in vlan
    assertEquals(5, m_vlanDao.findAll().size());

    // 1 entry in stpnode
    assertEquals(1, m_stpNodeDao.countAll());

    OnmsStpNode stpnode = m_stpNodeDao.findByNodeAndVlan(ciscosw.getId(), 1);
    assertTrue(CISCO_WS_C2948_BRIDGEID.equals(stpnode.getBaseBridgeAddress()));
    assertEquals(50, stpnode.getBaseNumPorts().intValue());

    assertEquals(BridgeBaseType.TRANSPARENT_ONLY, stpnode.getBaseType());
    assertEquals(StpProtocolSpecification.IEEE8021D, stpnode.getStpProtocolSpecification());

    // 50 entry in stpinterface
    assertEquals(50, m_stpInterfaceDao.findAll().size());
  }
  @Before
  public void setUp() throws Exception {
    Properties p = new Properties();
    p.setProperty("log4j.logger.org.hibernate.SQL", "WARN");
    MockLogAppender.setupLogging(p);

    NetworkBuilder nb = new NetworkBuilder();

    nb.addNode("cisco1")
        .setForeignSource("linkd")
        .setForeignId("cisco1")
        .setSysObjectId(".1.3.6.1.4.1.9.1.122")
        .setType("A");
    // nb.addInterface("10.1.1.1").setIsSnmpPrimary("P").setIsManaged("M")
    // .addSnmpInterface(3).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("66933c17555c");
    nb.addInterface("10.1.1.2")
        .setIsSnmpPrimary("P")
        .setIsManaged("M")
        .addSnmpInterface(3)
        .setIfType(6)
        .setCollectionEnabled(true)
        .setIfSpeed(100000000)
        .setPhysAddr("c2007db90010");
    nb.addInterface("10.1.2.1")
        .setIsSnmpPrimary("S")
        .setIsManaged("M")
        .addSnmpInterface(1)
        .setIfType(6)
        .setCollectionEnabled(true)
        .setIfSpeed(100000000)
        .setPhysAddr("c2007db90000");
    // nb.addInterface("10.1.2.2").setIsSnmpPrimary("S").setIsManaged("M")
    // .addSnmpInterface(1).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("c2017db90000");
    nb.addInterface("10.1.3.1")
        .setIsSnmpPrimary("S")
        .setIsManaged("M")
        .addSnmpInterface(2)
        .setIfType(6)
        .setCollectionEnabled(true)
        .setIfSpeed(100000000)
        .setPhysAddr("c2007db90001");
    // nb.addInterface("10.1.3.2").setIsSnmpPrimary("S").setIsManaged("M")
    // .addSnmpInterface(2).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("c2027db90000");
    m_nodeDao.save(nb.getCurrentNode());

    nb.addNode("cisco2")
        .setForeignSource("linkd")
        .setForeignId("cisco2")
        .setSysObjectId(".1.3.6.1.4.1.9.1.122")
        .setType("A");
    // nb.addInterface("10.1.2.1").setIsSnmpPrimary("P").setIsManaged("M")
    // .addSnmpInterface(1).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("c2007db90000");
    nb.addInterface("10.1.2.2")
        .setIsSnmpPrimary("P")
        .setIsManaged("M")
        .addSnmpInterface(1)
        .setIfType(6)
        .setCollectionEnabled(true)
        .setIfSpeed(100000000)
        .setPhysAddr("c2017db90000");
    nb.addInterface("10.1.5.1")
        .setIsSnmpPrimary("S")
        .setIsManaged("M")
        .addSnmpInterface(2)
        .setIfType(6)
        .setCollectionEnabled(true)
        .setIfSpeed(100000000)
        .setPhysAddr("c2017db90001");
    // nb.addInterface("10.1.5.2").setIsSnmpPrimary("S").setIsManaged("M")
    // .addSnmpInterface(2).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("c2027db90010");
    m_nodeDao.save(nb.getCurrentNode());

    nb.addNode("cisco3")
        .setForeignSource("linkd")
        .setForeignId("cisco3")
        .setSysObjectId(".1.3.6.1.4.1.9.1.122")
        .setType("A");
    // nb.addInterface("10.1.1.1").setIsSnmpPrimary("P").setIsManaged("M")
    // .addSnmpInterface(1).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("c2007db90001");
    // nb.addInterface("10.1.3.1").setIsSnmpPrimary("S").setIsManaged("M")
    // .addSnmpInterface(1).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("c2007db90001");
    nb.addInterface("10.1.3.2")
        .setIsSnmpPrimary("P")
        .setIsManaged("M")
        .addSnmpInterface(1)
        .setIfType(6)
        .setCollectionEnabled(true)
        .setIfSpeed(100000000)
        .setPhysAddr("c2027db90000");
    nb.addInterface("10.1.4.1")
        .setIsSnmpPrimary("S")
        .setIsManaged("M")
        .addSnmpInterface(2)
        .setIfType(6)
        .setCollectionEnabled(true)
        .setIfSpeed(100000000)
        .setPhysAddr("c2027db90001");
    // nb.addInterface("10.1.4.2").setIsSnmpPrimary("S").setIsManaged("M")
    // .addSnmpInterface(2).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("c2037db90000");
    // nb.addInterface("10.1.5.1").setIsSnmpPrimary("S").setIsManaged("M")
    // .addSnmpInterface(3).setIfType(6).setCollectionEnabled(true).setIfSpeed(100000000).setPhysAddr("c2017db90001");
    nb.addInterface("10.1.5.2")
        .setIsSnmpPrimary("S")
        .setIsManaged("M")
        .addSnmpInterface(3)
        .setIfType(6)
        .setCollectionEnabled(true)
        .setIfSpeed(100000000)
        .setPhysAddr("c2027db90010");
    m_nodeDao.save(nb.getCurrentNode());

    m_nodeDao.flush();

    for (Package pkg : Collections.list(m_linkdConfig.enumeratePackage())) {
      pkg.setForceIpRouteDiscoveryOnEthernet(true);
    }
  }
Ejemplo n.º 15
0
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(
            host = CISCO_C870_IP,
            port = 161,
            resource = "classpath:linkd/nms7467/" + CISCO_C870_IP + "-walk.txt")
      })
  public void testCiscoC870Collection() throws Exception {
    m_nodeDao.save(builder.getCiscoC870());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseLldpDiscovery(false);
    example1.setUseOspfDiscovery(false);
    example1.setUseIsisDiscovery(false);

    final OnmsNode ciscorouter = m_nodeDao.findByForeignId("linkd", CISCO_C870_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(ciscorouter.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(ciscorouter.getId()));

    // linkd has 1 linkable node
    assertEquals(1, m_linkd.getLinkableNodesOnPackage("example1").size());
    LinkableNode linkNode = m_linkd.getLinkableNodesOnPackage("example1").iterator().next();

    // linkabble node is not null
    assertTrue(linkNode != null);

    // has 0 route (next hop must be valid!)
    assertEquals(0, linkNode.getRouteInterfaces().size());
    // has 0 vlan
    assertEquals(0, m_vlanDao.countAll());

    String packageName =
        m_linkdConfig.getFirstPackageMatch(InetAddressUtils.addr(CISCO_C870_IP)).getName();

    assertEquals("example1", packageName);

    assertEquals(1, linkNode.getBridgeIdentifiers().size());

    // has 1 stp node entry check the bridge identifier and protocol
    assertEquals(CISCO_C870_BRIDGEID, linkNode.getBridgeIdentifier(1));

    // has 50 stp entry che ifIndex must be different then -1
    //
    assertEquals(1, linkNode.getStpInterfaces().get(1).size());

    // no cdp inteface also if the walk return several interfaces
    assertEquals(
        "No cdp interface because no other node is there", 0, linkNode.getCdpInterfaces().size());

    for (OnmsStpInterface stpiface : linkNode.getStpInterfaces().get(1)) {
      assertTrue("should have a valid ifindex", stpiface.getIfIndex().intValue() > 0);
      assertTrue("should have a valid bridgeport", stpiface.getBridgePort().intValue() > 0);
    }

    // This make shure that the ip/mac association is saved
    /*
     * nodelabel:ip:mac:ifindex:ifdescr
     *
     * CISCO_C870:172.20.1.1:001f6cd034e7:12:Vlan1
     * CISCO_C870:172.20.2.1:001f6cd034e7:13:Vlan2
     * CISCO_C870:10.255.255.2:001f6cd034e7:12:Vlan1
     * CISCO_C870:65.41.39.146:00000c03b09e:14:BVI1
     */

    final Set<String> macAddresses = m_linkd.getMacAddressesOnPackage(packageName);
    assertEquals(2, macAddresses.size());
    List<AtInterface> ats = m_linkd.getAtInterfaces(packageName, "001f6cd034e7");
    assertNotNull(ats);

    assertEquals(3, ats.size());
    for (final AtInterface at : ats) {
      if (at.getIpAddress().getHostAddress().equals("172.20.1.1"))
        assertEquals(12, at.getIfIndex().intValue());
      else if (at.getIpAddress().getHostAddress().equals("172.20.2.1"))
        assertEquals(13, at.getIfIndex().intValue());
      else if (at.getIpAddress().getHostAddress().equals("10.255.255.2"))
        assertEquals(12, at.getIfIndex().intValue());
      else
        assertTrue(
            "ip: " + at.getIpAddress().getHostAddress() + "does not match any known ip address",
            false);
    }

    ats = m_linkd.getAtInterfaces(packageName, "00000c03b09e");
    assertEquals(1, ats.size());
    for (AtInterface at : ats) {
      if (at.getIpAddress().getHostAddress().equals("65.41.39.146"))
        assertEquals(14, at.getIfIndex().intValue());
      else
        assertTrue(
            "ip: " + at.getIpAddress().getHostAddress() + "does not match any known ip address",
            false);
    }

    // Now Let's test the database
    // 0 atinterface in database
    assertEquals(4, m_atInterfaceDao.countAll());

    final Criteria criteria = new Criteria(OnmsIpRouteInterface.class);
    criteria.setAliases(Arrays.asList(new Alias[] {new Alias("node", "node", JoinType.LEFT_JOIN)}));
    criteria.addRestriction(new EqRestriction("node.id", ciscorouter.getId()));
    final List<OnmsIpRouteInterface> iproutes = m_ipRouteInterfaceDao.findMatching(criteria);
    // 7 route entry in database
    for (OnmsIpRouteInterface iproute : iproutes) {
      System.out.println(
          iproute.getRouteDest()
              + "/"
              + iproute.getRouteMask()
              + "/"
              + iproute.getRouteNextHop()
              + "/"
              + iproute.getRouteIfIndex());
    }
    assertEquals(7, iproutes.size());

    // 0 entry in vlan
    assertEquals(0, m_vlanDao.findAll().size());

    // 1 entry in stpnode
    assertEquals(1, m_stpNodeDao.countAll());

    OnmsStpNode stpnode = m_stpNodeDao.findByNodeAndVlan(ciscorouter.getId(), 1);
    assertTrue(CISCO_C870_BRIDGEID.equals(stpnode.getBaseBridgeAddress()));
    assertEquals(1, stpnode.getBaseNumPorts().intValue());

    assertEquals(BridgeBaseType.SRT, stpnode.getBaseType());
    assertEquals(StpProtocolSpecification.IEEE8021D, stpnode.getStpProtocolSpecification());

    // 1 entry in stpinterface
    assertEquals(1, m_stpInterfaceDao.findAll().size());
  }
Ejemplo n.º 16
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.º 17
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.º 18
0
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(
            host = DARWIN_10_8_IP,
            port = 161,
            resource = "classpath:linkd/nms7467/" + DARWIN_10_8_IP + "-walk.txt")
      })
  public void testDarwin108Collection() throws Exception {
    m_nodeDao.save(builder.getDarwin108());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseLldpDiscovery(false);
    example1.setUseOspfDiscovery(false);
    example1.setUseIsisDiscovery(false);

    m_linkdConfig.update();

    final OnmsNode mac = m_nodeDao.findByForeignId("linkd", DARWIN_10_8_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(mac.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(mac.getId()));

    // linkd has 1 linkable node
    assertEquals(1, m_linkd.getLinkableNodesOnPackage("example1").size());
    LinkableNode linkNode = m_linkd.getLinkableNodesOnPackage("example1").iterator().next();

    // linkabble node is not null
    assertTrue(linkNode != null);

    // has 1 route (next hop must be valid!) no ip route table
    assertEquals(0, linkNode.getRouteInterfaces().size());
    // has 0 vlan
    assertEquals(0, m_vlanDao.countAll());

    String packageName =
        m_linkdConfig.getFirstPackageMatch(InetAddressUtils.addr(DARWIN_10_8_IP)).getName();

    assertEquals("example1", packageName);

    assertEquals(false, linkNode.isBridgeNode());

    assertEquals(0, linkNode.getBridgeIdentifiers().size());

    // no cdp inteface also if the walk return several interfaces
    assertEquals("cdp not supported", 0, linkNode.getCdpInterfaces().size());

    // This make shure that the ip/mac association is saved
    /*
     * nodelabel:ip:mac:ifindex:ifdescr
     * DARWIN_10_8:172.20.1.28:0026b0ed8fb8:4:en0
     *
     */

    final Set<String> macAddresses = m_linkd.getMacAddressesOnPackage(packageName);
    assertNotNull(macAddresses);
    assertEquals(1, macAddresses.size());

    List<AtInterface> ats = m_linkd.getAtInterfaces(packageName, "0026b0ed8fb8");
    assertNotNull(ats);
    assertEquals("should have saved 1 ip to mac", 1, ats.size());

    for (AtInterface at : ats) {
      if (at.getIpAddress().getHostAddress().equals("172.20.1.28"))
        assertTrue(at.getIfIndex().intValue() == 4);
      else
        assertTrue(
            "ip: " + at.getIpAddress().getHostAddress() + "does not match any known ip address",
            false);
    }

    // Now Let's test the database
    // 0 atinterface in database
    assertEquals(0, m_atInterfaceDao.findAll().size());

    final Criteria criteria = new Criteria(OnmsIpRouteInterface.class);
    criteria.setAliases(Arrays.asList(new Alias[] {new Alias("node", "node", JoinType.LEFT_JOIN)}));
    criteria.addRestriction(new EqRestriction("node.id", mac.getId()));
    final List<OnmsIpRouteInterface> iproutes = m_ipRouteInterfaceDao.findMatching(criteria);
    // 4 route entry in database
    for (OnmsIpRouteInterface iproute : iproutes) {
      System.out.println(
          iproute.getRouteDest()
              + "/"
              + iproute.getRouteMask()
              + "/"
              + iproute.getRouteNextHop()
              + "/"
              + iproute.getRouteIfIndex());
    }
    assertEquals(20, iproutes.size());

    // 0 entry in vlan
    assertEquals(0, m_vlanDao.findAll().size());

    // 0 entry in stpnode
    assertEquals(0, m_stpNodeDao.countAll());

    // 0 entry in stpinterface
    assertEquals(0, m_stpInterfaceDao.findAll().size());
  }
Ejemplo n.º 19
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());
  }
Ejemplo n.º 20
0
  /*
       * fixed a fake link found using cdp:
       * caused by duplicated ip address
  s     * r-uk-nott-newt-103:Fa0:(1)<------>(4):Fa3:r-ro-suce-pict-001
       */
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = RNewt103_IP, port = 161, resource = RNewt103_SNMP_RESOURCE)
      })
  public void testCdpFakeLinkRoUk() throws Exception {

    m_nodeDao.save(builder.getRPict001());
    m_nodeDao.save(builder.getRNewt103());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseIsisDiscovery(false);
    example1.setUseIpRouteDiscovery(false);
    example1.setUseOspfDiscovery(false);
    example1.setUseLldpDiscovery(false);
    example1.setUseCdpDiscovery(true);
    example1.setUseBridgeDiscovery(false);

    example1.setEnableVlanDiscovery(false);

    example1.setSaveStpNodeTable(false);
    example1.setSaveStpInterfaceTable(false);
    example1.setSaveRouteTable(false);

    final OnmsNode routerRo = m_nodeDao.findByForeignId("linkd", RPict001_NAME);
    final OnmsNode routerUk = m_nodeDao.findByForeignId("linkd", RNewt103_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(routerRo.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(routerUk.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(routerRo.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(routerUk.getId()));

    assertEquals(0, m_dataLinkInterfaceDao.countAll());

    assertTrue(m_linkd.runSingleLinkDiscovery("example1"));

    assertEquals(0, m_dataLinkInterfaceDao.countAll());
  }
Ejemplo n.º 21
0
  /*
   *
   *  Get only ospf links.
   */
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(
            host = MUMBAI_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + MUMBAI_NAME + "_" + MUMBAI_IP + ".txt"),
        @JUnitSnmpAgent(
            host = CHENNAI_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + CHENNAI_NAME + "_" + CHENNAI_IP + ".txt"),
        @JUnitSnmpAgent(
            host = DELHI_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + DELHI_NAME + "_" + DELHI_IP + ".txt"),
        @JUnitSnmpAgent(
            host = BANGALORE_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + BANGALORE_NAME + "_" + BANGALORE_IP + ".txt"),
        @JUnitSnmpAgent(
            host = BAGMANE_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + BAGMANE_NAME + "_" + BAGMANE_IP + ".txt"),
        @JUnitSnmpAgent(
            host = MYSORE_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + MYSORE_NAME + "_" + MYSORE_IP + ".txt"),
        @JUnitSnmpAgent(
            host = SPACE_EX_SW1_IP,
            port = 161,
            resource =
                "classpath:linkd/nms10205/" + SPACE_EX_SW1_NAME + "_" + SPACE_EX_SW1_IP + ".txt"),
        @JUnitSnmpAgent(
            host = SPACE_EX_SW2_IP,
            port = 161,
            resource =
                "classpath:linkd/nms10205/" + SPACE_EX_SW2_NAME + "_" + SPACE_EX_SW2_IP + ".txt"),
        @JUnitSnmpAgent(
            host = J6350_41_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + J6350_41_NAME + "_" + J6350_41_IP + ".txt"),
        @JUnitSnmpAgent(
            host = J6350_42_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + "J6350-42_" + J6350_42_IP + ".txt"),
        @JUnitSnmpAgent(
            host = SRX_100_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + "SRX-100_" + SRX_100_IP + ".txt"),
        @JUnitSnmpAgent(
            host = SSG550_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + SSG550_NAME + "_" + SSG550_IP + ".txt")
      })
  public void testNetwork10205OspfLinks() throws Exception {
    m_nodeDao.save(getMumbai());
    m_nodeDao.save(getChennai());
    m_nodeDao.save(getDelhi());
    m_nodeDao.save(getBangalore());
    m_nodeDao.save(getBagmane());
    m_nodeDao.save(getMysore());
    m_nodeDao.save(getSpaceExSw1());
    m_nodeDao.save(getSpaceExSw2());
    m_nodeDao.save(getJ635041());
    m_nodeDao.save(getJ635042());
    m_nodeDao.save(getSRX100());
    m_nodeDao.save(getSGG550());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseLldpDiscovery(false);
    example1.setUseCdpDiscovery(false);
    example1.setUseBridgeDiscovery(false);
    example1.setUseIpRouteDiscovery(false);

    example1.setSaveRouteTable(false);
    example1.setSaveStpInterfaceTable(false);
    example1.setSaveStpNodeTable(false);

    final OnmsNode mumbai = m_nodeDao.findByForeignId("linkd", MUMBAI_NAME);
    final OnmsNode chennai = m_nodeDao.findByForeignId("linkd", CHENNAI_NAME);
    final OnmsNode delhi = m_nodeDao.findByForeignId("linkd", DELHI_NAME);
    final OnmsNode bangalore = m_nodeDao.findByForeignId("linkd", BANGALORE_NAME);
    final OnmsNode bagmane = m_nodeDao.findByForeignId("linkd", BAGMANE_NAME);
    final OnmsNode mysore = m_nodeDao.findByForeignId("linkd", MYSORE_NAME);
    final OnmsNode spaceexsw1 = m_nodeDao.findByForeignId("linkd", SPACE_EX_SW1_NAME);
    final OnmsNode spaceexsw2 = m_nodeDao.findByForeignId("linkd", SPACE_EX_SW2_NAME);
    final OnmsNode j635041 = m_nodeDao.findByForeignId("linkd", J6350_41_NAME);
    final OnmsNode j635042 = m_nodeDao.findByForeignId("linkd", J6350_42_NAME);
    final OnmsNode srx100 = m_nodeDao.findByForeignId("linkd", SRX_100_NAME);
    final OnmsNode ssg550 = m_nodeDao.findByForeignId("linkd", SSG550_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(chennai.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(mumbai.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(delhi.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(bangalore.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(bagmane.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(mysore.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(spaceexsw1.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(spaceexsw2.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(j635041.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(j635042.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(srx100.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(ssg550.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(mumbai.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(chennai.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(delhi.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(bangalore.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(bagmane.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(mysore.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw1.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw2.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(j635041.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(j635042.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(srx100.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(ssg550.getId()));

    assertEquals(0, m_dataLinkInterfaceDao.countAll());

    assertTrue(m_linkd.runSingleLinkDiscovery("example1"));

    final List<DataLinkInterface> links = m_dataLinkInterfaceDao.findAll();

    assertEquals(9, links.size());

    int start = getStartPoint(links);
    for (final DataLinkInterface datalinkinterface : links) {
      int id = datalinkinterface.getId().intValue();
      if (start == id) {
        checkLink(chennai, mumbai, 528, 520, datalinkinterface);
      } else if (start + 1 == id) {
        checkLink(delhi, mumbai, 28503, 519, datalinkinterface);
      } else if (start + 2 == id) {
        checkLink(bangalore, mumbai, 2401, 507, datalinkinterface);
      } else if (start + 3 == id) {
        checkLink(bagmane, mumbai, 534, 977, datalinkinterface);
      } else if (start + 4 == id) {
        checkLink(mysore, mumbai, 508, 978, datalinkinterface);
      } else if (start + 5 == id) {
        checkLink(mysore, chennai, 505, 517, datalinkinterface);
      } else if (start + 6 == id) {
        checkLink(bangalore, delhi, 2397, 3674, datalinkinterface);
      } else if (start + 7 == id) {
        checkLink(bagmane, bangalore, 1732, 2396, datalinkinterface);
      } else if (start + 8 == id) {
        checkLink(mysore, bagmane, 520, 654, datalinkinterface);
      } else {
        checkLink(mumbai, mumbai, -1, -1, datalinkinterface);
      }
    }
  }
Ejemplo n.º 22
0
  /*
   *  The
   *  MUMBAI:port ge 0/1/3:ip 192.168.5.5   ------> CHENNAI:port ge 4/0/2: ip 192.168.5.6
   *  MUMBAI:port ge 0/1/2:ip 192.168.5.9   ------> DELHI:port ge 1/0/2: ip 192.168.5.10
   *  MUMBAI:port ge 0/0/1:ip 192.168.5.13   ------> BANGALORE:port ge 0/0/0: ip 192.168.5.14
   *  DELHI:port ge 1/0/1:ip 192.168.1.5     ------> BANGALORE:port ge 0/0/1: ip 192.168.1.6
   *  DELHI:port ge 1/1/6:ip 172.16.7.1     ------> Space-EX-SW1: port 0/0/6: ip 172.16.7.1 ???? same ip address
   *  CHENNAI:port ge 4/0/3:ip 192.168.1.1  ------> DELHI: port ge 1/1/0: ip 192.168.1.2
   *
   *  a lot of duplicated ip this is a clear proof that linkd is not able to
   *  gather topology of this lab using the useBridgeTopology and ip routes.
   */
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(
            host = MUMBAI_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + MUMBAI_NAME + "_" + MUMBAI_IP + ".txt"),
        @JUnitSnmpAgent(
            host = CHENNAI_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + CHENNAI_NAME + "_" + CHENNAI_IP + ".txt"),
        @JUnitSnmpAgent(
            host = DELHI_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + DELHI_NAME + "_" + DELHI_IP + ".txt"),
        @JUnitSnmpAgent(
            host = BANGALORE_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + BANGALORE_NAME + "_" + BANGALORE_IP + ".txt"),
        @JUnitSnmpAgent(
            host = BAGMANE_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + BAGMANE_NAME + "_" + BAGMANE_IP + ".txt"),
        @JUnitSnmpAgent(
            host = MYSORE_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + MYSORE_NAME + "_" + MYSORE_IP + ".txt"),
        @JUnitSnmpAgent(
            host = SPACE_EX_SW1_IP,
            port = 161,
            resource =
                "classpath:linkd/nms10205/" + SPACE_EX_SW1_NAME + "_" + SPACE_EX_SW1_IP + ".txt"),
        @JUnitSnmpAgent(
            host = SPACE_EX_SW2_IP,
            port = 161,
            resource =
                "classpath:linkd/nms10205/" + SPACE_EX_SW2_NAME + "_" + SPACE_EX_SW2_IP + ".txt"),
        @JUnitSnmpAgent(
            host = J6350_41_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + J6350_41_NAME + "_" + J6350_41_IP + ".txt"),
        @JUnitSnmpAgent(
            host = J6350_42_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + "J6350-42_" + J6350_42_IP + ".txt"),
        @JUnitSnmpAgent(
            host = SRX_100_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + "SRX-100_" + SRX_100_IP + ".txt"),
        @JUnitSnmpAgent(
            host = SSG550_IP,
            port = 161,
            resource = "classpath:linkd/nms10205/" + SSG550_NAME + "_" + SSG550_IP + ".txt")
      })
  public void testNetwork10205Links() throws Exception {
    m_nodeDao.save(getMumbai());
    m_nodeDao.save(getChennai());
    m_nodeDao.save(getDelhi());
    m_nodeDao.save(getBangalore());
    m_nodeDao.save(getBagmane());
    m_nodeDao.save(getMysore());
    m_nodeDao.save(getSpaceExSw1());
    m_nodeDao.save(getSpaceExSw2());
    m_nodeDao.save(getJ635041());
    m_nodeDao.save(getJ635042());
    m_nodeDao.save(getSRX100());
    m_nodeDao.save(getSGG550());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    assertEquals(false, example1.hasForceIpRouteDiscoveryOnEthernet());
    example1.setForceIpRouteDiscoveryOnEthernet(true);
    example1.setUseCdpDiscovery(false);

    final OnmsNode mumbai = m_nodeDao.findByForeignId("linkd", MUMBAI_NAME);
    final OnmsNode chennai = m_nodeDao.findByForeignId("linkd", CHENNAI_NAME);
    final OnmsNode delhi = m_nodeDao.findByForeignId("linkd", DELHI_NAME);
    final OnmsNode bangalore = m_nodeDao.findByForeignId("linkd", BANGALORE_NAME);
    final OnmsNode bagmane = m_nodeDao.findByForeignId("linkd", BAGMANE_NAME);
    final OnmsNode mysore = m_nodeDao.findByForeignId("linkd", MYSORE_NAME);
    final OnmsNode spaceexsw1 = m_nodeDao.findByForeignId("linkd", SPACE_EX_SW1_NAME);
    final OnmsNode spaceexsw2 = m_nodeDao.findByForeignId("linkd", SPACE_EX_SW2_NAME);
    final OnmsNode j635041 = m_nodeDao.findByForeignId("linkd", J6350_41_NAME);
    final OnmsNode j635042 = m_nodeDao.findByForeignId("linkd", J6350_42_NAME);
    final OnmsNode srx100 = m_nodeDao.findByForeignId("linkd", SRX_100_NAME);
    final OnmsNode ssg550 = m_nodeDao.findByForeignId("linkd", SSG550_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(chennai.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(mumbai.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(delhi.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(bangalore.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(bagmane.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(mysore.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(spaceexsw1.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(spaceexsw2.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(j635041.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(j635042.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(srx100.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(ssg550.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(mumbai.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(chennai.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(delhi.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(bangalore.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(bagmane.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(mysore.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw1.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw2.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(j635041.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(j635042.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(srx100.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(ssg550.getId()));

    assertEquals(0, m_dataLinkInterfaceDao.countAll());

    assertTrue(m_linkd.runSingleLinkDiscovery("example1"));

    final List<DataLinkInterface> links = m_dataLinkInterfaceDao.findAll();

    assertEquals(9, links.size());

    // Linkd is able to find partially the topology using the next hop router
    // among the core nodes:
    // mumbai, chennai, delhi, mysore,bangalore and bagmane
    // the link between chennai and delhi is lost
    // the link between chennai and bagmane is lost
    // the link between bagmane and delhi is lost
    // I checked the walks and no route info
    // is there for discovering the link.
    // I have to guess that linkd is working as expected

    // The bridge and RSTP topology information are
    // unusuful, the devices supporting RSTP
    // have themselves as designated bridge.

    // Other links are lost...
    // no routing entry and no bridge
    // forwarding

    int start = getStartPoint(links);
    for (final DataLinkInterface datalinkinterface : links) {
      int id = datalinkinterface.getId().intValue();
      if (start == id) {
        checkLink(delhi, mumbai, 28503, 519, datalinkinterface);
      } else if (start + 1 == id) {
        checkLink(bangalore, mumbai, 2401, 507, datalinkinterface);
      } else if (start + 2 == id) {
        checkLink(bagmane, mumbai, 534, 977, datalinkinterface);
      } else if (start + 3 == id) {
        checkLink(mysore, mumbai, 508, 978, datalinkinterface);
      } else if (start + 4 == id) {
        checkLink(chennai, mumbai, 528, 520, datalinkinterface);
      } else if (start + 5 == id) {
        checkLink(mysore, chennai, 505, 517, datalinkinterface);
      } else if (start + 6 == id) {
        checkLink(bangalore, delhi, 2397, 3674, datalinkinterface);
      } else if (start + 7 == id) {
        checkLink(bagmane, bangalore, 1732, 2396, datalinkinterface);
      } else if (start + 8 == id) {
        checkLink(mysore, bagmane, 520, 654, datalinkinterface);
      } else {
        checkLink(mumbai, mumbai, -1, -1, datalinkinterface);
      }
    }
  }
Ejemplo n.º 23
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());
  }
Ejemplo n.º 24
0
  /*
   *
   *     nodelabel           |  snmpifname  | ifindex |       parent       |  parentif  | parentifindex
   *     --------------------+--------------+---------+--------------------+------------+---------------
   *      r-de-pots-amka-001 | Fa6/0/0      |     164 | r-de-juet-luck-001 | ge-0/0/0.0 |           510
   *      r-de-juet-luck-001 | ge-0/0/2.100 |     549 | s-de-juet-luck-001 | Fa0/1      |         10001
   *      r-de-juet-luck-001 | ge-0/0/2.950 |     550 | s-de-juet-luck-001 | Fa0/1      |         10001     *
   *
   * The links are mostly from the bridge forwarding table protocol in fact the
   * ge-0/0/2.100 and ge-0/0/2.950 are logical interface for vlan 100 and
   * vlan 950 on juniper router. with the same mac address 54e032ef3102
   * So both vlan 100 and vlan 950 will address the same link
   * No way to get layer 2 link because no STP is enabled on Juniper device
   *
   */
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(host = Rluck001_IP, port = 161, resource = Rluck001_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = Sluck001_IP, port = 161, resource = Sluck001_SNMP_RESOURCE)
      })
  public void testNetworkLinksCiscoJuniperLldp() throws Exception {

    m_nodeDao.save(builder.getRluck001());
    m_nodeDao.save(builder.getSluck001());
    m_nodeDao.flush();

    Package example1 = m_linkdConfig.getPackage("example1");
    example1.setUseIsisDiscovery(false);
    example1.setUseIpRouteDiscovery(false);
    example1.setUseOspfDiscovery(false);
    example1.setUseLldpDiscovery(true);
    example1.setUseCdpDiscovery(false);
    example1.setUseBridgeDiscovery(false);

    example1.setEnableVlanDiscovery(false);

    example1.setSaveStpNodeTable(false);
    example1.setSaveStpInterfaceTable(false);
    example1.setSaveRouteTable(false);

    final OnmsNode routerJuniper = m_nodeDao.findByForeignId("linkd", Rluck001_NAME);
    final OnmsNode switchCisco = m_nodeDao.findByForeignId("linkd", Sluck001_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(routerJuniper.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(switchCisco.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(routerJuniper.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(switchCisco.getId()));

    for (LinkableNode linkableNode : m_linkd.getLinkableNodesOnPackage("example1")) {
      assertNotNull(linkableNode.getLldpChassisId());
    }

    assertTrue(m_linkd.runSingleLinkDiscovery("example1"));
    assertEquals(0, m_dataLinkInterfaceDao.countAll());
  }
Ejemplo n.º 25
0
  /*
   * Penrose: baseBridgeAddress = 80711f8fafd0
   * Penrose: stpDesignatedRoot = 001f12373dc0
   * Penrose: stpport/designatedbridge/designatedport 62/8000 001f12373dc0/8201
   *          -----To Riovista - Root Spanning tree: ifindex 515 ---ge-1/2/1
   * Penrose: stpport/designatedbridge/designatedport 483/8000 0022830957d0/81e3
   *          -----this is a backbone port to a higher bridge: ifindex 2693 -- ae0
   *          ---- aggregated port almost sure the link to Delaware
   *
   * Delaware: baseBridgeAddress = 0022830957d0
   * Delaware: stpDesignatedRoot = 001f12373dc0
   * Delaware: stpport/designatedbridge/designatedport 21/8000 001f12373dc0/822f
   *          -----To Riovista - Root Spanning tree: ifindex 540 -- ge-0/2/0
   * Delaware: stpport/designatedbridge/designatedport 483/8000 0022830957d0/81e3
   *          -----this is a backbone port to a lower bridge: ifindex 658 ---ae0
   *          -----aggregated port almost sure the link to Penrose
   *
   * Riovista: baseBridgeAddress = 001f12373dc0
   * Riovista: stpDesignatedRoot = 001f12373dc0
   * Riovista: stpport/designatedbridge/designatedport 513/8000 001f12373dc0/8201
   *          -----To Penrose ifindex 584 ---ge-0/0/0.0
   * Riovista: stpport/designatedbridge/designatedport 559/8000001f12373dc0/822f
   *          -----To Delaware ifindex 503 ---ge-0/0/46.0
   *
   *
   * Phoenix: baseBridgeAddress = 80711fc414d0
   * Phoenix: Spanning Tree is disabled
   *
   * Austin: baseBridgeAddress = 80711fc413d0
   * Austin: Spanning Tree is disabled
   *
   * Sanjose: baseBridgeAddress = 002283d857d0
   * Sanjose: Spanning Tree is disabled
   *
   * There are two links found between Penrose and Delaware,
   * one on ae0 using stp and another over xe-1/0/0.0 using the ip route next hop strategy
   *
   * Also the link between Austin and Delaware is not found because
   * no route entry is found so no way to find it.
   * This prove how weak is the way in which is set up linkd.
   * This test passes because i've verified that this is what the linkd can discover using it's values
   *
   * root@sanjose-mx240# run show lldp neighbors
   * Local Interface Chassis Id        Port info     System Name
   * ge-1/0/1        80:71:1f:c4:13:c0  ge-1/0/3     Austin
   * ge-1/0/0        80:71:1f:c4:14:c0  ge-1/0/3     phoenix-mx80
   *
   * root@phoenix-mx80# run show lldp neighbors
   * Local Interface Chassis Id        Port info     System Name
   * ge-1/0/3        00:22:83:d8:57:c0  ge-1/0/0     sanjose-mx240
   * xe-0/0/1        80:71:1f:8f:af:c0  xe-1/0/1     penrose-mx480
   * xe-0/0/0        80:71:1f:c4:13:c0  <ToPHX-xe000> Austin
   * root@Austin# run show lldp neighbors
   * Local Interface Chassis Id        Port info     System Name
   * xe-0/0/1        00:22:83:09:57:c0  xe-1/0/1     delaware
   * ge-1/0/3        00:22:83:d8:57:c0  ge-1/0/1     sanjose-mx240
   * xe-0/0/0        80:71:1f:c4:14:c0  <ToAUS-xe000> phoenix-mx80
   *
   * root@penrose-mx480# run show lldp neighbors
   * Local Interface Chassis Id        Port info     System Name
   * ge-1/2/1        00:1f:12:37:3d:c0  ge-0/0/0.0   Riovista-ce
   * ge-1/3/1        00:22:83:09:57:c0  ge-0/0/6     delaware
   * xe-1/0/0        00:22:83:09:57:c0  <To_Penrose> delaware
   * xe-1/0/1        80:71:1f:c4:14:c0  xe-0/0/1     phoenix-mx80
   *
   * root@delaware# run show lldp neighbors
   * Local Interface Chassis Id        Port info     System Name
   * ge-0/2/0        00:1f:12:37:3d:c0  ge-0/0/46.0  Riovista-ce
   * xe-1/0/0        80:71:1f:8f:af:c0  <To_Delaware> penrose-mx480
   * ge-0/0/6        80:71:1f:8f:af:c0  ge-1/3/1     penrose-mx480
   * xe-1/0/1        80:71:1f:c4:13:c0  xe-0/0/1     Austin
   *
   * root@Riovista-ce# run show lldp neighbors
   * Local Interface    Parent Interface    Chassis Id          Port info          System Name
   * ge-0/0/46.0        -                   00:22:83:09:57:c0   ge-0/2/0           delaware
   * ge-0/0/0.0         -                   80:71:1f:8f:af:c0   ge-1/2/1           penrose-mx480
   *
   */
  @Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(host = PENROSE_IP, port = 161, resource = PENROSE_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = DELAWARE_IP, port = 161, resource = DELAWARE_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = PHOENIX_IP, port = 161, resource = PHOENIX_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = AUSTIN_IP, port = 161, resource = AUSTIN_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = SANJOSE_IP, port = 161, resource = SANJOSE_SNMP_RESOURCE),
        @JUnitSnmpAgent(host = RIOVISTA_IP, port = 161, resource = RIOVISTA_SNMP_RESOURCE)
      })
  public void testNetwork1055Links() throws Exception {
    m_nodeDao.save(builder.getPenrose());
    m_nodeDao.save(builder.getDelaware());
    m_nodeDao.save(builder.getPhoenix());
    m_nodeDao.save(builder.getAustin());
    m_nodeDao.save(builder.getSanjose());
    m_nodeDao.save(builder.getRiovista());
    m_nodeDao.flush();

    HibernateEventWriter queryManager = (HibernateEventWriter) m_linkd.getQueryManager();
    /*
     *         DELAWARE_IF_IFNAME_MAP.put(517, "ge-0/0/1");
     *         DELAWARE_IF_IFALIAS_MAP.put(517, "test");
     */
    assertEquals(
        517, queryManager.getFromSysnameIfAlias(DELAWARE_NAME, "test").getIfIndex().intValue());
    assertEquals(
        517, queryManager.getFromSysnameIfName(DELAWARE_NAME, "ge-0/0/1").getIfIndex().intValue());

    /*
     * DELAWARE_IF_MAC_MAP.put(585, "0022830951f5");
     */
    assertEquals(
        585,
        queryManager
            .getFromSysnameMacAddress(DELAWARE_NAME, "0022830951f5")
            .getIfIndex()
            .intValue());
    /*
     * DELAWARE_IP_IF_MAP.put(InetAddressUtils.addr("10.155.69.17"), 13);
     */
    assertEquals(
        13,
        queryManager
            .getFromSysnameIpAddress(DELAWARE_NAME, InetAddressUtils.addr("10.155.69.17"))
            .getIfIndex()
            .intValue());

    /*
     * DELAWARE_IF_IFALIAS_MAP.put(574, "<To_Penrose>");
     */
    assertEquals(
        574,
        queryManager.getFromSysnameIfAlias(DELAWARE_NAME, "<To_Penrose>").getIfIndex().intValue());

    Package example1 = m_linkdConfig.getPackage("example1");
    assertEquals(false, example1.hasForceIpRouteDiscoveryOnEthernet());
    example1.setForceIpRouteDiscoveryOnEthernet(true);

    final OnmsNode penrose = m_nodeDao.findByForeignId("linkd", PENROSE_NAME);
    final OnmsNode delaware = m_nodeDao.findByForeignId("linkd", DELAWARE_NAME);
    final OnmsNode phoenix = m_nodeDao.findByForeignId("linkd", PHOENIX_NAME);
    final OnmsNode austin = m_nodeDao.findByForeignId("linkd", AUSTIN_NAME);
    final OnmsNode sanjose = m_nodeDao.findByForeignId("linkd", SANJOSE_NAME);
    final OnmsNode riovista = m_nodeDao.findByForeignId("linkd", RIOVISTA_NAME);

    assertTrue(m_linkd.scheduleNodeCollection(penrose.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(delaware.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(phoenix.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(austin.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(sanjose.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(riovista.getId()));

    assertTrue(m_linkd.runSingleSnmpCollection(penrose.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(delaware.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(phoenix.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(austin.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(sanjose.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(riovista.getId()));

    assertEquals(0, m_dataLinkInterfaceDao.countAll());

    assertTrue(m_linkd.runSingleLinkDiscovery("example1"));

    assertEquals(22, m_dataLinkInterfaceDao.countAll());
    final List<DataLinkInterface> links = m_dataLinkInterfaceDao.findAll();

    final int start = getStartPoint(links);
    for (final DataLinkInterface datalinkinterface : links) {
      Integer linkid = datalinkinterface.getId();

      if (linkid == start) {
        checkLink(penrose, phoenix, 644, 564, datalinkinterface);
        assertEquals(DiscoveryProtocol.iproute, datalinkinterface.getProtocol());
      } else if (linkid == start + 1) {
        checkLink(penrose, delaware, 535, 598, datalinkinterface);
        assertEquals(DiscoveryProtocol.iproute, datalinkinterface.getProtocol());
      } else if (linkid == start + 2) {
        checkLink(phoenix, austin, 565, 554, datalinkinterface);
        assertEquals(DiscoveryProtocol.iproute, datalinkinterface.getProtocol());
      } else if (linkid == start + 3) {
        checkLink(sanjose, phoenix, 564, 566, datalinkinterface);
        assertEquals(DiscoveryProtocol.iproute, datalinkinterface.getProtocol());
      } else if (linkid == start + 4) {
        checkLink(sanjose, austin, 8562, 586, datalinkinterface);
        assertEquals(DiscoveryProtocol.iproute, datalinkinterface.getProtocol());
      } else if (linkid == start + 5) {
        checkLink(delaware, penrose, 598, 535, datalinkinterface);
        assertEquals(DiscoveryProtocol.ospf, datalinkinterface.getProtocol());
      } else if (linkid == start + 6) {
        checkLink(phoenix, penrose, 564, 644, datalinkinterface);
        assertEquals(DiscoveryProtocol.ospf, datalinkinterface.getProtocol());
      } else if (linkid == start + 7) {
        checkLink(austin, phoenix, 554, 565, datalinkinterface);
        assertEquals(DiscoveryProtocol.ospf, datalinkinterface.getProtocol());
      } else if (linkid == start + 8) {
        checkLink(sanjose, phoenix, 564, 566, datalinkinterface);
        assertEquals(DiscoveryProtocol.ospf, datalinkinterface.getProtocol());
      } else if (linkid == start + 9) {
        checkLink(sanjose, austin, 8562, 586, datalinkinterface);
        assertEquals(DiscoveryProtocol.ospf, datalinkinterface.getProtocol());
      } else if (linkid == start + 10) {
        checkLink(penrose, riovista, 515, 584, datalinkinterface);
        assertEquals(DiscoveryProtocol.bridge, datalinkinterface.getProtocol());
      } else if (linkid == start + 11) {
        checkLink(penrose, delaware, 2693, 658, datalinkinterface);
        assertEquals(DiscoveryProtocol.bridge, datalinkinterface.getProtocol());
      } else if (linkid == start + 12) {
        checkLink(delaware, riovista, 540, 503, datalinkinterface);
        assertEquals(DiscoveryProtocol.bridge, datalinkinterface.getProtocol());
      } else if (linkid == start + 13) {
        // penrose xe-1/0/0 -> delaware xe-1/0/0 --lldp
        checkLink(delaware, penrose, 574, 510, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else if (linkid == start + 14) {
        // penrose xe-1/0/1 -> phoenix xe-0/0/1  --lldp
        checkLink(phoenix, penrose, 509, 511, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else if (linkid == start + 15) {
        // penrose ge-1/3/1 -> delaware ge-0/0/6 --lldp
        checkLink(delaware, penrose, 522, 525, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else if (linkid == start + 16) {
        // penrose ge-1/2/1 -> riovista ge-0/0/0.0  --lldp
        // this link is also discovered using the bridge strategy
        checkLink(riovista, penrose, 584, 515, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else if (linkid == start + 17) {
        // delaware xe-1/0/1 -> austin xe-0/0/1  --lldp
        checkLink(austin, delaware, 509, 575, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else if (linkid == start + 18) {
        // delaware ge-0/2/0 -> riovista ge-0/0/46.0  --lldp
        // this link is also discovered using the bridge strategy
        checkLink(riovista, delaware, 503, 540, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else if (linkid == start + 19) {
        // phoenix ge-1/0/3 -> sanjose ge-1/0/0  --lldp
        checkLink(sanjose, phoenix, 516, 515, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else if (linkid == start + 20) {
        // phoenix ge-0/2/0 -> austin ge-0/0/46.0  --lldp
        checkLink(austin, phoenix, 508, 508, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else if (linkid == start + 21) {
        // austin ge-1/0/3 -> sanjose ge-1/0/1  --lldp
        checkLink(sanjose, austin, 517, 515, datalinkinterface);
        assertEquals(DiscoveryProtocol.lldp, datalinkinterface.getProtocol());
      } else {
        checkLink(penrose, penrose, -1, -1, datalinkinterface);
      }
    }
  }