2 Replies Latest reply on Oct 10, 2011 10:51 AM by Carlos NameToUpdate

    Recover failed servers from a Compliance Job Run

      Hi all,


      I'm working on a sample script to recover failed servers from a Compliance Job Run. I've managed to work with Utility namespace to switch between objects in the context and retrieve them to recover object information.

      I have managed to work with java Lists to recover objects and set them in the context. The problem is that JobRun getFailedServersByRunId returns an object of the class "java.util.Set" instead of "java.util.List", and I haven't found any mechanisms to deal with that type of objects.


      I've tried to use the object string to work with server objects, but no luck.


      Has anyone deal with this before? Which would be the right approach to recover those servers from the Job Run?


      This is my script, for further reference:


      # Get the DBKey of the Job

      blcli_execute ComplianceJob getDBKeyByGroupAndName "/Compliance/Job/Path" "Compliance Job Name" > /dev/null

      blcli_storeenv COMPLIANCE_JOB_KEY

      blcli_execute Utility storeTargetObject COMPLIANCE_JOB_OBJECT > /dev/null


      # Find all Job Runs of that Job

      blcli_execute JobRun findAllByJobKey "$COMPLIANCE_JOB_KEY" > /dev/null

      blcli_storeenv COMPLIANCE_JOB_RUNS


      # Save List object in the context

      blcli_execute Utility storeTargetObject COMPLIANCE_JOB_RUNS_OBJ > /dev/null


      # Recover number of elements

      blcli_execute Utility listGetLastIndex  > /dev/null

      blcli_storeenv NUM_RUNS


      for i in {1..$NUM_RUNS}


          blcli_execute Utility setTargetObject COMPLIANCE_JOB_RUNS_OBJ > /dev/null


          # Select the Job Run from the list and set it as target object

          blcli_execute Utility listItemSelect $i > /dev/null

          blcli_execute Utility setTargetObject > /dev/null

          blcli_execute Utility storeTargetObject CURRENT_JOB > /dev/null


          # Execute object-contextual calls

          blcli_execute JobRun getName > /dev/null

          blcli_storeenv NAME

          blcli_execute JobRun getEndTime > /dev/null

          blcli_storeenv ENDDATE

          blcli_execute JobRun getJobRunId > /dev/null

          blcli_storeenv JR_ID

          blcli_execute JobRun getHadErrors > /dev/null

          blcli_storeenv ERRORS

          blcli_execute JobRun getHadWarnings > /dev/null

          blcli_storeenv WARNINGS

          blcli_execute JobRun getIsAborted > /dev/null

          blcli_storeenv ABORTED

          blcli_execute JobRun getIsCompleted > /dev/null

          blcli_storeenv COMPLETED

          blcli_execute JobRun getIsIncomplete > /dev/null

          blcli_storeenv INCOMPLETE

          blcli_execute JobRun getIsReset > /dev/null

          blcli_storeenv RESETED

          blcli_execute JobRun getIsRunning > /dev/null

          blcli_storeenv RUNNING



          blcli_execute JobRun getFailedServersByRunId $JR_ID #> /dev/null

          blcli_storeenv FAILED_SERVERS

          # Is there any way of working with objects of the class java.util.Set from the BLCLI????

      #    blcli_execute Utility storeTargetObject FAILED_SERVERS_SET #> /dev/null

      #    blcli_execute Utility setTargetObject FAILED_SERVERS_SET #> /dev/null

          NUM_FAILED_SERVERS=$(getNumElementsInSet "$FAILED_SERVERS")


          if [ $NUM_FAILED_SERVERS -gt 0 ]



              # Would like to recover Server Names from the java.util.Set Server objects but haven't find the way

              for j in {1..$NUM_FAILED_SERVERS}


                  SERVER_OBJ=$(getIndexObjetFromSet "$FAILED_SERVERS" $j)

      # None of these seem to work

      #            blcli_execute JobResultDevice getName > /dev/null

      #            blcli_execute Server getName > /dev/null

      #            blcli_storeenv SERVER_NAME




      #    blcli_execute Utility setTargetObject CURRENT_JOB > /dev/null

          echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

          echo "EJECUCIÓN: $NAME . Finalizada en: "$ENDDATE


          echo "EN EJECUCIÓN: $RUNNING"

          echo "Servidores fallidos: $FAILED_SERVERS_LIST"

          echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"




      Thanks in advance.

        • 1. Recover failed servers from a Compliance Job Run
          Bill Robinson

          a couple notes:


          blcli_storeenv COMPLIANCE_JOB_KEY

          -> this saves a shell environment variable that you can later reference by ${COMPLIANCE_JOB_KEY} and is a string or integer. 

          blcli_execute Utility storeTargetObject COMPLIANCE_JOB_OBJECT

          -> this stores the java object for reference later. 


          to load the object or reference it you do:

          Utility setTargetObject NAMED_OBJECT=COMPLIANCE_JOB_OBJECT


          SomeNameSpace someCommand arg1 arg2 NAMED_OBJECT=COMPLIANCE_JOB_OBJECT


          what you use depends on the command.  if the command is expecting an object use the NAMED_OBJECT syntax.  if the command takes a string, use the shell variable.  if it takes no input, use the setTargetObject before you run the command.

          1 of 1 people found this helpful
          • 2. Recover failed servers from a Compliance Job Run

            Thanks, Bill.

            I finally went through this by using jython, which allowed me to work with native java objects (in this case, as I stated, I needed to work with java.util.Set objects).