Searching the Help
To search for information in the Help, type a word or phrase in the Search box. When you enter a group of words, OR is inferred. You can use Boolean operators to refine your search.
Results returned are case insensitive. However, results ranking takes case into account and assigns higher scores to case matches. Therefore, a search for "cats" followed by a search for "Cats" would return the same number of Help topics, but the order in which the topics are listed would be different.
Search for | Example | Results |
---|---|---|
A single word | cat
|
Topics that contain the word "cat". You will also find its grammatical variations, such as "cats". |
A phrase. You can specify that the search results contain a specific phrase. |
"cat food" (quotation marks) |
Topics that contain the literal phrase "cat food" and all its grammatical variations. Without the quotation marks, the query is equivalent to specifying an OR operator, which finds topics with one of the individual words instead of the phrase. |
Search for | Operator | Example |
---|---|---|
Two or more words in the same topic |
|
|
Either word in a topic |
|
|
Topics that do not contain a specific word or phrase |
|
|
Topics that contain one string and do not contain another | ^ (caret) |
cat ^ mouse
|
A combination of search types | ( ) parentheses |
|
- Create Jython Code
- Use External Java JAR Files within Jython
- Execution of the Code
- Modifying Out-of-the-Box Scripts
- Structure of the Jython File
- Results Generation by the Jython Script
- The Framework Instance
- Finding the Correct Credentials (for Connection Adapters)
- Handling Exceptions from Java
- Troubleshooting Migration from Jython Version 2.1 to 2.5.3
The Framework Instance
The Framework instance is the only argument that is supplied in the main function in the Jython script. This is an interface that can be used to retrieve information required to run the script (for example, information on trigger CIs and adapter parameters), and is also used to report on errors that occur during the script run. For details, see Data Flow Management API Reference.
The correct usage of Framework instance is to pass it as argument to each method that uses it.
Example:
def DiscoveryMain(Framework): OSHVResult = helperMethod (Framework) return OSHVResult def helperMethod (Framework): .... probe_name = Framework.getDestinationAttribute('probe_name') ... return result
This section describes the most important Framework usages:
Framework.getTriggerCIData(String attributeName)
This API provides the intermediate step between the Trigger CI data defined in the adapter and the script.
Example of Retrieving Credential Information:
You request the following Trigger CI data information:
To retrieve the credential information from the task, use this API:
credId = Framework.getTriggerCIData('credentialsId')
Framework.createClient(credentialsId, props)
You make a connection to a remote machine by creating a client object and executing commands on that client. To create a client, retrieve the ClientFactory
class. The getClientFactory() method receives the type of the requested client protocol. The protocol constants are defined in the ClientsConsts class. For details on credentials and supported protocols, see the Universal CMDB Discovery and Integrations Content Help.
Example of Creating a Client Instance for the Credentials ID:
To create a Client
instance for the credentials ID:
properties = Properties() codePage = Framework.getCodePage() properties.put( BaseAgent.ENCODING, codePage) client = Framework.createClient(credentailsID ,properties)
You can now use the Client
instance to connect to the relevant machine or application.
Example of Creating a WMI Client and Running a WMI Query:
To create a WMI client and run a WMI query using the client:
wmiClient = Framework.createClient(credential) resultSet = wmiClient. executeQuery("SELECT TotalPhysicalMemory FROM Win32_LogicalMemoryConfiguration")
Note: To make the createClient()
API work, add the following parameter to the Trigger CI data parameters: credentialsId = ${SOURCE.credentials_id} in the Triggered CI Data pane. Or you can manually add the credentials ID when calling the function: wmiClient = clientFactory().createClient(credentials_id).
The following diagram illustrates the hierarchy of the clients, with their commonly-supported APIs:
For details on the clients and their supported APIs, see BaseClient, ShellClient, and QueryClient in the DFM Framework. These files are located in the following folder:
Framework.getParameter (String parameterName)
In addition to retrieving information on the Trigger CI, you often need to retrieve an adapter parameter value. For example:
Example of Retrieving the Value of the protocolType Parameter:
To retrieve the value of the protocolType
parameter from the Jython script, use the following API:
protocolType = Framework.getParameterValue('protocolType')
Framework.reportError(String message) and Framework.reportWarning(String message)
Some errors (for example, connection failure, hardware problems, timeouts) can occur during a script run. When such errors are detected, Framework can report on the problem. The message that is reported reaches the server and is displayed for the user.
Example of a Report Error and Message:
The following example illustrates the use of the reportError(<Error Msg>)
API:
try: client = Framework.createClient(Framework.getTriggerCIData(BaseClient.CREDENTIALS_ID))
except: strException = str(sys.exc_info()[1]).strip() Framework. reportError ('Connection failed: %s' % strException)
You can use either one of the APIs—Framework.reportError(String message)
, Framework.reportWarning(String message)
—to report on a problem. The difference between the two APIs is that when reporting an error, the Probe saves a communication log file with the entire session's parameters to the file system. In this way you are able to track the session and better understand the error.
For details on error messages, see Error Messages.
We welcome your comments!
To open the configured email client on this computer, open an email window.
Otherwise, copy the information below to a web mail client, and send this email to cms-doc@microfocus.com.
Help Topic ID:
Product:
Topic Title:
Feedback: