Setting up RapidCMDB to work with SmartsRapidCMDB talks to external systems via custom datasources. In order to enable Smarts integration for RapidCMDB:
See the Getting Started Document to see how RapidCMDB is strated. Ad-hoc Integration with SmartsTypically 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 DatasourcesGo 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 SmartsWe 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 ConnectorHere 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 ConnectorListening 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:
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 } |
Add Comment