コード例 #1
0
  /** {@inheritDoc} */
  @Transactional
  public OnmsIpInterface setIsPrimaryFlag(final Integer nodeId, final String ipAddress) {
    // TODO upsert? not sure if this needs one.. leave the todo here in case
    if (nodeId == null) {
      LogUtils.debugf(this, "nodeId is null!");
      return null;
    } else if (ipAddress == null) {
      LogUtils.debugf(this, "ipAddress is null!");
      return null;
    }
    final OnmsIpInterface svcIface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddress);
    if (svcIface == null) {
      LogUtils.infof(
          this, "unable to find IPInterface for nodeId=%s, ipAddress=%s", nodeId, ipAddress);
      return null;
    }
    OnmsIpInterface primaryIface = null;
    if (svcIface.isPrimary()) {
      primaryIface = svcIface;
    } else if (svcIface.getNode().getPrimaryInterface() == null) {
      svcIface.setIsSnmpPrimary(PrimaryType.PRIMARY);
      m_ipInterfaceDao.saveOrUpdate(svcIface);
      m_ipInterfaceDao.flush();
      primaryIface = svcIface;
    } else {
      svcIface.setIsSnmpPrimary(PrimaryType.SECONDARY);
      m_ipInterfaceDao.saveOrUpdate(svcIface);
      m_ipInterfaceDao.flush();
    }

    m_ipInterfaceDao.initialize(primaryIface);
    return primaryIface;
  }
コード例 #2
0
  @Transactional
  private OnmsIpInterface saveOrUpdate(final OnmsIpInterface iface) {
    iface.visit(new ServiceTypeFulfiller());
    infof(this, "SaveOrUpdating IpInterface %s", iface);
    m_ipInterfaceDao.saveOrUpdate(iface);
    m_ipInterfaceDao.flush();

    return iface;
  }