Implement a Discovery Adapter

A DFM task has the aim of accessing remote (or local) systems, modeling extracted data as CIs, and saving the CIs to the CMDB. The task consists of the following steps:

  1. Create an adapter.

    You configure an adapter file that holds the context, parameters, and result types by selecting the scripts that are to be part of the adapter. For details, see Step 1: Create an Adapter.

  2. Create a Discovery job.

    You configure a job with scheduling information and a trigger query. For details, see Step 2: Assign a Job to the Adapter.

  3. Edit Discovery code.

    You can edit the Jython or Java code that is contained in the adapter files and that refers to the DFM Framework. For details, see Step 3: Create Jython Code.

To write new adapters, you create each of the above components, each one of which is automatically bound to the component in the previous step. For example, once you create a job and select the relevant adapter, the adapter file binds to the job.

Adapter Code

The actual implementation of connecting to the remote system, querying its data, and mapping it as CMDB data is performed by the Jython code. For example, the code contains the logic for connecting to a database and extracting data from it. In this case, the code expects to receive a JDBC URL, a user name, a password, a port, and so on. These parameters are specific for each instance of the database that answers the TQL query. You define these variables in the adapter (in the Trigger CI data) and when the job runs, these specific details are passed to the code for execution.

The adapter can refer to this code by a Java class name or a Jython script name. In this section we discuss writing DFM code as Jython scripts.

An adapter can contain a list of scripts to be used when running discovery. When creating a new adapter, you usually create a new script and assign it to the adapter. A new script includes basic templates, but you can use one of the other scripts as a template by right-clicking it and selecting Save as:

For details on writing new Jython scripts, see Step 3: Create Jython Code. You add scripts through the Resources pane:

The list of scripts are run one after the other, in the order in which they are defined in the adapter:

Note A script must be specified even though it is being used solely as a library by another script. In this case, the library script must be defined before the script using it. In this example, the processdbutils.py script is a library used by the last host_processes.py script. Libraries are distinguished from regular runnable scripts by the lack of the DiscoveryMain() function.