Search in sources :

Example 1 with MibObj

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;
}
Also used : HwExtension(org.opennms.netmgt.config.hardware.HwExtension) MibObj(org.opennms.netmgt.config.hardware.MibObj) HashSet(java.util.HashSet)

Example 2 with MibObj

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);
            }
        }
    }
}
Also used : HwExtension(org.opennms.netmgt.config.hardware.HwExtension) MibObj(org.opennms.netmgt.config.hardware.MibObj) HwEntityAttributeType(org.opennms.netmgt.model.HwEntityAttributeType)

Aggregations

HwExtension (org.opennms.netmgt.config.hardware.HwExtension)2 MibObj (org.opennms.netmgt.config.hardware.MibObj)2 HashSet (java.util.HashSet)1 HwEntityAttributeType (org.opennms.netmgt.model.HwEntityAttributeType)1