Working with Smarts in Scripts

Table of Contents

RapidOSS integrates with other systems via datasources. Datasources encapsulate the connection information and use the operations of the underlying custom adapter to operate on the external system.

Smarts plugin adds two new datasources to the existing datasources of RapidOSS:

  • SmartsNotificationDatasource
  • SmartsTopologyDatasource

Different instances (for different Smarts servers) of these two datasources are available in your scripts to operate on notifications or topology objects in your Smarts server.

In order to call the operations on any datasource:

  • an instance of the datasource must have been created and
  • the instance should be retrieved in the script

Defining Instances of Datasources

While defining a Smarts connector in the Smarts tab of the admin UI, an instance of the notification or the topology datasource along with an instance of smarts connection will be created for you. If the name of your connector is MyConn then the name of the datasource will be:

  • MyConnNotificationDs - if connector type is Notification
  • MyConnTopologyDs -  if connector type is Topology

Retrieving an Instance and Invoking Operations

Here is an example script where an instance of a notification datasource and an instance of a topology datasource are retrieved and operations are invoked.

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

// 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"])
Best documentation on the available operations for Smarts datasources are the source files themselves. These operations are defined in the following 2 files:
  • RS_HOME/RapidSuite/operations/datasource/SmartsNotificationDatasourceOperations.groovy
  • RS_HOME/RapidSuite/operations/datasource/SmartsTopologyDatasourceOperations.groovy
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.