Add a way to use the IP address when building criteria selections for the SNMP interfaces on the SNMP Poller's configuration file.
Description
In 1.8, it was possible to make a criteria selection using the IP address because there was a field called ipaddr on the snmpinterface table.
In 1.10, that field was removed from the snmpinterface table, and any existing criteria that uses this field will be broken and there is no way to fix it without code changes.
The idea is to replace the criteria builder on the SNMP Poller code, to be able to access the IP address field through the ipinterface table, by joining it with the snmpinterface table.
The problem is that the current code is based on a SQL Restriction. So, in order to use a HQL based JOIN, on a SQL world, is using the alias automatically generated by Hibernate for the joined tables, which is not elegant but works. Of course if the criteria code is changed on the future, the alias might change. For this reason, it is important to add a JUnit test to verify a sample criteria with the IP address in order to be able to prevent failures in the future.
This feature is related with a customer support ticket 1717.
Acceptance / Success Criteria
None
Lucidchart Diagrams
Activity
Show:
Alejandro Galue December 18, 2012 at 2:02 PM
The fix has been merged into master on revision 66b00c861b3cb8dfc04daed4d839670a1291a9dc. The code was changed a little bit in order to be compatible with 1.11.x.
Alejandro Galue December 18, 2012 at 10:52 AM
Fixed on revision 5e9c3407b222a431458ef932ac61413ebaa127ef for 1.10. The fix contains a JUnit test that verify that all the new criterias using the CriteriaBuilder works as expected.
Of course, this code just adds a new feature, and must be taken in consideration on all those installations of OpenNMS that must be migrated from 1.8 to 1.10 and requires the usage of the IP address on the SNMP Poller configuration file.
Also, this implies the usage of useCriteriaFilters="true" as explained on .
Alejandro Galue December 18, 2012 at 10:46 AM
The code change is really simple, and here is a sample criteria that uses an IP address:
Note the way to access the IP address field. The tag "ipinterfac1_" is the alias automatically generated by hibernate when adding defining a JOIN Criteria between the snmpinterface table and the ipinterface table.
Here is the important section of the code for org.opennms.netmgt.snmpinterfacepoller.DefaultPollContext, on which the criteria processing is done.
In 1.8, it was possible to make a criteria selection using the IP address because there was a field called ipaddr on the snmpinterface table.
In 1.10, that field was removed from the snmpinterface table, and any existing criteria that uses this field will be broken and there is no way to fix it without code changes.
The idea is to replace the criteria builder on the SNMP Poller code, to be able to access the IP address field through the ipinterface table, by joining it with the snmpinterface table.
The problem is that the current code is based on a SQL Restriction. So, in order to use a HQL based JOIN, on a SQL world, is using the alias automatically generated by Hibernate for the joined tables, which is not elegant but works. Of course if the criteria code is changed on the future, the alias might change. For this reason, it is important to add a JUnit test to verify a sample criteria with the IP address in order to be able to prevent failures in the future.
This feature is related with a customer support ticket 1717.