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


Java OnmsNode.addIpInterface方法代码示例

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


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

示例1: createNode

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private OnmsNode createNode(int nodeId, String nodelabel, String foreignSource, String foreignId, String ipAddress) {
    OnmsNode n = new OnmsNode();
    n.setId(nodeId);
    n.setLabel(nodelabel);
    if (foreignSource != null) {
        n.setForeignSource(foreignSource);
    }
    if (foreignId != null) {
        n.setForeignId(foreignId);
    }
    OnmsIpInterface ip = new OnmsIpInterface();
    ip.setId(10 + nodeId);
    ip.setIpAddress(InetAddressUtils.addr(ipAddress));
    ip.setNode(n);
    n.addIpInterface(ip);
    return n;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:18,代码来源:FindTopLevelResourcesTest.java

示例2: testFindNodeResourcesWithResponseTime

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public void testFindNodeResourcesWithResponseTime() throws Exception {
    List<OnmsNode> nodes = new LinkedList<OnmsNode>();
    OnmsNode node = createNode();
    OnmsIpInterface ip = createIpInterface();
    node.addIpInterface(ip);
    nodes.add(node);
    
    expect(m_nodeDao.findAll()).andReturn(nodes);

    File response = m_fileAnticipator.tempDir("response");
    File ipDir = m_fileAnticipator.tempDir(response, "192.168.1.1");
    m_fileAnticipator.tempFile(ipDir, "icmp" + RrdUtils.getExtension());
    
    m_easyMockUtils.replayAll();
    List<OnmsResource> resources = m_resourceDao.findNodeResources();
    m_easyMockUtils.verifyAll();
    
    assertNotNull("resource list should not be null", resources);
    assertEquals("resource list size", 1, resources.size());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:21,代码来源:DefaultResourceDaoTest.java

示例3: testFindNodeResourcesWithDistributedResponseTime

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public void testFindNodeResourcesWithDistributedResponseTime() throws Exception {
    List<OnmsNode> nodes = new LinkedList<OnmsNode>();
    OnmsNode node = createNode();
    OnmsIpInterface ip = createIpInterface();
    node.addIpInterface(ip);
    nodes.add(node);

    expect(m_nodeDao.findAll()).andReturn(nodes);

    File response = m_fileAnticipator.tempDir("response");
    File distributed = m_fileAnticipator.tempDir(response, "distributed");
    File monitor = m_fileAnticipator.tempDir(distributed, "1");
    File ipDir = m_fileAnticipator.tempDir(monitor, "192.168.1.1");
    m_fileAnticipator.tempFile(ipDir, "icmp" + RrdUtils.getExtension());
    
    m_easyMockUtils.replayAll();
    List<OnmsResource> resources = m_resourceDao.findNodeResources();
    m_easyMockUtils.verifyAll();
    
    assertNotNull("resource list should not be null", resources);
    assertEquals("resource list size", 1, resources.size());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:23,代码来源:DefaultResourceDaoTest.java

示例4: testFindNodeResourcesWithNodeSnmp

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public void testFindNodeResourcesWithNodeSnmp() throws Exception {
    List<OnmsNode> nodes = new LinkedList<OnmsNode>();
    OnmsNode node = createNode();
    OnmsIpInterface ip = createIpInterface();
    node.addIpInterface(ip);
    nodes.add(node);
    
    expect(m_nodeDao.findAll()).andReturn(nodes);

    File snmp = m_fileAnticipator.tempDir("snmp");
    File nodeDir = m_fileAnticipator.tempDir(snmp, "1");
    m_fileAnticipator.tempFile(nodeDir, "foo" + RrdUtils.getExtension());
    
    m_easyMockUtils.replayAll();
    List<OnmsResource> resources = m_resourceDao.findNodeResources();
    m_easyMockUtils.verifyAll();
    
    assertNotNull("resource list should not be null", resources);
    assertEquals("resource list size", 1, resources.size());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:21,代码来源:DefaultResourceDaoTest.java

示例5: testFindNodeResourcesWithNodeInterface

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public void testFindNodeResourcesWithNodeInterface() throws Exception {
    List<OnmsNode> nodes = new LinkedList<OnmsNode>();
    OnmsNode node = createNode();
    OnmsIpInterface ip = createIpInterface();
    node.addIpInterface(ip);
    nodes.add(node);
    
    expect(m_nodeDao.findAll()).andReturn(nodes);

    File snmp = m_fileAnticipator.tempDir("snmp");
    File nodeDir = m_fileAnticipator.tempDir(snmp, "1");
    File intfDir = m_fileAnticipator.tempDir(nodeDir, "eth0");
    m_fileAnticipator.tempFile(intfDir, "foo" + RrdUtils.getExtension());
    
    m_easyMockUtils.replayAll();
    List<OnmsResource> resources = m_resourceDao.findNodeResources();
    m_easyMockUtils.verifyAll();
    
    assertNotNull("resource list should not be null", resources);
    assertEquals("resource list size", 1, resources.size());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:DefaultResourceDaoTest.java

示例6: testGetResourceForIpInterface

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public void testGetResourceForIpInterface() throws Exception {
    OnmsNode node = createNode();
    OnmsIpInterface ip = createIpInterface();
    node.addIpInterface(ip);
    
    File response = m_fileAnticipator.tempDir("response");
    File ipDir = m_fileAnticipator.tempDir(response, "192.168.1.1");
    m_fileAnticipator.tempFile(ipDir, "icmp" + RrdUtils.getExtension());

    expect(m_nodeDao.get(1)).andReturn(ip.getNode()).times(2);
    expect(m_locationMonitorDao.findStatusChangesForNodeForUniqueMonitorAndInterface(1)).andReturn(new ArrayList<LocationMonitorIpInterface>());
    expect(m_dataCollectionConfigDao.getLastUpdate()).andReturn(new Date(System.currentTimeMillis() - 86400000l));

    m_easyMockUtils.replayAll();
    OnmsResource resource = m_resourceDao.getResourceForIpInterface(ip);
    m_easyMockUtils.verifyAll();
    
    assertNotNull("Resource should not be null", resource);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:20,代码来源:DefaultResourceDaoTest.java

示例7: setUp

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

    // Set the primary address of Node2 as the test address.
    m_testAddress = m_databasePopulator.getNode2().getPrimaryInterface().getIpAddress();

    // Adding the test address as a secondary address (unmanaged) to Node1
    OnmsNode n1 = m_databasePopulator.getNode1();
    OnmsIpInterface iface = new OnmsIpInterface(m_testAddress.getHostAddress(), n1);
    iface.setIsManaged("U");
    iface.setIsSnmpPrimary(PrimaryType.SECONDARY);
    OnmsSnmpInterface snmpIf = new OnmsSnmpInterface(n1, 1001);
    iface.setSnmpInterface(snmpIf);
    snmpIf.getIpInterfaces().add(iface);
    n1.addIpInterface(iface);
    m_databasePopulator.getNodeDao().save(n1);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:19,代码来源:IpInterfaceDaoHibernateTest.java

示例8: setUp

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

    OnmsNode n = new OnmsNode(m_databasePopulator.getDistPollerDao().get("localhost"), "my-new-node");
    n.setForeignSource("junit");
    n.setForeignId("10001");
    OnmsIpInterface iface = new OnmsIpInterface("192.168.1.3", n);
    iface.setIsManaged("M");
    iface.setIsSnmpPrimary(PrimaryType.PRIMARY);
    OnmsSnmpInterface snmpIf = new OnmsSnmpInterface(n, 1001);
    iface.setSnmpInterface(snmpIf);
    snmpIf.getIpInterfaces().add(iface);
    n.addIpInterface(iface);
    m_databasePopulator.getNodeDao().save(n);
    m_testNodeId = n.getId();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:19,代码来源:HibernateTrapdIpMgrTest.java

示例9: addIpInterface

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * <p>addIpInterface</p>
 *
 * @param nodeCriteria a {@link java.lang.String} object.
 * @param ipInterface a {@link org.opennms.netmgt.model.OnmsIpInterface} object.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@POST
@Consumes(MediaType.APPLICATION_XML)
public Response addIpInterface(@PathParam("nodeCriteria") final String nodeCriteria, final OnmsIpInterface ipInterface) {
    writeLock();
    
    try {
        final OnmsNode node = m_nodeDao.get(nodeCriteria);
        if (node == null) {
            throw getException(Status.BAD_REQUEST, "addIpInterface: can't find node " + nodeCriteria);
        } else if (ipInterface == null) {
            throw getException(Status.BAD_REQUEST, "addIpInterface: ipInterface object cannot be null");
        } else if (ipInterface.getIpAddress() == null) {
            throw getException(Status.BAD_REQUEST, "addIpInterface: ipInterface's ipAddress cannot be null");
        } else if (ipInterface.getIpAddress().getAddress() == null) {
            throw getException(Status.BAD_REQUEST, "addIpInterface: ipInterface's ipAddress bytes cannot be null");
        }
        LogUtils.debugf(this, "addIpInterface: adding interface %s", ipInterface);
        node.addIpInterface(ipInterface);
        m_ipInterfaceDao.save(ipInterface);
        
        final EventBuilder bldr = new EventBuilder(EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI, getClass().getName());

        bldr.setNodeid(node.getId());
        bldr.setInterface(ipInterface.getIpAddress());

        try {
            m_eventProxy.send(bldr.getEvent());
        } catch (final EventProxyException ex) {
            throw getException(Status.BAD_REQUEST, ex.getMessage());
        }
        return Response.seeOther(getRedirectUri(m_uriInfo, InetAddressUtils.str(ipInterface.getIpAddress()))).build();
    } finally {
        writeUnlock();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:43,代码来源:OnmsIpInterfaceResource.java

示例10: createAgent

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
protected void createAgent(int ifIndex, PrimaryType ifCollType) {
    m_node = new OnmsNode();
    m_node.setSysObjectId(".1.2.3.4.5.6.7");
    
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(m_node, ifIndex);

	m_iface = new OnmsIpInterface();
    m_iface.setId(123);
    m_iface.setIpAddress(myLocalHost());
	m_iface.setIsSnmpPrimary(ifCollType);
	m_iface.setSnmpInterface(snmpIface);
	m_node.addIpInterface(m_iface);
    

	EasyMock.expect(m_ifaceDao.load(m_iface.getId())).andReturn(m_iface).anyTimes();
    
    m_easyMockUtils.replayAll();
    
    m_agent = DefaultCollectionAgent.create(m_iface.getId(), m_ifaceDao, new MockPlatformTransactionManager());
    
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:SnmpCollectorTestCase.java


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