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


Java OnmsNode.getIpInterfaces方法代码示例

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


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

示例1: getResourcesForNode

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
public List<OnmsResource> getResourcesForNode(final int nodeId) {
	final LinkedList<OnmsResource> resources = new LinkedList<OnmsResource>();
    
	final OnmsNode node = m_nodeDao.get(nodeId);
    if (node == null) {
        throw new ObjectRetrievalFailureException(OnmsNode.class, nodeId, "Could not find node for node Id " + nodeId, null);
    }
    
    for (final OnmsIpInterface i : node.getIpInterfaces()) {
        String ipAddr = InetAddressUtils.str(i.getIpAddress());

        final File iface = getInterfaceDirectory(ipAddr, false);
        
        if (iface.isDirectory()) {
            resources.add(createResource(i));
        }
    }

    return resources;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:ResponseTimeResourceType.java

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

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

示例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);

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:DnsRecord.java

示例5: validateNode

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private void validateNode(OnmsNode n) throws Exception {
      assertNotNull("Expected node to be non-null", n);
      assertNotNull("Expected node "+n.getId()+" to have interfaces", n.getIpInterfaces());
      assertEquals("Unexpected number of interfaces for node "+n.getId(), 4, n.getIpInterfaces().size());
      for (Object o : n.getIpInterfaces()) {
	OnmsIpInterface iface = (OnmsIpInterface)o;
	assertNotNull(iface);
	assertNotNull(InetAddressUtils.str(iface.getIpAddress()));
}
      
      assertNodeEquals(getNode1(), n);
  }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:13,代码来源:NodeDaoTest.java

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

示例7: getIpAddrToInterfaceMap

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
  * <p>getIpAddrToInterfaceMap</p>
  *
  * @param imported a {@link org.opennms.netmgt.model.OnmsNode} object.
  * @return a {@link java.util.Map} object.
  */
 protected Map<String, OnmsIpInterface> getIpAddrToInterfaceMap(OnmsNode imported) {
     Map<String, OnmsIpInterface> ipAddrToIface = new HashMap<String, OnmsIpInterface>();
     for (final OnmsIpInterface iface : imported.getIpInterfaces()) {
         final String ipAddress = InetAddressUtils.str(iface.getIpAddress());
ipAddrToIface.put(ipAddress, iface);
     }
     return ipAddrToIface;
 }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:AbstractSaveOrUpdateOperation.java

示例8: findNodeResources

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * Returns a list of resources for all the nodes.
 *
 * <ul>
 * <li>A resource must be listed once no matter if storeByForeignSource is enabled or not</li>
 * <li>Discovered nodes should have resources based on the nodeId</li>
 * <li>A requisitioned node should have resources based on nodeSource if storeByForeignSource is enabled</li>
 * <li>A requisitioned node should have resources based on nodeId if storeByForeignSource is not enabled</li>
 * </ul>
 * 
 * <p>TODO It does not currently fully check that an IP address that is found to have
 * distributed response time data is in the database on the proper node so it can have false positives.</p>
 * 
 * @return a {@link java.util.List} object.
 */
protected List<OnmsResource> findNodeResources() {
    List<OnmsResource> resources = new LinkedList<OnmsResource>();

    IntSet snmpNodes = findSnmpNodeDirectories();
    Set<String> nodeSources = findNodeSourceDirectories();

    Set<String> responseTimeInterfaces = findChildrenMatchingFilter(new File(getRrdDirectory(), RESPONSE_DIRECTORY), RrdFileConstants.INTERFACE_DIRECTORY_FILTER);
    Set<String> distributedResponseTimeInterfaces = findChildrenChildrenMatchingFilter(new File(new File(getRrdDirectory(), RESPONSE_DIRECTORY), "distributed"), RrdFileConstants.INTERFACE_DIRECTORY_FILTER);

    List<OnmsNode> nodes = m_nodeDao.findAll();
    IntSet nodesFound = new IntSet();
    for (OnmsNode node : nodes) {
        // Only returns non-deleted nodes to fix NMS-2977
        if (nodesFound.contains(node.getId()) || (node.getType() != null && node.getType().equals("D"))) {
            continue;
        }
        boolean nodeIdfound = false;
        boolean nodeSourcefound = false;
        boolean responseTimeFound = false;
        if (node.getForeignSource() != null && node.getForeignId() != null && nodeSources.contains(node.getForeignSource() + ":" + node.getForeignId())) {
            nodeSourcefound = true;
        } else if (snmpNodes.contains(node.getId())) {
            nodeIdfound = true;
        } else if (responseTimeInterfaces.size() > 0 || distributedResponseTimeInterfaces.size() > 0) {
            for (final OnmsIpInterface ip : node.getIpInterfaces()) {
                final String addr = InetAddressUtils.str(ip.getIpAddress());
                if (responseTimeInterfaces.contains(addr) || distributedResponseTimeInterfaces.contains(addr)) {
                    responseTimeFound = true;
                    break;
                }
            }
        }
        boolean storeByFS = ResourceTypeUtils.isStoreByForeignSource();
        if (nodeSourcefound || (responseTimeFound && storeByFS)) {
            log().debug("findNodeResources: adding resources for nodeSource " + node.getForeignSource() + ":" + node.getForeignId());
            resources.add(m_nodeSourceResourceType.createChildResource(node.getForeignSource() + ":" + node.getForeignId()));
            nodesFound.add(node.getId());
        }
        if (nodeIdfound || (responseTimeFound && !storeByFS)) {
            log().debug("findNodeResources: adding resources for nodeId " + node.getId());
            resources.add(m_nodeResourceType.createChildResource(node));
            nodesFound.add(node.getId());
        }
    }

    return resources;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:63,代码来源:DefaultResourceDao.java

示例9: detectIpAddressTable

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public void detectIpAddressTable(final BatchTask currentPhase) {
     	final OnmsNode node = getNode();

         debugf(this, "Attempting to scan the IPAddress table for node %s", node);

// mark all provisioned interfaces as 'in need of scanning' so we can mark them
         // as scanned during ipAddrTable processing
         final Set<InetAddress> provisionedIps = new HashSet<InetAddress>();
         if (getForeignSource() != null) {
             for(final OnmsIpInterface provisioned : node.getIpInterfaces()) {
                 provisionedIps.add(provisioned.getIpAddress());
             }
         }

         final IPAddressTableTracker ipAddressTracker = new IPAddressTableTracker() {
         	@Override
         	public void processIPAddressRow(final IPAddressRow row) {
         		final String ipAddress = row.getIpAddress();
		infof(this, "Processing IPAddress table row with ipAddr %s", ipAddress);

		final InetAddress address = addr(ipAddress);

		// skip if it's any number of unusual/local address types
		if (address == null) return;
		if (address.isAnyLocalAddress()) {
			debugf(this, "%s.isAnyLocalAddress() == true, Skipping.", ipAddress);
			return;
		}
		if (address.isLinkLocalAddress()) {
			debugf(this, "%s.isLinkLocalAddress() == true, Skipping.", ipAddress);
			return;
		}
		if (address.isLoopbackAddress()) {
			debugf(this, "%s.isLoopbackAddress() == true, Skipping.", ipAddress);
			return;
		}
		if (address.isMulticastAddress()) {
			debugf(this, "%s.isMulticastAddress() == true, Skipping.", ipAddress);
			return;
		}

                 // mark any provisioned interface as scanned
                 provisionedIps.remove(ipAddress);

                 OnmsIpInterface iface = row.createInterfaceFromRow();

                 if (iface != null) {
                     iface.setIpLastCapsdPoll(getScanStamp());
                     iface.setIsManaged("M");

                     final List<IpInterfacePolicy> policies = getProvisionService().getIpInterfacePoliciesForForeignSource(getForeignSource() == null ? "default" : getForeignSource());
                     for(final IpInterfacePolicy policy : policies) {
                         if (iface != null) {
                             iface = policy.apply(iface);
                         }
                     }
                     
                     if (iface != null) {
                         currentPhase.add(ipUpdater(currentPhase, iface), "write");
                     }
                 }
         	}
         };

         walkTable(currentPhase, provisionedIps, ipAddressTracker);
     }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:67,代码来源:NodeScan.java

示例10: detectIpInterfaceTable

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public void detectIpInterfaceTable(final BatchTask currentPhase) {
     	final OnmsNode node = getNode();

         debugf(this, "Attempting to scan the IPInterface table for node %s", node);

// mark all provisioned interfaces as 'in need of scanning' so we can mark them
         // as scanned during ipAddrTable processing
         final Set<InetAddress> provisionedIps = new HashSet<InetAddress>();
         if (getForeignSource() != null) {
             for(final OnmsIpInterface provisioned : node.getIpInterfaces()) {
                 provisionedIps.add(provisioned.getIpAddress());
             }
         }

         final IPInterfaceTableTracker ipIfTracker = new IPInterfaceTableTracker() {
         	@Override
         	public void processIPInterfaceRow(final IPInterfaceRow row) {
         		final String ipAddress = row.getIpAddress();
         		infof(this, "Processing IPInterface table row with ipAddr %s for node %d/%s/%s", ipAddress, node.getId(), node.getForeignSource(), node.getForeignId());

		final InetAddress address = addr(ipAddress);

		// skip if it's any number of unusual/local address types
		if (address == null) return;
		if (address.isAnyLocalAddress()) {
			debugf(this, "%s.isAnyLocalAddress() == true, Skipping.", ipAddress);
			return;
		}
		if (address.isLinkLocalAddress()) {
			debugf(this, "%s.isLinkLocalAddress() == true, Skipping.", ipAddress);
			return;
		}
		if (address.isLoopbackAddress()) {
			debugf(this, "%s.isLoopbackAddress() == true, Skipping.", ipAddress);
			return;
		}
		if (address.isMulticastAddress()) {
			debugf(this, "%s.isMulticastAddress() == true, Skipping.", ipAddress);
			return;
		}

                 // mark any provisioned interface as scanned
                 provisionedIps.remove(ipAddress);

                 // save the interface
                 OnmsIpInterface iface = row.createInterfaceFromRow();
                 
                 if (iface != null) {
                  iface.setIpLastCapsdPoll(getScanStamp());
	
                  // add call to the ip interface is managed policies
                  iface.setIsManaged("M");
	
                  final List<IpInterfacePolicy> policies = getProvisionService().getIpInterfacePoliciesForForeignSource(getForeignSource() == null ? "default" : getForeignSource());
                  for(final IpInterfacePolicy policy : policies) {
                      if (iface != null) {
                          iface = policy.apply(iface);
                      }
                  }
	
                  if (iface != null) {
                      currentPhase.add(ipUpdater(currentPhase, iface), "write");
                  }
                 }
             }
         };

         walkTable(currentPhase, provisionedIps, ipIfTracker);
     }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:70,代码来源:NodeScan.java

示例11: testNoRescanOnImport

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test(timeout=300000)
@Transactional
@JUnitSnmpAgents({
    @JUnitSnmpAgent(host="172.20.1.201", port=161, resource="classpath:testNoRescanOnImport-part1.properties"),
    @JUnitSnmpAgent(host="172.20.1.204", port=161, resource="classpath:testNoRescanOnImport-part1.properties"),
    @JUnitSnmpAgent(host="10.1.15.245", port=161, resource="classpath:testNoRescanOnImport-part2.properties")
})
public void testNoRescanOnImport() throws Exception {
    setupLogging("INFO");

    System.err.println("-------------------------------------------------------------------------");
    System.err.println("Import Part 1");
    System.err.println("-------------------------------------------------------------------------");

    importFromResource("classpath:/testNoRescanOnImport-part1.xml", true);

    final List<OnmsNode> nodes = getNodeDao().findAll();
    assertEquals(1, nodes.size());
    
    final OnmsNode node = nodes.get(0);
    assertEquals(1, node.getIpInterfaces().size());

    System.err.println("-------------------------------------------------------------------------");
    System.err.println("Import Part 2");
    System.err.println("-------------------------------------------------------------------------");

    setupLogging("DEBUG");
    m_eventAnticipator.reset();
    anticipateNoRescanFirstNodeEvents();
    anticipateNoRescanSecondNodeEvents();
    importFromResource("classpath:/testNoRescanOnImport-part2.xml", false);
    m_eventAnticipator.verifyAnticipated();
    setupLogging("INFO");

    //Verify node count
    assertEquals(2, getNodeDao().countAll());

    for (final OnmsNode n : getNodeDao().findAll()) {
    	LogUtils.infof(this, "found node %s", n);
    	for (final OnmsIpInterface iface : n.getIpInterfaces()) {
    		LogUtils.infof(this, "  interface: %s", iface);
    	}
    }
    
    setupLogging("ERROR");
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:47,代码来源:ProvisionerRescanTest.java

示例12: setUp

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
	MockLogAppender.setupLogging();

	FileUtils.deleteDirectory(new File(TEST_SNMP_DIR));

	RrdUtils.setStrategy(RrdUtils.getSpecificStrategy(StrategyName.basicRrdStrategy));

	OnmsIpInterface iface = null;
	OnmsNode testNode = null;
	Collection<OnmsNode> testNodes = m_nodeDao.findByLabel(TEST_NODE_LABEL);
	if (testNodes == null || testNodes.size() < 1) {
		NetworkBuilder builder = new NetworkBuilder();
		builder.addNode(TEST_NODE_LABEL).setId(1).setSysObjectId(".1.3.6.1.4.1.1588.2.1.1.1");
		InterfaceBuilder ifBldr = builder.addInterface(TEST_NODE_IP).setIsSnmpPrimary("P");
		ifBldr.addSnmpInterface(6).setIfName("fw0").setPhysAddr("44:33:22:11:00").setIfType(144).setCollectionEnabled(true);
		testNode = builder.getCurrentNode();
		Assert.assertNotNull(testNode);
		m_nodeDao.save(testNode);
		m_nodeDao.flush();
	} else {
		testNode = testNodes.iterator().next();
	}

	Set<OnmsIpInterface> ifaces = testNode.getIpInterfaces();
	Assert.assertEquals(1, ifaces.size());
	iface = ifaces.iterator().next();

	SnmpPeerFactory.setInstance(m_snmpPeerFactory);

	m_collectionAgent = DefaultCollectionAgent.create(iface.getId(), m_ipInterfaceDao, m_transactionManager);
	
	TcaRrd rrd = new TcaRrd();
	rrd.addRra("RRA:AVERAGE:0.5:1:3600");
	rrd.addRra("RRA:AVERAGE:0.5:300:288");
	rrd.addRra("RRA:MIN:0.5:300:288");
	rrd.addRra("RRA:MAX:0.5:300:288");
	rrd.addRra("RRA:AVERAGE:0.5:900:2880");
	rrd.addRra("RRA:MIN:0.5:900:2880");
	rrd.addRra("RRA:MAX:0.5:900:2880");
	rrd.addRra("RRA:AVERAGE:0.5:3600:4300");
	rrd.addRra("RRA:MIN:0.5:3600:4300");
	rrd.addRra("RRA:MAX:0.5:3600:4300");
	TcaDataCollection tcadc = new TcaDataCollection();
	tcadc.setName("default");
	tcadc.setRrd(rrd);
	TcaDataCollectionConfig tcadcc = new TcaDataCollectionConfig();
	tcadcc.addDataCollection(tcadc);
	tcadcc.setRrdRepository(TEST_SNMP_DIR);
	EasyMock.expect(m_configDao.getConfig()).andReturn(tcadcc).atLeastOnce();
	EasyMock.replay(m_configDao);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:58,代码来源:TcaCollectorTest.java

示例13: setUp

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();

    // Initialize the JdbcFilterDao so that it will connect to the correct database
    DatabaseSchemaConfigFactory.init();
    JdbcFilterDao jdbcFilterDao = new JdbcFilterDao();
    jdbcFilterDao.setDataSource(m_database);
    jdbcFilterDao.setDatabaseSchemaConfigFactory(DatabaseSchemaConfigFactory.getInstance());
    jdbcFilterDao.afterPropertiesSet();
    FilterDaoFactory.setInstance(jdbcFilterDao);

    RrdUtils.setStrategy(RrdUtils.getSpecificStrategy(StrategyName.basicRrdStrategy));

    m_testHostName = InetAddressUtils.str(InetAddress.getLocalHost());

    OnmsIpInterface iface = null;
    OnmsNode testNode = null;
    Collection<OnmsNode> testNodes = m_nodeDao.findByLabel(TEST_NODE_LABEL);
    if (testNodes == null || testNodes.size() < 1) {
        NetworkBuilder builder = new NetworkBuilder();
        builder.addNode(TEST_NODE_LABEL).setId(1).setSysObjectId(".1.3.6.1.4.1.1588.2.1.1.1");

        builder.addSnmpInterface(1).setIfName("lo0").setPhysAddr("00:11:22:33:44");
        builder.addSnmpInterface(2).setIfName("gif0").setPhysAddr("00:11:22:33:45").setIfType(55);
        builder.addSnmpInterface(3).setIfName("stf0").setPhysAddr("00:11:22:33:46").setIfType(57);

        builder.addSnmpInterface(6).setIfName("fw0").setPhysAddr("44:33:22:11:00").setIfType(144).setCollectionEnabled(true)
            .addIpInterface(m_testHostName).setIsSnmpPrimary("P");

        testNode = builder.getCurrentNode();
        assertNotNull(testNode);
        m_nodeDao.save(testNode);
        m_nodeDao.flush();
    } else {
        testNode = testNodes.iterator().next();
    }

    Set<OnmsIpInterface> ifaces = testNode.getIpInterfaces();
    assertEquals(1, ifaces.size());
    iface = ifaces.iterator().next();

    SnmpPeerFactory.setInstance(m_snmpPeerFactory);

    SnmpCollector collector = new SnmpCollector();
    collector.initialize(null);

    m_collectionSpecification = CollectorTestUtils.createCollectionSpec("SNMP", collector, "default");
    m_collectionAgent = DefaultCollectionAgent.create(iface.getId(), m_ipInterfaceDao, m_transactionManager);
    m_agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.getLocalHostAddress());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:52,代码来源:SnmpCollectorTest.java

示例14: setUp

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    final Properties p = new Properties();
	p.setProperty("log4j.logger.org.opennms.netmgt.snmp.SnmpUtils", "DEBUG");
    MockLogAppender.setupLogging(p);

    assertTrue(m_snmpPeerFactory instanceof ProxySnmpAgentConfigFactory);

    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    m_agentConfig = m_snmpPeerFactory.getAgentConfig(InetAddressUtils.addr(TEST_HOST_ADDRESS));

    RrdUtils.setStrategy(RrdUtils.getSpecificStrategy(StrategyName.basicRrdStrategy));

    OnmsIpInterface iface = null;
    OnmsNode testNode = null;
    Collection<OnmsNode> testNodes = m_nodeDao.findByLabel(TEST_NODE_LABEL);
    if (testNodes == null || testNodes.size() < 1) {
        NetworkBuilder builder = new NetworkBuilder();
        builder.addNode(TEST_NODE_LABEL).setId(1).setSysObjectId(".1.3.6.1.4.1.1588.2.1.1.1");

        builder.addSnmpInterface(1).setIfName("lo0").setPhysAddr("00:11:22:33:44");
        builder.addSnmpInterface(2).setIfName("gif0").setPhysAddr("00:11:22:33:45").setIfType(55);
        builder.addSnmpInterface(3).setIfName("stf0").setPhysAddr("00:11:22:33:46").setIfType(57);

        InterfaceBuilder ifBldr = builder.addInterface(TEST_HOST_ADDRESS).setIsSnmpPrimary("P");
        ifBldr.addSnmpInterface(6).setIfName("fw0").setPhysAddr("44:33:22:11:00").setIfType(144).setCollectionEnabled(true);

        testNode = builder.getCurrentNode();
        assertNotNull(testNode);
        m_nodeDao.save(testNode);
        m_nodeDao.flush();
    } else {
        testNode = testNodes.iterator().next();
    }

    final Set<OnmsIpInterface> ifaces = testNode.getIpInterfaces();
    assertEquals(1, ifaces.size());
    iface = ifaces.iterator().next();
    
    LogUtils.debugf(this, "iface = %s", iface);

    final SnmpCollector collector = new SnmpCollector();
    collector.initialize(null);

    m_collectionSpecification = CollectorTestUtils.createCollectionSpec("SNMP", collector, "default");
    m_collectionAgent = DefaultCollectionAgent.create(iface.getId(), m_ipInterfaceDao, m_transactionManager);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:48,代码来源:SnmpCollectorMinMaxValTest.java


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