Exemplo n.º 1
0
  /**
   * mergeAgentAttributes
   *
   * @param scannedNode a {@link org.opennms.netmgt.model.OnmsNode} object.
   */
  public void mergeAgentAttributes(OnmsNode scannedNode) {
    if (hasNewValue(scannedNode.getSysContact(), getSysContact())) {
      setSysContact(scannedNode.getSysContact());
    }

    if (hasNewValue(scannedNode.getSysDescription(), getSysDescription())) {
      setSysDescription(scannedNode.getSysDescription());
    }

    if (hasNewValue(scannedNode.getSysLocation(), getSysLocation())) {
      setSysLocation(scannedNode.getSysLocation());
    }

    if (hasNewValue(scannedNode.getSysName(), getSysName())) {
      setSysName(scannedNode.getSysName());
    }

    if (hasNewValue(scannedNode.getSysObjectId(), getSysObjectId())) {
      setSysObjectId(scannedNode.getSysObjectId());
    }
  }
  @Override
  public List<LinkableSnmpNode> getSnmpNodeList() {
    final List<LinkableSnmpNode> nodes = new ArrayList<LinkableSnmpNode>();

    final Criteria criteria = new Criteria(OnmsNode.class);
    criteria.setAliases(
        Arrays.asList(new Alias[] {new Alias("ipInterfaces", "iface", JoinType.LEFT_JOIN)}));
    criteria.addRestriction(new EqRestriction("type", NodeType.ACTIVE));
    criteria.addRestriction(new EqRestriction("iface.isSnmpPrimary", PrimaryType.PRIMARY));
    for (final OnmsNode node : m_nodeDao.findMatching(criteria)) {
      nodes.add(
          new LinkableSnmpNode(
              node.getId(),
              node.getPrimaryInterface().getIpAddress(),
              node.getSysObjectId(),
              node.getSysName()));
    }
    return nodes;
  }
  @Override
  public LinkableSnmpNode getSnmpNode(final int nodeid) {
    final Criteria criteria = new Criteria(OnmsNode.class);
    criteria.setAliases(
        Arrays.asList(new Alias[] {new Alias("ipInterfaces", "iface", JoinType.LEFT_JOIN)}));
    criteria.addRestriction(new EqRestriction("type", NodeType.ACTIVE));
    criteria.addRestriction(new EqRestriction("iface.isSnmpPrimary", PrimaryType.PRIMARY));
    criteria.addRestriction(new EqRestriction("id", nodeid));
    final List<OnmsNode> nodes = m_nodeDao.findMatching(criteria);

    if (nodes.size() > 0) {
      final OnmsNode node = nodes.get(0);
      return new LinkableSnmpNode(
          node.getId(),
          node.getPrimaryInterface().getIpAddress(),
          node.getSysObjectId(),
          node.getSysName());
    } else {
      return null;
    }
  }