Sample 2- Using scripts to generate a federated schema

Table of Contents

Installation Instructions

  • Download Sample2
  • Unzip in RS_HOME
  • Before starting the application, copy MySql jdbc driver into RS_HOME/RapidCMDB/lib folder.
  • Before running the scripts, you need to modify checkDatasources() method in both Sample2Setup.groovy and Sample2Connector.groovy scripts to point to the correct MySql database servers.

In the code segment shown below, url, username and password parameters have to be modified:

...
if(conn == null){
    conn = DatabaseConnection.add(name:"mysql", driver:"com.mysql.jdbc.Driver", url:"jdbc:mysql://192.168.1.100/test", username:"root", password:"root");
}
...

Running Sample2

The deployment and setup procedure is as follows:

  • Unzip the sample package in RS_HOME (..../RapidServer)
  • In RapidCMDBModeler UI, register and runthe setup script (Sample2Setup.groovy), which will create the modeling meta-data (as if you have done the modeling through the RapidCMDBModeler UI).
  • After running the setup script, access the RapidCMDBModeler UI/Model Managed Classes view and browse the definitions for modeled classes and their relationships.
  • Generate the modeled classes by clicking on "Generate" in RapidCMDBModeler UI/Model Managed Classes view. All modeled classes will be generated.
  • In order for the model classes to be available from RapidCMDB Admin UI for consumption, reload the RapidCMDB application from RapidCMDB Admin UI / Application Management view.  
  • Register and run the data population script (Sample2Connector.groovy) in RapidCMDB Admin UI/Scripting page to populate the MySql database and create instances for the modeled classes. You can use RapidCMDB Admin UI/Modeled Classes to list the instances of modeled classes created and add more instances if you want.
  • Register and run the consuming scripts (Sample2Test*.groovy), provided with the sample, in RapidCMDB Admin UI/Scripting page.
  • As the last and most fun step, write new consuming scripts and/or setup script to modify the behavior. These scripts have to be registered and run in RapidCMDB Admin UI/Scripting page.

Sample Scenario 2

What is it:

Scenario 2 is a simplified representation of a Customer-Service-Resource relation in a company.


In this scenario, some of the data is federated from MySql databases. Key properties for all models are kept in RapidCMDB while some models have more data brought from their source and kept in RapidCMDB. In a real world scenario, these properties might be the ones that are static in their nature and rarely change. This way, you can minimize the cost of accessing the original data source for those static properties.

Scripts provided:

  • Setup script (Sample2Setup.groovy):  creates the model classes and relations between them. When you execute the script the first time, you may get an error. Run it again.
  • Connector script (Sample2Connector.groovy): creates a schema with the required tables and populates them in an MySql database and creates instances in RapidCMDB.
  • Sample scripts (Sample2Test*.groovy): runs some queries in RCMDB data. You need to register these scripts in RapidCMDB Admin UI/Scripting page and run from a Url by supplying parameters. At the beginning of each script, the parameters required are explained.
    Ex: http://localhost:12222/RapidSuite/script/run/Sample2Test3?Service=service1&Servicelevel=Gold&State=state1

What is next:

Once setup and connector scripts are registered and run, you can:

  • run sample test scripts
  • start populating more data in RapidCMDB Admin UI/Modeled Classes page. Any model UI can also be directly accessed by forming a Url as follows:http://localhost:12222/RapidSuite/<modelName>
    Ex:http://localhost:12222/RapidSuite/resource
    Even though model names start with a capital letter while creating them, when used in Url, it should be in small letters.
  • modify the model classes at RapidCMDBModeler home page (Ex:http://localhost:12223/Modeler). Note that after any model changes, RapidCMDB Admin application has to be reloaded from RapidCMDB Admin UI/Application Management page.
  • write scripts to access, manipulate, and query the data.  These scripts have to be registered and run in RapidCMDB Admin UI/Scripting page. For more information on consuming scripts, visit this document.

Labels

sample sample Delete
tutorial tutorial Delete
federated federated Delete
cmdb cmdb Delete
federation federation Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.