예제 #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);
    }
  }
예제 #2
0
  public boolean scheduleNodeCollection(int nodeid) {

    LinkableNode node = null;
    // database changed need reload packageiplist
    m_linkdConfig.updatePackageIpListMap();

    // First of all get Linkable Node
    LogUtils.debugf(this, "scheduleNodeCollection: Loading node %d from database", nodeid);
    try {
      node = m_queryMgr.getSnmpNode(nodeid);
      if (node == null) {
        LogUtils.warnf(
            this,
            "scheduleNodeCollection: Failed to get linkable node from database with ID %d. Exiting",
            nodeid);
        return false;
      }
    } catch (final SQLException sqlE) {
      LogUtils.errorf(
          this,
          sqlE,
          "scheduleNodeCollection: SQL Exception while syncing node object with ID %d with database information.",
          nodeid);
      return false;
    }
    synchronized (m_nodes) {
      LogUtils.debugf(this, "adding node %s to the collection", node);
      m_nodes.add(node);
    }

    scheduleCollectionForNode(node);
    return true;
  }
예제 #3
0
  /**
   * {@inheritDoc}
   *
   * @param nodeid
   */
  public List<SnmpCollection> getSnmpCollections(
      int nodeid, final InetAddress ipaddr, final String sysoid) {
    List<SnmpCollection> snmpcolls = new ArrayList<SnmpCollection>();

    for (final String pkgName : m_linkdConfig.getAllPackageMatches(ipaddr)) {
      snmpcolls.add(getSnmpCollection(nodeid, ipaddr, sysoid, pkgName));
    }

    return snmpcolls;
  }
예제 #4
0
 /**
  * {@inheritDoc}
  *
  * @param nodeid
  */
 public SnmpCollection getSnmpCollection(
     final int nodeid, final InetAddress ipaddr, final String sysoid, final String pkgName) {
   final Package pkg = m_linkdConfig.getPackage(pkgName);
   if (pkg != null) {
     final SnmpCollection collection = createCollection(nodeid, ipaddr);
     populateSnmpCollection(collection, pkg, sysoid);
     return collection;
   }
   return null;
 }
예제 #5
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);
    }
  }
예제 #6
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;
  }
예제 #7
0
  /**
   * Update database when an interface is deleted
   *
   * @param nodeid the nodeid for the node
   * @param ipAddr the ip address of the interface
   * @param ifIndex the ifIndex of the interface
   */
  void deleteInterface(int nodeid, String ipAddr, int ifIndex) {

    LogUtils.debugf(
        this,
        "deleteInterface: marking table entries as deleted for node %d with IP address %s and ifIndex %s",
        nodeid,
        ipAddr,
        (ifIndex > -1 ? "" + ifIndex : "N/A"));

    try {
      m_queryMgr.updateForInterface(nodeid, ipAddr, ifIndex, QueryManager.ACTION_DELETE);
    } catch (SQLException sqlE) {
      LogUtils.errorf(this, sqlE, "deleteInterface: SQL Exception while updating database.");
    }

    // database changed need reload packageiplist
    m_linkdConfig.updatePackageIpListMap();
  }
예제 #8
0
  void deleteNode(int nodeid) {
    LogUtils.debugf(this, "deleteNode: deleting LinkableNode for node %s", nodeid);

    try {
      m_queryMgr.update(nodeid, QueryManager.ACTION_DELETE);
    } catch (SQLException sqlE) {
      LogUtils.errorf(
          this,
          sqlE,
          "deleteNode: SQL Exception while syncing node object with database information.");
    }

    LinkableNode node = removeNode(nodeid);

    if (node == null) {
      LogUtils.warnf(this, "deleteNode: node not found: %d", nodeid);
    } else {
      Collection<SnmpCollection> collections =
          getSnmpCollections(nodeid, node.getSnmpPrimaryIpAddr(), node.getSysoid());
      LogUtils.debugf(
          this,
          "deleteNode: fetched SnmpCollections from scratch, iterating over %d objects to wake them up",
          collections.size());
      for (SnmpCollection collection : collections) {
        ReadyRunnable rr = getReadyRunnable(collection);

        if (rr == null) {
          LogUtils.warnf(this, "deleteNode: found null ReadyRunnable");
          return;
        } else {
          rr.unschedule();
        }
      }
    }

    // database changed need reload packageiplist
    m_linkdConfig.updatePackageIpListMap();
  }
  @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);
    }
  }
예제 #10
0
 /**
  * isInterfaceInPackageRange
  *
  * @param ipaddr a {@link java.lang.String} object.
  * @param pkg a {@link java.lang.String} object.
  * @return a boolean.
  */
 public boolean isInterfaceInPackageRange(InetAddress ipaddr, String pkg) {
   return m_linkdConfig.isInterfaceInPackageRange(ipaddr, m_linkdConfig.getPackage(pkg));
 }
예제 #11
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);
  }
예제 #12
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);
      }
    }
  }
예제 #13
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);
      }
    }
  }