Skip to content

Conversation

@synqotik
Copy link
Contributor

@synqotik synqotik commented Dec 24, 2025

Rest API for SNMP Config where the config is in the DB (via CM).

Covered in this PR:

  • Get the SNMP Config
  • Lookup the SNMP config for a specific IP address
  • Add a definition for an IP address or IP address range
  • Remove a definition for a given IP address

(Note, all these also include monitoring location.)

Added integration tests. The one for addDefinition was failing locally, I will fix it subsequently (the actual Rest API is working). Wanted to get this PR merged so I can continue with the UI.

Add/remove profiles will be done separately.

External References

@synqotik synqotik changed the title NMS-19270: Rest API for SNMP Config NMS-19270: Rest API for SNMP Config, Lookup and Add/Remove Definitions Dec 24, 2025
@synqotik synqotik force-pushed the jira/NMS-19270-rest-get-snmp-config branch from 587cb76 to c3a58c8 Compare December 24, 2025 19:15
@synqotik synqotik marked this pull request as ready for review December 24, 2025 19:18
}

// If a non-default location was specified, check if it is a valid monitoring location
final List<OnmsMonitoringLocation> locationList = monitoringLocationDao.findAll();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use monitoringLocationDao.get here.

private String convertToValidLocation(String location) {
final boolean isDefaultLocation = Strings.isNullOrEmpty(location) || location.equalsIgnoreCase(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);

if (isDefaultLocation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (isDefaultLocation) {
if (MonitoringLocationUtils.isDefaultLocationName(location)) {

Comment on lines +247 to +248
} catch (Exception ignored) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} catch (Exception ignored) {
}
} catch (Exception ignored) {
LOG.debug("Invalid IP address: {}", ipAddress, e);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants