4.0

Table Of Contents
Define and Publish Events to Orchestrator
The IPluginEventPublisher interface allows you to publish to the Orchestrator policy engine events that you
define in the plug-in that occur in the plugged-in technology.
You can use the methods of the IPluginEventPublisher interface to set gauges and triggers that Orchestrator
policies monitor.
The SolarSystemEventGenerator class defines a method that generates solar flares of a given magnitude on
Star objects in the solar system application. By implementing a method to create solar flares in the solar system
plug-in, the plug-in adds a function that does not exist in the solar system application. The
generateFlareEvent() method that the plug-in defines registers a policy gauge with the Orchestrator policy
engine. An Orchestrator policy can watch this gauge for solar flares that exceed a certain magnitude.
Prerequisites
n
Set up the event generator class to create event generator instances.
n
Create instances of the IPluginEventPublisher interface.
Procedure
1 Create functions that define event listeners and the events that the event listeners monitor.
The SolarSystemEventGenerator class declares an interface from which to create listener instances, and
adds a method to the interface to create flare events of a certain magnitude on a given Star object.
public interface StarFlareEventListener{
void starFlareEvent(String starid, double magnitude);
}
2 Create listener instances to listen for the events that the plug-in defines.
The SolarSystemEventGenerator instantiates the StarFlareEventListener interface to create a listener
named starFlareEventListener.
private StarFlareEventListener starFlareEventListener;
3 Create functions to generate events in the plugged-in technology.
The SolarSystemEventGenerator defines the generateFlareEvent() method that takes an object type,
identifier, and a magnitude value as parameters. The method writes in the logs that the plug-in generated
a flare event on a given object.
public void generateFlareEvent(String sdkType, String id, double magnitude) {
String key = sdkType + "' / '" + id;
log.info("Generate Flare Event for : '" + key + "'");
}
4 Register the objects to monitor with
IPluginEventPublisher
instances.
The SolarSystemEventGenerator.generateFlareEvent() method adds IPluginEventPublisher instances
for each object to the policyElements hashtable of publishers that the SolarSystemEventGenerator class
creates.
public void generateFlareEvent(String sdkType, String id, double magnitude) {
String key = sdkType + "' / '" + id;
log.info("Generate Flare Event for : '" + key + "'");
Vector<IPluginEventPublisher> publishers = policyElements.get(key);
}
vCenter Orchestrator Developer's Guide
174 VMware, Inc.