当前位置: 首页>>代码示例>>Java>>正文


Java OnmsNode.getSnmpInterfaceWithIfIndex方法代码示例

本文整理汇总了Java中org.opennms.netmgt.model.OnmsNode.getSnmpInterfaceWithIfIndex方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsNode.getSnmpInterfaceWithIfIndex方法的具体用法?Java OnmsNode.getSnmpInterfaceWithIfIndex怎么用?Java OnmsNode.getSnmpInterfaceWithIfIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opennms.netmgt.model.OnmsNode的用法示例。


在下文中一共展示了OnmsNode.getSnmpInterfaceWithIfIndex方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: simulateScan

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private void simulateScan(Date timestamp) {
    OnmsNode n = getNodeDao().get(getNode1().getId());
    
    assertEquals(4, n.getIpInterfaces().size());
    assertEquals(4, n.getSnmpInterfaces().size());

    OnmsIpInterface iface = n.getIpInterfaceByIpAddress("192.168.1.1");
    assertNotNull(iface);
    iface.setIpLastCapsdPoll(timestamp);
    
    OnmsSnmpInterface snmpIface = n.getSnmpInterfaceWithIfIndex(1);
    assertNotNull(snmpIface);
    snmpIface.setLastCapsdPoll(timestamp);
    
    getNodeDao().saveOrUpdate(n);
    
    getNodeDao().flush();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:19,代码来源:NodeDaoTest.java

示例2: updateSnmpInterfaceData

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
   * <p>updateSnmpInterfaceData</p>
   *
   * @param node a {@link org.opennms.netmgt.model.OnmsNode} object.
   * @param ifIndex a {@link java.lang.Integer} object.
   */
  public void updateSnmpInterfaceData(OnmsNode node, Integer ifIndex) {
      // first look to see if an snmpIf was created already
      OnmsSnmpInterface snmpIf = node.getSnmpInterfaceWithIfIndex(ifIndex);
      
      if (snmpIf == null) {
          // if not then create one
          snmpIf = new OnmsSnmpInterface(node, ifIndex);
      }
      
      // IfTable Attributes
snmpIf.setIfType(getIfType(ifIndex));
snmpIf.setIfAdminStatus(getAdminStatus(ifIndex));
snmpIf.setIfDescr(getIfDescr(ifIndex));
snmpIf.setIfSpeed(getIfSpeed(ifIndex));
snmpIf.setPhysAddr(getPhysAddr(ifIndex));
  }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:23,代码来源:IfTable.java

示例3: deleteSnmpInterface

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * <p>deleteSnmpInterface</p>
 *
 * @param nodeCriteria a {@link java.lang.String} object.
 * @param ifIndex a int.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@DELETE
@Path("{ifIndex}")
public Response deleteSnmpInterface(@PathParam("nodeCriteria") final String nodeCriteria, @PathParam("ifIndex") final int ifIndex) {
    writeLock();
    
    try {
        final OnmsNode node = m_nodeDao.get(nodeCriteria);
        if (node == null) throw getException(Status.BAD_REQUEST, "deleteSnmpInterface: can't find node " + nodeCriteria);
        
        final OnmsEntity 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, "deletSnmpInterface: deleting interface with ifIndex %d from node %s", ifIndex, nodeCriteria);
        node.getSnmpInterfaces().remove(snmpInterface);
        m_nodeDao.saveOrUpdate(node);
        // TODO Add important events here
        return Response.ok().build();
    } finally {
        writeUnlock();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:OnmsSnmpInterfaceResource.java

示例4: updateIpInterfaceData

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * <p>updateIpInterfaceData</p>
 *
 * @param node a {@link org.opennms.netmgt.model.OnmsNode} object.
 * @param ipAddr a {@link java.lang.String} object.
 */
public void updateIpInterfaceData(final OnmsNode node, final String ipAddr) {
	OnmsIpInterface ipIf = node.getIpInterfaceByIpAddress(ipAddr);
    if (ipIf == null) {
        ipIf = new OnmsIpInterface(ipAddr, node);
    }

    final InetAddress inetAddr = ipIf.getIpAddress();
    final Integer ifIndex = getIfIndex(inetAddr);

    // if we've found an ifIndex for this interface
    if (ifIndex != null) {

        // first look to see if an snmpIf was created already
        OnmsSnmpInterface snmpIf = node.getSnmpInterfaceWithIfIndex(ifIndex);

        if (snmpIf == null) {
            // if not then create one
            snmpIf = new OnmsSnmpInterface(node, ifIndex);
        }

        final InetAddress mask = getNetMask(inetAddr);
        if (mask != null) {
            snmpIf.setNetMask(mask);
        }

        snmpIf.setCollectionEnabled(true);
        
        ipIf.setSnmpInterface(snmpIf);

    }

    ipIf.setIpHostName(ipAddr);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:40,代码来源:IpAddressTable.java

示例5: updateSnmpInterfaceData

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * <p>updateSnmpInterfaceData</p>
 *
 * @param node a {@link org.opennms.netmgt.model.OnmsNode} object.
 * @param ifIndex a {@link java.lang.Integer} object.
 */
public void updateSnmpInterfaceData(OnmsNode node, Integer ifIndex) {
    // first look to see if an snmpIf was created already
    OnmsSnmpInterface snmpIf2 = node.getSnmpInterfaceWithIfIndex(ifIndex);
    
    if (snmpIf2 == null) {
        // if not then create one
        snmpIf2 = new OnmsSnmpInterface(node, ifIndex);
    }
    // ifXTable Attributes
    snmpIf2.setIfAlias(getIfAlias(ifIndex));
    snmpIf2.setIfName(getIfName(ifIndex));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:19,代码来源:IfXTable.java

示例6: updateIpInterfaceData

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * <p>updateIpInterfaceData</p>
 *
 * @param node a {@link org.opennms.netmgt.model.OnmsNode} object.
 * @param ipAddr a {@link java.lang.String} object.
 */
public void updateIpInterfaceData(OnmsNode node, String ipAddr) {
    OnmsIpInterface ipIf = node.getIpInterfaceByIpAddress(ipAddr);
    if (ipIf == null) {
        ipIf = new OnmsIpInterface(ipAddr, node);
    }

    InetAddress inetAddr = ipIf.getIpAddress();
    Integer ifIndex = getIfIndex(inetAddr);

    // if we've found an ifIndex for this interface
    if (ifIndex != null) {

        // first look to see if an snmpIf was created already
        OnmsSnmpInterface snmpIf = node.getSnmpInterfaceWithIfIndex(ifIndex);

        if (snmpIf == null) {
            // if not then create one
            snmpIf = new OnmsSnmpInterface(node, ifIndex);
        }

        final InetAddress mask = getNetMask(inetAddr);
        if (mask != null) {
            snmpIf.setNetMask(mask);
        }

        snmpIf.setCollectionEnabled(true);
        
        ipIf.setSnmpInterface(snmpIf);

    }

    ipIf.setIpHostName(ipAddr);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:40,代码来源:IpAddrTable.java

示例7: 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();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:64,代码来源:OnmsSnmpInterfaceResource.java


注:本文中的org.opennms.netmgt.model.OnmsNode.getSnmpInterfaceWithIfIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。