Define a New Job to Operate With Localized Data

This task describes how to write a new job that can operate with localized data.

Jython scripts usually execute commands and parse their output. To receive this command output in a properly decoded manner, use the API for the ShellUtils class. For details, see  Universal CMDB (UCMDB) Web Service API Overview.

This code usually takes the following form:

client = Framework.createClient(protocol, properties)
shellUtils = shellutils.ShellUtils(client)
languageBundle = shellutils.getLanguageBundle ('langNetwork', shellUtils.osLanguage, Framework)
strWindowsIPAddress = languageBundle.getString('windows_ipconfig_str_ip_address')
ipconfigOutput = shellUtils.executeCommandAndDecode('ipconfig /all', strWindowsIPAddress)
#Do work with output here
  1. Create a client:

    client = Framework.createClient(protocol, properties)
    
  2. Create an instance of the ShellUtils class and add the operating system language to it. If the language is not added, the default language is used (usually English):

    shellUtils = shellutils.ShellUtils(client)

    During object initialization, DFM automatically detects machine language and sets preferable encoding from the predefined Language object. Preferable encoding is the first instance appearing in the encoding list.

  3. Retrieve the appropriate resource bundle from shellclient using the getLanguageBundle method:

    languageBundle = shellutils.getLanguageBundle ('langNetwork', shellUtils.osLanguage, Framework)
    
  4. Retrieve a keyword from the resource bundle, suitable for a particular command:

    strWindowsIPAddress = languageBundle.getString('windows_ipconfig_str_ip_address')
    
  5. Invoke the executeCommandAndDecode method and pass the keyword to it on the ShellUtils object:

    ipconfigOutput = shellUtils.executeCommandAndDecode('ipconfig /all', strWindowsIPAddress)
    

    The ShellUtils object is also needed to link a user to the API reference (where this method is described in detail).

  6. Parse the output as usual.

Parent topic: Support Localization in Jython Adapters