Search in sources :

Example 46 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class NodeInfoPanelItemProvider method createComponent.

private Component createComponent(AbstractVertex ref) {
    Preconditions.checkState(ref.getNodeID() != null, "no Node ID defined.");
    OnmsNode node = nodeDao.get(ref.getNodeID());
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);
    formLayout.setMargin(false);
    formLayout.addComponent(createLabel("Node ID", "" + node.getId()));
    final HorizontalLayout nodeButtonLayout = new HorizontalLayout();
    Button nodeButton = createButton(node.getLabel(), null, null, event -> new NodeInfoWindow(ref.getNodeID()).open());
    nodeButton.setStyleName(BaseTheme.BUTTON_LINK);
    nodeButtonLayout.addComponent(nodeButton);
    nodeButtonLayout.setCaption("Node Label");
    formLayout.addComponent(nodeButtonLayout);
    if (!Strings.isNullOrEmpty(node.getSysObjectId())) {
        formLayout.addComponent(createLabel("Enterprise OID", node.getSysObjectId()));
    }
    return formLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) OnmsNode(org.opennms.netmgt.model.OnmsNode) Button(com.vaadin.ui.Button) UIHelper.createButton(org.opennms.netmgt.vaadin.core.UIHelper.createButton) NodeInfoWindow(org.opennms.features.topology.app.internal.ui.NodeInfoWindow) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 47 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class OpenlayersWidgetCompontentTest method testGeolocation.

@Test
@Ignore
public void testGeolocation() throws Exception {
    final OnmsNode node = new OnmsNode();
    final OnmsAssetRecord asset = new OnmsAssetRecord();
    final OnmsGeolocation geo = new OnmsGeolocation();
    node.setId(1);
    node.setAssetRecord(asset);
    asset.setGeolocation(geo);
    geo.setAddress1("220 Chatham Business Dr.");
    geo.setCity("Pittsboro");
    geo.setState("NC");
    geo.setZip("27312");
    assertEquals("220 Chatham Business Dr., Pittsboro, NC 27312", geo.asAddressString());
    EasyMock.expect(m_geocoder.getCoordinates(geo.asAddressString())).andReturn(new Coordinates(-1.0f, 1.0f)).times(1);
    final PaintTarget target = EasyMock.createMock(PaintTarget.class);
    m_assetDao.saveOrUpdate(EasyMock.isA(OnmsAssetRecord.class));
    target.startTag(EasyMock.eq("1"));
    target.addAttribute(EasyMock.eq("longitude"), EasyMock.eq("-1.0"));
    target.addAttribute(EasyMock.eq("latitude"), EasyMock.eq("1.0"));
    target.endTag(EasyMock.eq("1"));
    EasyMock.replay(m_nodeDao, m_assetDao, m_geocoder, target);
    // m_component.paintNode(target, node);
    EasyMock.verify(m_nodeDao, m_assetDao, m_geocoder, target);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsAssetRecord(org.opennms.netmgt.model.OnmsAssetRecord) Coordinates(org.opennms.features.geocoder.Coordinates) PaintTarget(com.vaadin.server.PaintTarget) OnmsGeolocation(org.opennms.netmgt.model.OnmsGeolocation) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 48 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class VacuumdIT method setUp.

@Before
public void setUp() throws Exception {
    m_network.createStandardNetwork();
    InputStream is = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/vacuumd/vacuumd-configuration.xml");
    try {
        VacuumdConfigFactory.setInstance(new VacuumdConfigFactory(is));
    } finally {
        IOUtils.closeQuietly(is);
    }
    m_eventdIpcMgr.setEventWriter(m_database);
    EventExpander expander = new EventExpander(new MetricRegistry());
    expander.setEventConfDao(new EmptyEventConfDao());
    m_eventdIpcMgr.setEventExpander(expander);
    Vacuumd.destroySingleton();
    m_vacuumd = Vacuumd.getSingleton();
    m_vacuumd.setEventManager(m_eventdIpcMgr);
    m_vacuumd.init();
    // Insert some empty nodes to avoid foreign-key violations on subsequent events/alarms
    OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "default-1");
    node.setId(1);
    m_nodeDao.save(node);
    node = new OnmsNode(m_locationDao.getDefaultLocation(), "default-2");
    node.setId(2);
    m_nodeDao.save(node);
    m_nodeDao.flush();
    MockUtil.println("------------ Finished setup for: " + this.getClass().getName() + " --------------------------");
}
Also used : VacuumdConfigFactory(org.opennms.netmgt.config.VacuumdConfigFactory) OnmsNode(org.opennms.netmgt.model.OnmsNode) EventExpander(org.opennms.netmgt.eventd.EventExpander) InputStream(java.io.InputStream) MetricRegistry(com.codahale.metrics.MetricRegistry) EmptyEventConfDao(org.opennms.netmgt.dao.mock.MockEventIpcManager.EmptyEventConfDao) Before(org.junit.Before)

Example 49 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class MultipleImportIT method testScanTwice.

@Test
@Ignore
@JUnitSnmpAgent(host = "0.0.0.0", resource = "classpath:/snmpwalk-empty.properties")
public void testScanTwice() throws Exception {
    final String[] ueis = { EventConstants.PROVISION_SCAN_COMPLETE_UEI, EventConstants.PROVISION_SCAN_ABORTED_UEI };
    final CountDownLatch eventReceived = anticipateEvents(1, ueis);
    System.err.println("triggering first import");
    m_provisioner.importModelFromResource(m_resourceLoader.getResource("classpath:/SPC-222-a.xml"), Boolean.TRUE.toString());
    waitForEverything();
    System.err.println("triggering second import");
    m_provisioner.importModelFromResource(m_resourceLoader.getResource("classpath:/SPC-222-b.xml"), Boolean.TRUE.toString());
    waitForEverything();
    System.err.println("finished triggering imports");
    eventReceived.await(5, TimeUnit.MINUTES);
    final List<OnmsNode> nodes = getNodeDao().findAll();
    assertEquals(200, nodes.size());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) CountDownLatch(java.util.concurrent.CountDownLatch) Ignore(org.junit.Ignore) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)

Example 50 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class ProvisionerIT method testProvisionerServiceRescanAfterAddingSnmpNms7838.

// fail if we take more than five minutes
@Test(timeout = 300000)
// Start the test with an empty SNMP agent
@JUnitSnmpAgent(host = "198.51.100.201", port = 161, resource = "classpath:/snmpwalk-empty.properties")
public void testProvisionerServiceRescanAfterAddingSnmpNms7838() throws Exception {
    importFromResource("classpath:/requisition_then_scan2.xml", Boolean.TRUE.toString());
    final List<OnmsNode> nodes = getNodeDao().findAll();
    final OnmsNode node = nodes.get(0);
    runPendingScans();
    m_nodeDao.flush();
    assertEquals(1, getInterfaceDao().countAll());
    // Make sure that the OnmsIpInterface doesn't have an ifIndex
    assertNull(getInterfaceDao().get(node, "198.51.100.201").getIfIndex());
    // Make sure that no OnmsSnmpInterface records exist for the node
    assertNull(getSnmpInterfaceDao().findByNodeIdAndIfIndex(node.getId(), 4));
    assertNull(getSnmpInterfaceDao().findByNodeIdAndIfIndex(node.getId(), 5));
    LOG.info("******************** ADDING SNMP DATA ********************");
    // Add some SNMP data to the agent
    m_mockSnmpDataProvider.setDataForAddress(new SnmpAgentAddress(addr("198.51.100.201"), 161), new DefaultResourceLoader().getResource("classpath:/snmpTestData3.properties"));
    // Rescan
    m_mockEventIpcManager.sendEventToListeners(nodeUpdated(node.getId()));
    runPendingScans();
    m_nodeDao.flush();
    // Make sure that a second interface was added from the SNMP agent data
    assertEquals(2, getInterfaceDao().countAll());
    // Verify the ifIndex entries
    assertEquals(5, getInterfaceDao().get(node, "198.51.100.201").getIfIndex().intValue());
    assertEquals(5, getInterfaceDao().get(node, "198.51.100.201").getSnmpInterface().getIfIndex().intValue());
    assertEquals(4, getInterfaceDao().get(node, "198.51.100.204").getIfIndex().intValue());
    assertEquals(4, getInterfaceDao().get(node, "198.51.100.204").getSnmpInterface().getIfIndex().intValue());
}
Also used : SnmpAgentAddress(org.opennms.netmgt.snmp.SnmpAgentAddress) OnmsNode(org.opennms.netmgt.model.OnmsNode) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)

Aggregations

OnmsNode (org.opennms.netmgt.model.OnmsNode)496 Test (org.junit.Test)209 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)116 Transactional (org.springframework.transaction.annotation.Transactional)84 ArrayList (java.util.ArrayList)52 Date (java.util.Date)49 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)38 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)38 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)38 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)37 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)36 InetAddress (java.net.InetAddress)35 Before (org.junit.Before)32 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)31 OnmsResource (org.opennms.netmgt.model.OnmsResource)28 HashMap (java.util.HashMap)27 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)26 File (java.io.File)25 List (java.util.List)25 Path (javax.ws.rs.Path)23