EPI Script in BSM/OMi 9.26 for SetAssignedGroup

Hi! I'd like to try to get a EPI scrript that would do two things:

  1. Set a Custom Attribute of a particular value
  2. Assign the Event inside the OMI Dashboard to the same value

I can get the CA value entered, but I'm trying to see how I can get the Assigned Group in. I'm a little stumped on how I might be able to either get the AssignedGroupID value to use, or use the OprEvent method to set it. 

Here's my current sample code:

import java.io.File;
import java.util.List;
import com.hp.opr.api.scripting.Event;
import com.hp.opr.api.scripting.Severity;
import com.hp.opr.api.scripting.Priority;
import com.hp.opr.api.ws.model.event.OprEvent;
import java.util.Date;

class GroovyScriptSkeleton
{
  def init()
  {
  }

  def destroy()
  {
  }


  def process(List<Event> events)
  {

	String priority;
	String severity;
	String eventtext;
        String eventid;

try {
	events.each {
		event -> 
			def assignedgroup = 
			severity = event.getSeverity();
			event.addCustomAttribute("Queue","QUEUENAME");
			if ( severity != "NORMAL" ) {event.addCustomAttribute("Severity",severity)}
			event.setAssignedGroup(setName("QUEUENAME"));
		}
    	}
	catch (InterruptedException e){ return; }
  }
}

 

Parents
  • Please use EPI API Java doc for correct method names and method signatures.

    First of all, getSeverity() method doesn't return String! It returns enum Severity. So your code should use something like that:

    Severity severity;
    severity = event.getSeverity();
    if (!severity.equals(Severity.NORMAL)) ...

    Next, there is no such method as setAssignedGroup(), there is setAssignedGroupId(). A simple way to figure out an internal ID of any existing group is to find an event in the event browser having this assigned group (or just pick up any event and assign it to that group) and then use Events WS to grab the ID via http://<BSM FQDN>/opr-console/rest/9.10/event_list/<event_id> (<event_id> is shown in the event browser).

  •  Dmitry,

      Thank you for the follow up, I apologize for not getting back to you sooner. Your approach of looking up the assigned group id did work. However, you can't use the method in the OPR space to look up the ID to ensure it's correct? I'm worried about the "what if it changes" scenario, to ensure that it works correctly.

    Thanks!

    Stephen Kirven

Reply
  •  Dmitry,

      Thank you for the follow up, I apologize for not getting back to you sooner. Your approach of looking up the assigned group id did work. However, you can't use the method in the OPR space to look up the ID to ensure it's correct? I'm worried about the "what if it changes" scenario, to ensure that it works correctly.

    Thanks!

    Stephen Kirven

Children