/** {@inheritDoc} */ @Transactional public OnmsIpInterface getPrimaryInterfaceForNode(final OnmsNode node) { final OnmsNode dbNode = getDbNode(node); if (dbNode == null) { return null; } else { final OnmsIpInterface primaryIface = dbNode.getPrimaryInterface(); if (primaryIface != null) { m_ipInterfaceDao.initialize(primaryIface); m_ipInterfaceDao.initialize(primaryIface.getMonitoredServices()); } return primaryIface; } }
/** {@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; }