use of org.opennms.netmgt.provision.snmp.EntityPhysicalTableTracker in project opennms by OpenNMS.
the class SnmpHardwareInventoryProvisioningAdapter method getRootEntity.
/**
* Gets the root entity.
*
* @param agentConfig the agent configuration
* @param node the node
* @return the root entity
* @throws HardwareInventoryException the hardware inventory exception
*/
private OnmsHwEntity getRootEntity(SnmpAgentConfig agentConfig, OnmsNode node) throws SnmpHardwareInventoryException {
LOG.debug("getRootEntity: Getting ENTITY-MIB using {}", agentConfig);
final List<SnmpObjId> vendorOidList = m_hwInventoryAdapterConfigDao.getConfiguration().getVendorOid(node.getSysObjectId());
final Map<String, String> replacementMap = m_hwInventoryAdapterConfigDao.getConfiguration().getReplacementMap();
final SnmpObjId[] vendorOids = vendorOidList.toArray(new SnmpObjId[vendorOidList.size()]);
final SnmpObjId[] allOids = (SnmpObjId[]) ArrayUtils.addAll(EntityPhysicalTableRow.ELEMENTS, vendorOids);
final EntityPhysicalTableTracker tracker = new EntityPhysicalTableTracker(m_vendorAttributes, allOids, replacementMap);
final String trackerName = tracker.getClass().getSimpleName() + '_' + node.getLabel();
final CompletableFuture<EntityPhysicalTableTracker> future = m_locationAwareSnmpClient.walk(agentConfig, tracker).withDescription(trackerName).withLocation(node.getLocation() != null ? node.getLocation().getLocationName() : null).execute();
try {
future.get();
} catch (ExecutionException e) {
LOG.error("Aborting entities scan for " + agentConfig, e);
throw new SnmpHardwareInventoryException("Aborting entities scan: Agent failed while scanning the " + trackerName + " table: " + e.getMessage());
} catch (final InterruptedException e) {
throw new SnmpHardwareInventoryException("ENTITY-MIB node collection interrupted, exiting");
}
OnmsHwEntity root = tracker.getRootEntity();
if (root == null) {
throw new SnmpHardwareInventoryException("Cannot get root entity for node " + node.getLabel() + ", it seems like its SNMP agent does not have an implementation for the entPhysicalTable of the ENTITY-MIB, or it has an incorrect implementation of it.");
}
return root;
}
Aggregations