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;
}
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);
}
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() + " --------------------------");
}
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());
}
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());
}
Aggregations