Working with Smarts

Table of Contents

Setting up RapidCMDB to work with Smarts

RapidCMDB talks to external systems via custom datasources. In order to enable Smarts integration for RapidCMDB:

  • Download the Smarts module  from the downloads page (make sure that the module version is in sync with the RapidCMDB version - both stable or both nightly)
  • After unzipping into RS_HOME (.../RapidServer), copy Smarts API libraries (skclient.jar and net.jar) from your EMC Smarts distribution into the RS_HOME/RapidCMDB/lib directory and restart RapidCMDB

See the Getting Started Document to see how RapidCMDB is strated.

Ad-hoc Integration with Smarts

Typically you would start with modeling your managed classes. Some of your managed classes will retrieve the values of its properties (some or all properties) from Smarts server or will perform actions on the Smarts server. In order to accomplish this, modeled class operations will use Smarts datasources underneath. However, nothing prevents you use Smarts datasources directly in your scripts for some ad-hoc integration needs. Here are the bare minimums to talk to a Smarts server from RapidCMDB...

Define Smarts Connections and Datasources

Go to the RapidCMDB admin UI  (http://....../RapidCMDB/) to define one or more Smarts connections. Each connection will be for a different server. One connection can be shared by multiple datasources. A datasource also defines the reconnection behavior if the connection is lost during or in between the script executions. See Advanced Topics Document for more information on reconnection to external systems.

Create a Script to Retrieve Data from Smarts

We give a special name to scripts whose purpose is to retrieve data from external systems: Connectors. For Smarts, you can create either a polling connector (by defining a scheduled script) which would periodically poll the server and retrieve data into RapidCMDB or  a listening connector (by defining a listening script) which would subscribe itself to Smarts server to receive update calls from the server as changes happen.

The best source of information for the datasource operations are the datasource implementation scripts (SmartsNotificationDatasource and SmartsTopologyDatasource in the RapidServer\RapidCMDB\grails-app\domain\datasource folder). Also, see Basic Model Operations document for details on how to work with instances of Datasources.

Define a Polling Script (Connector)

Add a scheduled script, set its schedule type to Periodic and give it a period of, say, 30 secs. This setting will run the script every 30 seconds. Script Name should point to your script file (i.e. myPollingConnector.groovy) in the RapidCMDB/scripts directory.

Implement the Polling Connector

Here is a sample script, retrieving and updating notifications and topology data on a Smarts server:

myPollingConnector.groovy

// this is how you get references to already created 2 Smarts datasources
def samNotifDs = SmartsNotificationDatasource.get(name:"samNotification")
def samTopoDs = SmartsTopologyDatasource.get(name:"samTopology")

// retrieving the value of the "SystemName" property of a topology object
def localDeviceName = samTopoDs.getProperty(["CreationClassName":"IP", "Name":"InstanceNameIP"], "SystemName")

// retrieving the values of multiple properties of a topology object
def peribitProps = samTopoDs.getProperties(["CreationClassName":"PeribitSession", "Name":peribitTunnelName], ["Prop1", "Prop2", "Prop3"]);

// getting an instance of a topology object
def tunnelObj = samTopoDs.getObject(["CreationClassName":"IPSecTunnel", "Name":"IPSecTunnelInstance"])

// creating a notification
def notifyParams = [EventName:"Down", ClassName:"IPSecTunnel", InstanceName:"IPSecTunnelInstance", Severity:"1"]
notifyParams.EventText = "Primary IPSec Tunnel IPSecTunnelInstance is Down"
samNotifDs.addNotification(notifyParams)

// clearing a notification
samNotifDs.clearNotification(["ClassName":"IPSecTunnel", "InstanceName":"IPSecTunnelInstance" , "EventName":"Down"])

Define a Listening Script (Connector)

Add a listening script and select the corresponding Smarts datasource you have created. Script Name should point to your script file (i.e. myListeningConnector.groovy) in the RapidCMDB/scripts directory.

Implement the Listening Connector 

Listening scripts are special scripts that are registered with the external system via the RapidCMDB listening datasource framework Therefore, they need to implement some methods so that they can interact properly with the framework.

The 4 methods that each listening script must implement are: 

  • getParameters(): any configuration parameters that define how the subscription to the external system must be set up are returned in a property map
  • init(): any itialization work that must be done before subscription starts
  • cleanUp(): any finalization after the subscription is ended
  • update(Map myNotification): this method will be called by the RapidCMDB framework as the external system notifies RapidCMDB of any changes to the system. You will access the properties of the passed in notification in the form of a map object and implement your logic.

myListeningConnector.groovy

// We will be subscribing to 9 attributes of the notification since we only want to be notified when a notification is created, cleared, or one of these 9 attributes changes.
// ICEventType whose value will be one of NOTIFY, CLEAR, or CHANGE will always be added as an additional attribute.
// TailMode=false means datasource will retrieve all existing notifications along with subscribing to new notification events.
// TransientInterval=300 means, transient fluctuations in notification attributes will be suppressed for a period of 300 msecs.
def getParameters(){
   return [
           "Attributes":["ClassName", "InstanceName", "EventName", "SourceDomainName", "OccurrenceCount", "UserDefined1", "UserDefined2", "UserDefined3", "UserDefined4"],
           "NotificationList":"Tunnels",
           "TransientInterval":300,
           "TailMode":false
   ]
}

def init(){
}

def cleanUp(){
}

// This is where we implement the listening business logic for our connector. Notification object is passed in as a map with 10 attributes (monitored atts + ICEventType).
def update(myNotification){
	// we only care about NOTIFY and CHANGE events
	if (myNotification.ICEventType != "NOTIFY" && myNotification.ICEventType != "CHANGE") return;

	//  define some local variables
	def IATA = myNotification.UserDefined6;
	def icname = myNotification.UserDefined7;

	// rest of the logic
}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.