use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class DragonWaveNodeSwitchingIT method testASetup.
@Test
@JUnitSnmpAgents({ @JUnitSnmpAgent(host = "192.168.255.22", resource = "classpath:/dw/walks/node3-walk.properties") })
public void testASetup() throws Exception {
final int nextNodeId = m_nodeDao.getNextNodeId();
final InetAddress iface = InetAddressUtils.addr("192.168.255.22");
final EventAnticipator anticipator = m_eventSubscriber.getEventAnticipator();
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_ADDED_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(iface).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_GAINED_SERVICE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(iface).setService("SNMP").getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_GAINED_SERVICE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(iface).setService("ICMP").getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.REINITIALIZE_PRIMARY_SNMP_INTERFACE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(iface).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.PROVISION_SCAN_COMPLETE_UEI, "Provisiond").setNodeid(nextNodeId).getEvent());
importResource("classpath:/dw/import/dw_test_import.xml");
anticipator.verifyAnticipated(200000, 0, 0, 0, 0);
final OnmsNode onmsNode = m_nodeDao.findAll().get(0);
assertEquals(".1.3.6.1.4.1.7262.1", onmsNode.getSysObjectId());
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class DefaultPollingContext method createApStatusEvent.
protected Event createApStatusEvent(String physAddr, Integer nodeId, String status) {
final List<Parm> parms = new ArrayList<Parm>();
OnmsNode node = getNodeDao().get(nodeId);
parms.add(buildParm(EventConstants.PARM_PASSIVE_IPADDR, getNodeIpAddress(node).getHostAddress()));
parms.add(buildParm(EventConstants.PARM_PASSIVE_NODE_LABEL, node.getLabel()));
parms.add(buildParm(EventConstants.PARM_PASSIVE_SERVICE_NAME, getPackage().getEffectiveService().getPassiveServiceName()));
parms.add(buildParm(EventConstants.PARM_PASSIVE_SERVICE_STATUS, status));
parms.add(buildParm("physAddr", physAddr));
EventBuilder bldr = new EventBuilder(PASSIVE_STATUS_UEI, "accesspointmonitord");
bldr.setParms(parms);
return bldr.getEvent();
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class MinionHeartbeatMonitor method poll.
@Override
public PollStatus poll(final MonitoredService svc, final Map<String, Object> parameters) {
// Minions send heartbeat every 30 seconds - we check that we can skip not more than one beat
final int period = 2 * ParameterMap.getKeyedInteger(parameters, "period", 30 * 1000);
// Get the minion to test whereas the minion ID is the nodes foreign ID by convention
final OnmsNode node = nodeDao.get().get(svc.getNodeId());
final OnmsMinion minion = minionDao.get().findById(node.getForeignId());
// Calculate the time since the last heartbeat was received
final long lastSeen = System.currentTimeMillis() - minion.getLastUpdated().getTime();
final PollStatus status;
if (lastSeen <= period) {
status = PollStatus.available();
} else if (ManagementFactory.getRuntimeMXBean().getUptime() < period) {
status = PollStatus.unknown("JVM has not been started long enough to process a heartbeat.");
} else {
status = PollStatus.unavailable(String.format("Last heartbeat was %.2f seconds ago", lastSeen / 1000.0));
}
return status;
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class VmwareCollector method getRuntimeAttributes.
@Override
public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) {
final Map<String, Object> runtimeAttributes = new HashMap<>();
final OnmsNode onmsNode = m_nodeDao.get(agent.getNodeId());
if (onmsNode == null) {
throw new IllegalArgumentException(String.format("VmwareCollector: No node found with id: %d", agent.getNodeId()));
}
// retrieve the assets
final String vmwareManagementServer = onmsNode.getAssetRecord().getVmwareManagementServer();
if (Strings.isNullOrEmpty(vmwareManagementServer)) {
throw new IllegalArgumentException(String.format("VmwareCollector: No management server is set on node with id %d.", onmsNode.getId()));
}
runtimeAttributes.put(VMWARE_MGMT_SERVER_KEY, vmwareManagementServer);
final String vmwareManagedObjectId = onmsNode.getForeignId();
if (Strings.isNullOrEmpty(vmwareManagedObjectId)) {
throw new IllegalArgumentException(String.format("VmwareCollector: No foreign id is set on node with id %d.", onmsNode.getId()));
}
runtimeAttributes.put(VMWARE_MGED_OBJECT_ID_KEY, vmwareManagedObjectId);
// retrieve the collection
final String collectionName = ParameterMap.getKeyedString(parameters, "collection", ParameterMap.getKeyedString(parameters, "vmware-collection", null));
final VmwareCollection collection = m_vmwareDatacollectionConfigDao.getVmwareCollection(collectionName);
if (collection == null) {
throw new IllegalArgumentException(String.format("VmwareCollector: No collection found with name '%s'.", collectionName));
}
runtimeAttributes.put(VMWARE_COLLECTION_KEY, collection);
// retrieve the server configuration
final Map<String, VmwareServer> serverMap = m_vmwareConfigDao.getServerMap();
if (serverMap == null) {
throw new IllegalStateException(String.format("VmwareCollector: Error getting vmware-config.xml's server map."));
}
final VmwareServer vmwareServer = serverMap.get(vmwareManagementServer);
if (vmwareServer == null) {
throw new IllegalStateException(String.format("VmwareCollector: Error getting credentials for VMware management server: %s", vmwareManagementServer));
}
runtimeAttributes.put(VMWARE_SERVER_KEY, vmwareServer);
return runtimeAttributes;
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class DefaultResourceDaoTest method testGetTopLevelResourceNodeExistsNoChildResources.
@Test
public void testGetTopLevelResourceNodeExistsNoChildResources() throws Exception {
OnmsNode node = createNode(2, "Node Two");
expect(m_nodeDao.get(node.getId().toString())).andReturn(node).times(1);
m_easyMockUtils.replayAll();
OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("node", "2"));
m_easyMockUtils.verifyAll();
assertNotNull("Resource should not be null", resource);
}
Aggregations