Search in sources :

Example 1 with AddressSnmpConfigVisitor

use of org.opennms.netmgt.config.snmp.AddressSnmpConfigVisitor in project opennms by OpenNMS.

the class SnmpPeerFactory method getAgentConfig.

public SnmpAgentConfig getAgentConfig(final InetAddress agentInetAddress, String location, final int requestedSnmpVersion) {
    getReadLock().lock();
    try {
        if (getSnmpConfig() == null) {
            final SnmpAgentConfig agentConfig = new SnmpAgentConfig(agentInetAddress);
            if (requestedSnmpVersion == SnmpAgentConfig.VERSION_UNSPECIFIED) {
                agentConfig.setVersion(SnmpAgentConfig.DEFAULT_VERSION);
            } else {
                agentConfig.setVersion(requestedSnmpVersion);
            }
            return agentConfig;
        }
        final SnmpAgentConfig agentConfig = new SnmpAgentConfig(agentInetAddress);
        // Now set the defaults from the getSnmpConfig()
        setSnmpAgentConfig(agentConfig, new Definition(), requestedSnmpVersion);
        final AddressSnmpConfigVisitor visitor = new AddressSnmpConfigVisitor(agentInetAddress, location);
        getSnmpConfig().visit(visitor);
        final Definition matchingDef = visitor.getDefinition();
        if (matchingDef != null) {
            setSnmpAgentConfig(agentConfig, matchingDef, requestedSnmpVersion);
        }
        return agentConfig;
    } finally {
        getReadLock().unlock();
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) AddressSnmpConfigVisitor(org.opennms.netmgt.config.snmp.AddressSnmpConfigVisitor) Definition(org.opennms.netmgt.config.snmp.Definition)

Aggregations

AddressSnmpConfigVisitor (org.opennms.netmgt.config.snmp.AddressSnmpConfigVisitor)1 Definition (org.opennms.netmgt.config.snmp.Definition)1 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1