4 Replies Latest reply on Aug 18, 2011 8:18 AM by Bill Robinson

    Using unrelased commands in Jython

      Hi All,


      I'm trying to replace one child job within the batch job.


      I'm using the command: "BatchJob findAllSubJobHeadersByBatchJobKey"

      from the unreleased commands.


      I used this trigger: blcli2 -Dcom.bladelogic.cli.debug.release-only="false"

      like it is explained in the documents.



      When I execute this command in NSH script it works ok.

      I would like to use this command within a Jython script, and it's not avialable within the BLJython context.


      I use an NSH script of type 2 to call the jython:


      `blcli2 -Dcom.bladelogic.cli.debug.release-only="false"`
      "/D/Program Files/BMC Software/BladeLogic/8.0/NSH/bin/bljython.bat" "D:\CreateDeployProcess.jy"


      Then The following "CreateDeployProcess.jy" Jython script is executed:

      (the runBlcliCmd() function is based on Bill's example: https://communities.bmc.com/communities/message/133673#133673)


          printInfo('Initializing BLCLI connection.  Standby.')
          jli = blcli.CLI()
          printInfo('BLCLI connection established. Processing script.')
          batchJobDBKey = runBlcliCmd('BatchJob','getDBKeyByGroupAndName',['/RND/Test/Version_Update', 'Test']).returnValue
          jobHeaderslist = runBlcliCmd('BatchJob', 'findAllSubJobHeadersByBatchJobKey',[batchJobDBKey]).returnValue


      I'm getting an error saying that the command cannot be found.

      ERROR: com.bladelogic.cli.factory.CommandNotFoundException: R: Cannot find command : BatchJob, findAllSubJobHeadersByBatchJobKey

      Is it possible to enable unreleased commands within Jython?




        • 1. Using unrelased commands in Jython
          Bill Robinson

          when you run the blcli (or blcli2) it creates a jvm, runs a command and closes the jvm.  any options you pass to it affect only that instance of the jvm.  so in your first example, the option to enable the unreleased commands is doing nothing there.


          to enabled the unreleased commands in jython you need to modify the br/bljython.cfg file and add that -D option to the java args in the file.


          is there a reason you are writing in jython?  you should also look at the 'performance commands' that work inside a nsh shell/session - eg blcli_execute NameSpace command args...

          • 2. Using unrelased commands in Jython

            Hi Bill,


            Thanks for the prompt reply!


            I'm using Jython as recommended in the "BLCLI Help".

            (in "C:/Program Files/BMC Software/BladeLogic/8.0/onlinehelp/help/cli" installation folder)


            The advantages of using Jython are explained in the file "JLI.4.2.html" in that folder.

            (Faster execution)


            Also, I would like the script to run under the credentials of the user executing the BL Job.

            (I believe that in NSH I select the credintials inside the script)


            Finally, I'm familiar with Jython from back in the days, when I developed deploy scripts for IBM WebSphere Server (I'm now working with IIS Servers). I'm less familiar with bash scripts.


            Thanks for the solution above, I'll go try it right away.





            P.S. I also couldn't find much documentation on the NSH shell.

            I got these documents:

            BMC Installation Folder\onlinedoc\BMCBladeLogicNSHCommands.pdf


            and of course - fabulous the BMC forums :-)


            If you know any other sources, I'd love to know.

            • 3. Using unrelased commands in Jython

              Hi Bill,


              Thanks a million! this was exactly the solution.


              just one more quick question, I looked at:



              I want to convert the result I get from findAllSubJobHeadersByBatchJobKey

              from headers to BDKeys.


              In that post, the NSH script uses "blcli_storeenv" command to make the other commands (Job getDBKey, Utility setTargetObject, and Utility listPrint) operate on the list.


              Is there an equivalent in Jython?




              • 4. Using unrelased commands in Jython
                Bill Robinson

                if your blcli function run is called run_blcli_cmd, then you do like this i think:





                keys = run_blclI_cmd("Utility","listPrint").returnValue