diff --git a/core/web-assets/src/main/assets/js/apps/onms-requisitions/lib/scripts/services/Requisitions.js b/core/web-assets/src/main/assets/js/apps/onms-requisitions/lib/scripts/services/Requisitions.js
index 63dc90a44fa0..aa6832c40439 100644
--- a/core/web-assets/src/main/assets/js/apps/onms-requisitions/lib/scripts/services/Requisitions.js
+++ b/core/web-assets/src/main/assets/js/apps/onms-requisitions/lib/scripts/services/Requisitions.js
@@ -48,10 +48,10 @@ const RequisitionNode = require('../model/RequisitionNode');
*
* @description The RequisitionsService provides all the required methods to access ReST API for the OpenNMS requisitions.
*
- * It uses Angular's Cache service to store localy all the requisitions after retrieving them from the server the first time.
+ * It uses Angular's Cache service to store locally all the requisitions after retrieving them from the server the first time.
* This helps in terms of performance and responsiveness of the UI. Only changes are pushed back to the server.
*
- * Conflicts may accour if someone else is changing the requisitions at the same time.
+ * Conflicts may occur if someone else is changing the requisitions at the same time.
*
* If the cache is not going to be used, the controllers are responsible for maintaining the state of the data.
*/
@@ -74,7 +74,7 @@ const RequisitionNode = require('../model/RequisitionNode');
requisitionsService.internal.foreignSourcesUrl = 'rest/foreignSources';
requisitionsService.internal.foreignSourcesConfigUrl = 'rest/foreignSourcesConfig';
requisitionsService.internal.monitoringLocationsUrl = 'rest/monitoringLocations';
- requisitionsService.internal.snmpConfigUrl = 'rest/snmpConfig';
+ requisitionsService.internal.snmpConfigUrl = 'api/v2/snmp-config';
requisitionsService.internal.errorHelp = ' Check the OpenNMS logs for more details, or try again later.';
requisitionsService.internal.excludedRequisitionNames = ['selfmonitor', 'minions'];
@@ -1428,9 +1428,10 @@ const RequisitionNode = require('../model/RequisitionNode');
requisitionsService.updateSnmpCommunity = function(ipAddress, snmpCommunity, snmpVersion) {
const deferred = $q.defer();
- const url = requisitionsService.internal.snmpConfigUrl + '/' + ipAddress;
+ const url = requisitionsService.internal.snmpConfigUrl + '/definition';
+
$log.debug('updateSnmpCommunity: updating snmp community for ' + ipAddress);
- $http.put(url, {'readCommunity' : snmpCommunity, 'version' : snmpVersion})
+ $http.put(url, {'readCommunity': snmpCommunity, 'version': snmpVersion, 'specific': [ipAddress] })
.then(function updateSnmpCommunitySuccess() {
$log.debug('updateSnmpCommunity: updated snmp community for ' + ipAddress);
deferred.resolve(ipAddress);
diff --git a/core/web-assets/src/test/javascript/ng-requisitions/services/Requisitions.test.js b/core/web-assets/src/test/javascript/ng-requisitions/services/Requisitions.test.js
index 381ecf806aac..a25604e43070 100644
--- a/core/web-assets/src/test/javascript/ng-requisitions/services/Requisitions.test.js
+++ b/core/web-assets/src/test/javascript/ng-requisitions/services/Requisitions.test.js
@@ -1002,8 +1002,8 @@ test('Service: RequisitionsService: deleteForeignSourceDefinition', function() {
test('Service: RequisitionsService: updateSnmpCommunity', function() {
console.log('Running tests for updateSnmpCommunity');
- var url = requisitionsService.internal.snmpConfigUrl + '/192.168.1.1';
- $httpBackend.expect('PUT', url, {'readCommunity' : 'my_community', 'version' : 'v2c'}).respond();
+ var url = requisitionsService.internal.snmpConfigUrl + '/definition';
+ $httpBackend.expect('PUT', url, {'readCommunity': 'my_community', 'version': 'v2c', 'specific': ['192.168.1.1']}).respond();
return runDigest(requisitionsService.updateSnmpCommunity('192.168.1.1', 'my_community', 'v2c')).then(function(ip) {
return expect(ip).toBe('192.168.1.1');
@@ -1044,10 +1044,12 @@ test('Service: RequisitionsService: quickAddNode', function() {
quickNode.snmpCommunity = 'my_community';
var node = quickNode.createRequisitionedNode().getOnmsRequisitionNode();
- var updateSnmpUrl = requisitionsService.internal.snmpConfigUrl + '/' + quickNode.ipAddress;
- $httpBackend.expect('PUT', updateSnmpUrl, {'readCommunity' : quickNode.snmpCommunity, 'version' : quickNode.snmpVersion}).respond();
+ var updateSnmpUrl = requisitionsService.internal.snmpConfigUrl + '/definition';
+ $httpBackend.expect('PUT', updateSnmpUrl, {'readCommunity' : quickNode.snmpCommunity, 'version' : quickNode.snmpVersion, 'specific': [quickNode.ipAddress]}).respond();
+
var saveUrl = requisitionsService.internal.requisitionsUrl + '/' + quickNode.foreignSource + '/nodes';
$httpBackend.expect('POST', saveUrl, node).respond({});
+
var importUrl = requisitionsService.internal.requisitionsUrl + '/' + quickNode.foreignSource + '/import?rescanExisting=false';
$httpBackend.expect('PUT', importUrl).respond({});
diff --git a/docs/modules/development/pages/rest/snmp_configuration_legacy.adoc b/docs/modules/development/pages/rest/snmp_configuration_legacy.adoc
index 67350a4ca653..42a3bc574051 100644
--- a/docs/modules/development/pages/rest/snmp_configuration_legacy.adoc
+++ b/docs/modules/development/pages/rest/snmp_configuration_legacy.adoc
@@ -1,9 +1,9 @@
-= SNMP Configuration (Legacy)
+= SNMP Configuration (Legacy / Deprecated API)
NOTE: {page-component-title} has been updated to move SNMP Configuration into the database.
-Please see xref:development:rest/snmp_configuration.adoc[SNMP Configuration] for the new REST API.
-Generally speaking you should avoid this API and use the new API instead, but if you have a use case that requires the legacy API, this page describes how to use it.
+Please see xref:development:rest/snmp_configuration.adoc[SNMP Configuration] for the new REST API (`api/v2/snmp-config`).
+The legacy API (`rest/snmpConfig`) has been deprecated and will be removed in a future release, and generally speaking you should avoid it and use the new API instead, but if you have a use case that requires the legacy API, this page describes how to use it.
Use this interface to edit the community string, SNMP version, etc. for an IP address.
If you make a change that would overlap with an existing `snmp-config.xml`, it will automatically create groups of `
* curl -v -X GET -u admin:admin http://localhost:8980/opennms/rest/snmpConfig/10.1.1.1 *- * + * + * @deprecated This v1 SNMP Config Rest API is deprecated as it is being replaced by the new v2 Rest API. + * It will be removed in a future release. * @author Mathew Brozowski * @version $Id: $ * @since 1.8.1 @@ -96,6 +98,7 @@ @Path("snmpConfig") @Tag(name = "SnmpConfig", description = "SNMP Config API") @Transactional +@Deprecated(forRemoval = true) public class SnmpConfigRestService extends OnmsRestService { @Autowired diff --git a/opennms-webapp-rest/src/test/java/org/opennms/web/rest/v1/SnmpConfigRestServiceIT.java b/opennms-webapp-rest/src/test/java/org/opennms/web/rest/v1/SnmpConfigRestServiceIT.java index 94fcc08ca968..31b64092e14d 100644 --- a/opennms-webapp-rest/src/test/java/org/opennms/web/rest/v1/SnmpConfigRestServiceIT.java +++ b/opennms-webapp-rest/src/test/java/org/opennms/web/rest/v1/SnmpConfigRestServiceIT.java @@ -49,6 +49,9 @@ /** * TODO * 1. Need to figure it out how to create a Mock for EventProxy to validate events sent by RESTful service + * + * @deprecated This class is deprecated and will be removed in a future release. + * This is used by the v1 SNMP Rest API, which is being replaced by the new v2 SNMP Rest API. */ @RunWith(OpenNMSJUnit4ClassRunner.class) @WebAppConfiguration @@ -68,6 +71,7 @@ }) @JUnitConfigurationEnvironment(systemProperties = "org.opennms.timeseries.strategy=integration") @JUnitTemporaryDatabase +// TODO: Remove when v1 SNMP API is removed (Horizon 37) public class SnmpConfigRestServiceIT extends AbstractSpringJerseyRestTestCase { private static final int DEFAULT_PORT = 9161; diff --git a/opennms-webapp/src/main/webapp/WEB-INF/applicationContext-spring-security.xml b/opennms-webapp/src/main/webapp/WEB-INF/applicationContext-spring-security.xml index 0b6417a24dc4..912baea61d62 100644 --- a/opennms-webapp/src/main/webapp/WEB-INF/applicationContext-spring-security.xml +++ b/opennms-webapp/src/main/webapp/WEB-INF/applicationContext-spring-security.xml @@ -69,7 +69,11 @@