Important

   

Starting version 8.9.03, BMC Server Automation is renamed to TrueSight Server Automation. This space contains information about BMC Server Automation 8.9.02 and previous versions. For TrueSight Server Automation 8.9.03 and later releases, see TrueSight Server Automation 8.9.

Installing and configuring Jython

This topic describes how to set up a Jython environment on a computer where you have already installed either the BMC Server Automation Application Server or the BMC Server Automation Console (GUI).

Before you begin

Make sure the BMC Server Automation Application Server or the BMC Server Automation Console is installed on the machine. The paths in this section assume a default installation location. Adjust as necessary.

To install and configure Jython

  1. Go to http://sourceforge.net/projects/jython/files/.
  2. Expand the jython folder and select the latest stable version. In this document, the 2.5.1 version is used as an example.
  3. Navigate into the 2.5.1 folder near the bottom of the page and then click the jython_installer-2.5.1.jar file to download it.
    If you want a reference for their Jython installation instructions, go to the following location: http://wiki.python.org/jython/InstallationInstructions
  4. Open a command prompt as a local admin and navigate to the directory that contains jython_installer_2.5.1
  5. Run the following command, where bljava is the location of the Java executable for BMC Server Automation. This step is required for the BMC Server Automation implementation of jython.

    (Default location for Microsoft Windows) C:\Program Files\BMC Software\BladeLogic\NSH\jre\bin\java.exe
    (Default location for UNIX) /opt/bmc/BladeLogic/NSH/br/java/bin/java

    (Command syntax for Windows)
    <bljava> -jar jython_installer-2.5.1.jar -s -d "C:\Program Files\Jython" -t minimum -i mod
    (Command syntax for UNIX)
    <bljava> -jar jython_installer-2.5.1.jar -s -d "/usr/local/jython" -t minimum -i mod

    This command silently installs the core and libraries in the C:\Program Files\Jython or /usr/local/jython directories.

    Note

    Do not install Jython inside the BMC Server Automation directory structure.

  6. Perform the following configuration tasks:
    • For Windows configuration:
      1. Edit the C:\Program Files\BMC Software\BladeLogic\NSH\br\bljythonexe.cfg file as follows:
        • The Java classpath must be the path to the exact JAR file. In other words:
          java.classpath=C:\Program Files\Jython\jython.jar
        • The Python home needs to be set to the python install dir:
          jvm.arg=-Dpython.home=C:\Program Files\Jython
      2. Ensure that the bljythonexe.cfg file looks like this:

        java.mainclass=org/python/util/jython
        java.classpath=C:\Program Files\Jython\jython.jar
        java.classpath=C:\Program Files\BMC Software\BladeLogic\NSH\br
        java.classpath=C:\Program Files\BMC Software\BladeLogic\NSH\br\stdlib
        java.classpath=C:\Program Files\BMC Software\BladeLogic\NSH\br\deployments
        java.classpath=<default>
        jvm.arg=-Xmx1024M
        jvm.arg=-Dblx.cmrootdir=C:\Program Files\BMC Software\BladeLogic\NSH\br
        jvm.arg=-Dpython.home=C:\Program Files\Jython
        jvm.arg=-Dcom.bladelogic.cli.xmldir=C:\Program Files\BMC Software\BladeLogic\NSH\br\xml\cli
        
      3. In the C:\Program files\Jython\registry file, look for the following line:

        #python.path = d:\\python20\\lib

        Change the line as follows:

        python.path = C:\\Program Files\\BMC Software\\BladeLogic\\NSH\\br\\jython
    • For UNIX configuration:
      1. Edit the /opt/bmc/BladeLogic/NSH//br/bljython file by adding the following lines after the two commented lines at the top.

        JYTHON_HOME=/usr/local/jython
        export JYTHON_HOME
        
      2. Edit /usr/local/jython/registry by adding the following line to the top of the file
        python.path = <blade_install_dir>/br/jython
  7. To verify that bljython runs correctly, open an NSH window and type the following code.
    If a list of all servers is returned, your Jython installation and configuration is working correctly.

    • For Windows:

      cd "/C/Program Files/BMC Software/BladeLogic/NSH/bin/"
      blcred cred -acquire -profile defaultProfile -username BLAdmin -password <password>
      ./bljythonexe
      import sys
      import bladelogic.cli.CLI as blcli
      jli = blcli.CLI()
      jli.setServiceProfileName('defaultProfile')
      jli.setRoleName('BLAdmins')
      jli.connect()
      serverList=jli.run(["Server","listAllServers"]).returnValue
      print serverList
    • For UNIX:

      cd "/opt/bmc/BladeLogic/NSH/bin/"
      blcred cred -acquire -profile defaultProfile -username BLAdmin -password <password>
      ./bljython
      import sys
      import bladelogic.cli.CLI as blcli
      jli = blcli.CLI()
      jli.setServiceProfileName('defaultProfile')
      jli.setRoleName('BLAdmins')
      jli.connect()
      serverList=jli.run(["Server","listAllServers"]).returnValue
      print serverList

        

You can now run Jython scripts from within the BMC Server Automation GUI or CLI by calling bljython /path/to/script/scriptName.jli from the following:

  • Within an NSH Script Job
  • The CLI directly
  • An NSH script run at the CLI
Was this page helpful? Yes No Submitting... Thank you

Comments