示例#1
0
 /**
  * getSnmpInterfaceWithIfIndex
  *
  * @param ifIndex a int.
  * @return a {@link org.opennms.netmgt.model.OnmsSnmpInterface} object.
  */
 @Transient
 public OnmsSnmpInterface getSnmpInterfaceWithIfIndex(int ifIndex) {
   for (OnmsSnmpInterface dbSnmpIface : getSnmpInterfaces()) {
     if (dbSnmpIface.getIfIndex().equals(ifIndex)) {
       return dbSnmpIface;
     }
   }
   return null;
 }
 @Override
 public void setParentInterfaces(
     OnmsSnmpInterface sourceInterface, OnmsSnmpInterface targetInterface) {
   if (targetInterface != null && targetInterface.getIfOperStatus() != null) {
     if (sourceInterface != null) {
       if (sourceInterface.getIfOperStatus() == 1 && targetInterface.getIfOperStatus() == 1) {
         getLinkStateMachine().setState(getLinkStateMachine().getUpState());
       } else {
         getLinkStateMachine().setState(getLinkStateMachine().getDownState());
       }
     }
   }
 }
示例#3
0
  /** {@inheritDoc} */
  @Override
  public void visit(EntityVisitor visitor) {
    visitor.visitNode(this);

    for (OnmsIpInterface iface : getIpInterfaces()) {
      iface.visit(visitor);
    }

    for (OnmsSnmpInterface snmpIface : getSnmpInterfaces()) {
      snmpIface.visit(visitor);
    }

    visitor.visitNodeComplete(this);
  }
示例#4
0
  /**
   * mergeSnmpInterfaces
   *
   * @param scannedNode a {@link org.opennms.netmgt.model.OnmsNode} object.
   * @param deleteMissing a boolean.
   */
  public void mergeSnmpInterfaces(OnmsNode scannedNode, boolean deleteMissing) {

    // we need to skip this step if there is an indication that snmp data collection failed
    if (scannedNode.getSnmpInterfaces().size() == 0) {
      // we assume here that snmp collection failed and we don't update the snmp data
      return;
    }

    // Build map of ifIndices to scanned SnmpInterfaces
    Map<Integer, OnmsSnmpInterface> scannedInterfaceMap = new HashMap<Integer, OnmsSnmpInterface>();
    for (OnmsSnmpInterface snmpIface : scannedNode.getSnmpInterfaces()) {
      if (snmpIface.getIfIndex() != null) {
        scannedInterfaceMap.put(snmpIface.getIfIndex(), snmpIface);
      }
    }

    // for each interface on existing node...
    for (Iterator<OnmsSnmpInterface> it = getSnmpInterfaces().iterator(); it.hasNext(); ) {

      OnmsSnmpInterface iface = it.next();
      OnmsSnmpInterface imported = scannedInterfaceMap.get(iface.getIfIndex());

      // remove it since there is no corresponding scanned interface
      if (imported == null) {
        if (deleteMissing) {
          it.remove();
          scannedInterfaceMap.remove(iface.getIfIndex());
        }
      } else {
        // merge the data from the corresponding scanned interface
        iface.mergeSnmpInterfaceAttributes(imported);
        scannedInterfaceMap.remove(iface.getIfIndex());
      }
    }

    // for any scanned interface that was not found on the node add it the database
    for (OnmsSnmpInterface snmpIface : scannedInterfaceMap.values()) {
      addSnmpInterface(snmpIface);
    }
  }
  protected String getEdgeTooltipText(DataLinkInterface link, Vertex source, Vertex target) {
    StringBuffer tooltipText = new StringBuffer();

    OnmsSnmpInterface sourceInterface =
        getSnmpInterfaceDao()
            .findByNodeIdAndIfIndex(Integer.parseInt(source.getId()), link.getIfIndex());
    OnmsSnmpInterface targetInterface =
        getSnmpInterfaceDao()
            .findByNodeIdAndIfIndex(Integer.parseInt(target.getId()), link.getParentIfIndex());

    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    if (sourceInterface != null
        && targetInterface != null
        && sourceInterface.getNetMask() != null
        && !sourceInterface.getNetMask().isLoopbackAddress()
        && targetInterface.getNetMask() != null
        && !targetInterface.getNetMask().isLoopbackAddress()) {
      tooltipText.append("Type of Link: Layer3/Layer2");
    } else {
      tooltipText.append("Type of Link: Layer2");
    }
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    tooltipText.append("Name: &lt;endpoint1 " + source.getLabel());
    if (sourceInterface != null) tooltipText.append(":" + sourceInterface.getIfName());
    tooltipText.append(" ---- endpoint2 " + target.getLabel());
    if (targetInterface != null) tooltipText.append(":" + targetInterface.getIfName());
    tooltipText.append("&gt;");
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    LinkStateMachine stateMachine = new LinkStateMachine();
    stateMachine.setParentInterfaces(sourceInterface, targetInterface);
    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    tooltipText.append("Link status: " + stateMachine.getLinkStatus());
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    if (targetInterface != null) {
      if (targetInterface.getIfSpeed() != null) {
        tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
        tooltipText.append("Bandwidth: " + getHumanReadableIfSpeed(targetInterface.getIfSpeed()));
        tooltipText.append(HTML_TOOLTIP_TAG_END);
      }
    } else if (sourceInterface != null) {
      if (sourceInterface.getIfSpeed() != null) {
        tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
        tooltipText.append("Bandwidth: " + getHumanReadableIfSpeed(sourceInterface.getIfSpeed()));
        tooltipText.append(HTML_TOOLTIP_TAG_END);
      }
    }

    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    tooltipText.append("End Point 1: " + source.getLabel() + ", " + source.getIpAddress());
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    tooltipText.append("End Point 2: " + target.getLabel() + ", " + target.getIpAddress());
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    return tooltipText.toString();
  }
示例#6
0
 /**
  * addSnmpInterface
  *
  * @param snmpIface a {@link org.opennms.netmgt.model.OnmsSnmpInterface} object.
  */
 public void addSnmpInterface(OnmsSnmpInterface snmpIface) {
   snmpIface.setNode(this);
   getSnmpInterfaces().add(snmpIface);
 }