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();
}
}
Aggregations