Write Jython Scripts

The mapping script is a regular Jython script, and should follow the rules for Jython scripts. For details, see Developing Jython Adapters.

The script should contain the DiscoveryMain function, which may return either an empty OSHVResult or a DataPushResults instance upon success.

To report any failure, the script should raise an exception, for example:

raise Exception('Failed to insert to remote UCMDB using TopologyUpdateService. See log of the remote UCMDB')

In the DiscoveryMain function, the data items to be pushed to or deleted from the external application can be obtained as follows:

# get add/update/delete result objects (in XML format) from the Framework
addResult = Framework.getTriggerCIData('addResult')
updateResult = Framework.getTriggerCIData('updateResult')
deleteResult = Framework.getTriggerCIData('deleteResult')

The client object to the external application can be obtained as follows:

oracleClient = Framework.createClient()

This client object automatically uses the credentials ID, host name and port number passed by the adapter through the Framework.

If you need to use the connection parameters that you defined for the adapter (for details, see the step on editing the discoveryPatterns\push_adapter.xml file in Build an Adapter Package), use the following code:

propValue = str(Framework.getDestinationAttribute('<Connection Property Name'))

For example:

serverName = Framework.getDestinationAttribute('ip_address')

This section also includes: