本文整理汇总了Java中org.opennms.netmgt.model.OnmsNode.getPrimaryInterface方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsNode.getPrimaryInterface方法的具体用法?Java OnmsNode.getPrimaryInterface怎么用?Java OnmsNode.getPrimaryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.netmgt.model.OnmsNode
的用法示例。
在下文中一共展示了OnmsNode.getPrimaryInterface方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrimaryInterfaceForNode
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/** {@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;
}
}
示例2: getSuitableIpForRancid
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private String getSuitableIpForRancid(OnmsNode node){
log().debug("getSuitableIpForRancid: node: " + node.getNodeId() + " Foreign Source: " + node.getForeignSource());
OnmsIpInterface primaryInterface = node.getPrimaryInterface();
String ipaddr = "127.0.0.1";
if (primaryInterface == null) {
log().debug("getSuitableIpForRancid: found null SNMP Primary Interface, getting interfaces");
Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces();
for (OnmsIpInterface onmsIpInterface : ipInterfaces) {
log().debug("getSuitableIpForRancid: trying Interface with id: " + onmsIpInterface.getId());
if (onmsIpInterface.getIpAddress() != null) {
ipaddr = str(onmsIpInterface.getIpAddress());
} else {
log().debug("getSuitableIpForRancid: found null ip address on Interface with id: " + onmsIpInterface.getId());
}
}
} else {
log().debug("getSuitableIpForRancid: found SNMP Primary Interface");
if (primaryInterface.getIpAddress() != null ) {
ipaddr = str(primaryInterface.getIpAddress());
} else {
log().debug("getSuitableIpForRancid: found null ip address on Primary Interface");
}
}
return ipaddr;
}
示例3: getIpForNode
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private InetAddress getIpForNode(final OnmsNode node) {
LogUtils.debugf(this, "getIpForNode: node: %s Foreign Source: %s", node.getNodeId(), node.getForeignSource());
final OnmsIpInterface primaryInterface = node.getPrimaryInterface();
InetAddress ipaddr = InetAddressUtils.getLocalHostAddress();
if (primaryInterface == null) {
log().debug("getIpForNode: found null SNMP Primary Interface, getting interfaces");
final Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces();
for (final OnmsIpInterface onmsIpInterface : ipInterfaces) {
log().debug("getIpForNode: trying Interface with id: " + onmsIpInterface.getId());
if (InetAddressUtils.str(onmsIpInterface.getIpAddress()) != null)
ipaddr = onmsIpInterface.getIpAddress();
else
log().debug("getIpForNode: found null ip address on Interface with id: " + onmsIpInterface.getId());
}
} else {
log().debug("getIpForNode: found SNMP Primary Interface");
if (InetAddressUtils.str(primaryInterface.getIpAddress()) != null )
ipaddr = primaryInterface.getIpAddress();
else
log().debug("getIpForNode: found null ip address on Primary Interface");
}
return ipaddr;
}
示例4: DnsRecord
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
DnsRecord(OnmsNode node) {
OnmsIpInterface primaryInterface = node.getPrimaryInterface();
if (primaryInterface == null) {
log().debug("Constructor: no primary interface found for nodeid: " + node.getNodeId());
Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces();
for (OnmsIpInterface onmsIpInterface : ipInterfaces) {
m_ip = onmsIpInterface.getIpAddress();
break;
}
} else {
log().debug("Constructor: primary interface found for nodeid: " + node.getNodeId());
m_ip = primaryInterface.getIpAddress();
}
log().debug("Constructor: set ip address: " + m_ip);
m_hostname = node.getLabel() + ".";
log().debug("Constructor: set hostname: " + m_hostname);
m_zone = m_hostname.substring(m_hostname.indexOf('.') + 1);
log().debug("Constructor: set zone: " + m_zone);
}
示例5: getSuitableIp
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
* <p>getSuitableIp</p>
*
* @param node a {@link org.opennms.netmgt.model.OnmsNode} object.
* @return a {@link java.lang.String} object.
*/
public String getSuitableIp(final OnmsNode node){
final OnmsIpInterface primaryInterface = node.getPrimaryInterface();
if (primaryInterface == null) {
final Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces();
for (final OnmsIpInterface onmsIpInterface : ipInterfaces) {
return str(onmsIpInterface.getIpAddress());
}
return "0.0.0.0";
}
return str(primaryInterface.getIpAddress());
}
示例6: getPrimaryIfIndexForNode
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private int getPrimaryIfIndexForNode(OnmsNode node) {
if(node.getPrimaryInterface() != null && node.getPrimaryInterface().getIfIndex() != null){
return node.getPrimaryInterface().getIfIndex();
}else{
return -1;
}
}
示例7: getPrimaryAddress
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Transactional(readOnly=true)
public String getPrimaryAddress(int nodeId) {
OnmsNode node = m_nodeDao.get(nodeId);
OnmsIpInterface primaryInterface = node.getPrimaryInterface();
if(node != null && primaryInterface != null) {
return InetAddressUtils.str(primaryInterface.getIpAddress());
}
return null;
}
示例8: NodeEntry
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public NodeEntry(final OnmsNode node) {
final OnmsAssetRecord assetRecord = node.getAssetRecord();
if (assetRecord != null && assetRecord.getGeolocation() != null) {
final OnmsGeolocation geolocation = assetRecord.getGeolocation();
m_longitude = geolocation.getLongitude();
m_latitude = geolocation.getLatitude();
}
m_nodeId = node.getId();
m_nodeLabel = node.getLabel();
m_foreignSource = node.getForeignSource();
m_foreignId = node.getForeignId();
if (assetRecord != null) {
m_maintcontract = assetRecord.getMaintcontract();
m_description = assetRecord.getDescription();
}
if (node.getPrimaryInterface() != null) {
m_ipAddress = InetAddressUtils.str(node.getPrimaryInterface().getIpAddress());
}
if (node.getCategories() != null && node.getCategories().size() > 0) {
for (final OnmsCategory category : node.getCategories()) {
m_categories.add(category.getName());
}
}
}
示例9: updateSnmpInterface
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
* <p>updateSnmpInterface</p>
*
* @param nodeCriteria a {@link java.lang.String} object.
* @param ifIndex a int.
* @param params a {@link org.opennms.web.rest.MultivaluedMapImpl} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@PUT
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("{ifIndex}")
public Response updateSnmpInterface(@PathParam("nodeCriteria") final String nodeCriteria, @PathParam("ifIndex") final int ifIndex, final MultivaluedMapImpl params) {
writeLock();
try {
final OnmsNode node = m_nodeDao.get(nodeCriteria);
if (node == null) throw getException(Status.BAD_REQUEST, "deleteSnmpInterface: can't find node " + nodeCriteria);
if (ifIndex < 0) throw getException(Status.BAD_REQUEST, "deleteSnmpInterface: invalid ifIndex specified for SNMP interface on node " + node.getId() + ": " + ifIndex);
final OnmsSnmpInterface snmpInterface = node.getSnmpInterfaceWithIfIndex(ifIndex);
if (snmpInterface == null) throw getException(Status.BAD_REQUEST, "deleteSnmpInterface: can't find SNMP interface with ifIndex " + ifIndex + " for node " + nodeCriteria);
LogUtils.debugf(this, "updateSnmpInterface: updating SNMP interface %s", snmpInterface);
final BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(snmpInterface);
for(final String key : params.keySet()) {
if (wrapper.isWritableProperty(key)) {
final String stringValue = params.getFirst(key);
final Object value = wrapper.convertIfNecessary(stringValue, (Class<?>)wrapper.getPropertyType(key));
wrapper.setPropertyValue(key, value);
}
}
Event e = null;
if (params.containsKey("collect")) {
// we've updated the collection flag so we need to send an event to redo collection
final EventBuilder bldr = new EventBuilder(EventConstants.REINITIALIZE_PRIMARY_SNMP_INTERFACE_EVENT_UEI, "OpenNMS.Webapp");
bldr.setNode(node);
// Bug NMS-4432 says that sometimes the primary SNMP interface is null
// so we need to check for that before we set the interface
final OnmsIpInterface iface = node.getPrimaryInterface();
if (iface == null) {
LogUtils.warnf(this, "updateSnmpInterface: Cannot send %s event because node %d has no primary SNMP interface", EventConstants.REINITIALIZE_PRIMARY_SNMP_INTERFACE_EVENT_UEI, node.getId());
} else {
bldr.setInterface(iface.getIpAddress());
e = bldr.getEvent();
}
}
LogUtils.debugf(this, "updateSnmpInterface: SNMP interface %s updated", snmpInterface);
m_snmpInterfaceDao.saveOrUpdate(snmpInterface);
if (e != null) {
try {
m_eventProxy.send(e);
} catch (final EventProxyException ex) {
throw getException(Response.Status.INTERNAL_SERVER_ERROR, "Exception occurred sending event: "+ex.getMessage());
}
}
return Response.seeOther(getRedirectUri(m_uriInfo)).build();
} finally {
writeUnlock();
}
}
示例10: determineProxyAddress
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private InetAddress determineProxyAddress(Map<String, Object> parameters, MonitoredService svc) {
LogUtils.debugf(getClass(), "Determining the proxy address on which to set up the ciscoPingEntry for target interface %s", svc.getAddress());
OnmsNode proxyNode = null;
InetAddress proxyAddress = null;
String proxyNodeId = ParameterMap.getKeyedString(parameters, PARM_PROXY_NODE_ID, null);
String proxyNodeFS = ParameterMap.getKeyedString(parameters, PARM_PROXY_FOREIGN_SOURCE, null);
String proxyNodeFI = ParameterMap.getKeyedString(parameters, PARM_PROXY_FOREIGN_ID, null);
String rawProxyIpAddr = ParameterMap.getKeyedString(parameters, PARM_PROXY_IP_ADDR, null);
String proxyIpAddr = rawProxyIpAddr;
if (rawProxyIpAddr != null) {
proxyIpAddr = PropertiesUtils.substitute(rawProxyIpAddr, getServiceProperties(svc));
LogUtils.debugf(getClass(), "Expanded value '%s' of parameter %s to '%s' for service %s on interface %s", rawProxyIpAddr, PARM_PROXY_IP_ADDR, proxyIpAddr, svc.getSvcName(), svc.getAddress());
}
/* If we have a foreign-source and foreign-id, short circuit to use that */
if (proxyNodeFS != null && !proxyNodeFS.equals("") && proxyNodeFI != null && !proxyNodeFI.equals("")) {
LogUtils.debugf(getClass(), "Trying to look up proxy node with foreign-source %s, foreign-id %s for target interface %s", proxyNodeFS, proxyNodeFI, svc.getAddress());
proxyNode = s_nodeDao.findByForeignId(proxyNodeFS, proxyNodeFI);
LogUtils.debugf(getClass(), "Found a node via foreign-source / foreign-id '%s'/'%s' to use as proxy", proxyNodeFS, proxyNodeFI);
if (proxyNode != null && proxyNode.getPrimaryInterface() != null) proxyAddress = proxyNode.getPrimaryInterface().getIpAddress();
}
if (proxyAddress != null) {
LogUtils.infof(getClass(), "Using address %s from node '%s':'%s' as proxy for service '%s' on interface %s", proxyAddress, proxyNodeFS, proxyNodeFI, svc.getSvcName(), svc.getIpAddr());
return proxyAddress;
}
/* No match with foreign-source / foreign-id? Try with a node ID */
if (proxyNodeId != null && Integer.valueOf(proxyNodeId) != null) {
LogUtils.debugf(getClass(), "Trying to look up proxy node with database ID %d for target interface %s", proxyNodeId, svc.getAddress());
proxyNode = s_nodeDao.get(Integer.valueOf(proxyNodeId));
if (proxyNode != null && proxyNode.getPrimaryInterface() != null) proxyAddress = proxyNode.getPrimaryInterface().getIpAddress();
}
if (proxyAddress != null) {
LogUtils.infof(getClass(), "Using address %s from node with DBID %s as proxy for service '%s' on interface %s", proxyAddress, proxyNodeId, svc.getSvcName(), svc.getIpAddr());
return proxyAddress;
}
/* No match with any node criteria? Try for a plain old IP address. */
LogUtils.infof(getClass(), "Trying to use address %s as proxy-ping agent address for target interface %s", proxyIpAddr, svc.getAddress());
try {
if (!"".equals(proxyIpAddr)) {
proxyAddress = InetAddressUtils.addr(proxyIpAddr);
}
} catch (final IllegalArgumentException e) {}
if (proxyAddress != null) {
LogUtils.infof(getClass(), "Using address %s (user-specified) as proxy for service '%s' on interface %s", proxyAddress, svc.getSvcName(), svc.getIpAddr());
return proxyAddress;
}
LogUtils.errorf(getClass(), "Unable to determine proxy address for service '%s' on interface '%s'. The poll will be unable to proceed.", svc.getSvcName(), svc.getIpAddr());
return null;
}