Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Regular Contributor.. T-G Regular Contributor..
Regular Contributor..
155 views

Get relatedCiHint in groovy script.

Jump to solution

Hello,

I am writing a groovy script that logs event data into a structured logfile.
This script will be part of an OBM Conencted Server scenario.

One of the attributes I want to process is the Related CI Hint in the event.

I use the following code to read the event data (excerpt):

import com.hp.opr.api.ws.adapter.ForwardEventArgs;
import com.hp.opr.api.ws.model.event.OprEvent;
import com.hp.opr.api.ws.model.event.ci.OprRelatedCiHints
[...]
Boolean forwardEvent(final ForwardEventArgs args)
{
OprEvent event = args.event
String m_cihint = event.relatedCiHint
[...]
}
[...]

With command line tool sendEvent I create test events, e.g.
sendEvent.bat -t "This is a test." -c Log2File -rch server.domain.com -nd server.domain.com

However, at execution time of the script the varibale "m_cihint" does not contain "server.domain.com" but "com.hp.opr.api.ws.model.event.ci.OprRelatedCiHints@65f6e290". OMI resolves the ci hint "server.domain.com" correctly in the event browser.

Any ideas?
Thanks in advance.

Thomas

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Get relatedCiHint in groovy script.

Jump to solution

Please check API docs. 

event.relatedCiHint is NOT supposed to return String as you expect, but an object of class OprRelatedCiHints. So you may try something like String m_cihint = event.relatedCiHint.hint (or maybe event.relatedCiHint.Hint - not sure about the exact syntax, please check the docs).

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Get relatedCiHint in groovy script.

Jump to solution

Please check API docs. 

event.relatedCiHint is NOT supposed to return String as you expect, but an object of class OprRelatedCiHints. So you may try something like String m_cihint = event.relatedCiHint.hint (or maybe event.relatedCiHint.Hint - not sure about the exact syntax, please check the docs).

0 Likes
Acclaimed Contributor.. Harald Acclaimed Contributor..
Acclaimed Contributor..

Re: Get relatedCiHint in groovy script.

Jump to solution

Other than the EPC (Event Processing Customization)  the Scripting Host returns you the relatedCI as Object

Means:

OprRelatedCi oprRelatedCI = event.getRelatedCi();
OprConfigurationItem relatedCI = oprRelatedCI.getConfigurationItem();
String strID = relatedCI.getId()

With this ID you can query the RTSM for the attributes you want......

In addition try the sample from the sampleLogFileAdapter:

 

logRelatedCI(event.relatedCi)

 

def logRelatedCI(def relatedCi)
{
if (relatedCi == null || relatedCi.configurationItem == null)
return

OprConfigurationItem ci = relatedCi.configurationItem
Map<String, Object> properties = ci.properties
if (properties == null || properties.isEmpty())
return

appendLogfile("\tRelated CI: ${ci.id}")
for (String name : properties.keySet())
{
def value = properties.get(name);
appendLogfile("\n\t\t${name}=${value.toString()}")
}
}

0 Likes
Regular Contributor.. T-G Regular Contributor..
Regular Contributor..

Re: Get relatedCiHint in groovy script.

Jump to solution

Hi Dimitry,

String m_cihint =event.relatedCiHint.hint

returns the expected string (server.domain.com).
Thanks for your quick response.

Regards
Thomas

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.