use of org.opennms.netmgt.config.hardware.MibObj in project opennms by OpenNMS.
the class DefaultSnmpHwInventoryAdapterConfigDao method translateConfig.
/* (non-Javadoc)
* @see org.opennms.core.xml.AbstractJaxbConfigDao#translateConfig(java.lang.Object)
*/
@Override
protected HwInventoryAdapterConfiguration translateConfig(HwInventoryAdapterConfiguration config) {
final Set<String> oids = new HashSet<String>();
final Set<String> names = new HashSet<String>();
for (HwExtension ext : config.getExtensions()) {
for (Iterator<MibObj> it = ext.getMibObjects().iterator(); it.hasNext(); ) {
MibObj obj = it.next();
final String oid = obj.getOid().toString();
if (oids.contains(oid)) {
LOG.warn("Duplicate OID detected, ignoring {} (please fix the configuration file)", obj);
it.remove();
continue;
} else {
oids.add(oid);
}
if (names.contains(obj.getAlias())) {
LOG.warn("Duplicate Alias detected, ignoring {} (please fix the configuration file)", obj);
it.remove();
continue;
} else {
names.add(obj.getAlias());
}
}
}
return config;
}
use of org.opennms.netmgt.config.hardware.MibObj in project opennms by OpenNMS.
the class SnmpHardwareInventoryProvisioningAdapter method initializeVendorAttributes.
/**
* Initialize vendor attributes.
*/
private void initializeVendorAttributes() {
m_vendorAttributes.clear();
for (HwEntityAttributeType type : m_hwEntityAttributeTypeDao.findAll()) {
LOG.debug("Loading attribute type {}", type);
m_vendorAttributes.put(type.getSnmpObjId(), type);
}
for (HwExtension ext : m_hwInventoryAdapterConfigDao.getConfiguration().getExtensions()) {
for (MibObj obj : ext.getMibObjects()) {
HwEntityAttributeType type = m_vendorAttributes.get(obj.getOid());
if (type == null) {
type = new HwEntityAttributeType(obj.getOid().toString(), obj.getAlias(), obj.getType());
LOG.info("Creating attribute type {}", type);
m_hwEntityAttributeTypeDao.save(type);
m_vendorAttributes.put(type.getSnmpObjId(), type);
}
}
}
}
Aggregations