Add the ability to apply the SiblingColumnStorageStrategy to resource's instance

Description

The current implementation of the SiblingColumnStorageStrategy requires to put the alias of any MibObj defined as string, for the required parameter named sibling-column-name. And that's the only valid element you can currently use for sibling-column-name.

In some circumstances it could be very useful to apply the regular expression to the resource's instance.

For example, suppose that the resource instance is something like the following:

0.132.43.51.76.89.2.144.10.1.1.1

That combines, the Mac Address and the IP address. The first 8 elements conforms the Mac Address and the last 4 elements conforms the IP address. Because the IP address might change, we want to use the Mac as the resource's identifier, in order to use only the Mac as the resource's folder; for example:

/opt/opennms/share/rrd/snmp/1/myResourceType/0.132.43.51.76.89.2.144/my-rrd.jrb
a
Instead of:

/opt/opennms/share/rrd/snmp/1/myResourceType/0.132.43.51.76.89.2.144.10.1.1.1/my-rrd.jrb

In order to do so, some changes are required in the current code of the SiblingColumnStorageStrategy.

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

Alejandro Galue May 2, 2012 at 1:44 PM

I've just discovered that if you put an invalid content (but not null) for sibling-column-name, the returned value will be the default, and the default is the resource's instance.

So, in order to solve the problem, described on this issue, you can configure the strategy to be something like this:

<storageStrategy class="org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy"> <parameter key="sibling-column-name" value="_index" /> <parameter key="replace-first" value="s/^(([\d]{1,3}\.){8,8}).*$/$1/" /> <parameter key="replace-first" value="s/\.$//" /> </storageStrategy>

I've added a JUnit test to validate the solution on revision a0e706837569ebf06d8410c86be3531a335186a7.

Won't Fix

Details

Assignee

Reporter

Labels

Fix versions

Affects versions

Priority

PagerDuty

Created May 2, 2012 at 1:30 PM
Updated January 27, 2017 at 4:20 PM
Resolved May 2, 2012 at 1:44 PM

Flag notifications