11 Replies Latest reply on Jul 1, 2013 7:42 AM by Bill Robinson

    Snapshot.findAllByJob - parameter jobKey wanted

    R V

      Hi all,

       

      I want to use "Snapshot findAllByJob" as Command-Input I have to provide:

       

                    

      jobKeycom.bladelogic.om.infra.app.service.job.JobKey

       

      Unfortunately I could not get further. Whatever I enter for "jobKey" - a DBKey (output from Job.getDBKey), an Id (output from Job.getJobId) or a "real" JobKey (output from Job.getJobKey) - I get an error that the parameter could not be converted:

       

      JobKey: DBKey:SJobKeyImpl:2000266-2
      Command execution failed. com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Found command 'Snapshot.findAllByJob' but with mismatching arguments. : java.lang.IllegalArgumentException: Input 'DBKey:SJobKeyImpl:2000266-2' cannot be converted to expected type : interface com.bladelogic.om.infra.app.service.job.JobKey

      Does anyone know, what this $%&*#-JobKey ist?

       

      Any help would remove one of the "$%&*#"-characters

       

      Regards,

      Reinhard

        • 1. Re: Snapshot.findAllByJob - parameter jobKey wanted
          Siddu angadi

          What exactly you are looking for?

           

          Are you looking for Job_Keys for your snapshot Jobs?

           

          Thanks

          Siddu

          • 2. Re: Snapshot.findAllByJob - parameter jobKey wanted
            R V

            Hi Siddu,

             

            first of all I'm looking for this command to work ;-) - i.e. if I have something named "com.bladelogic.om.infra.app.service.job.JobKey" as an input parameter I want to know how to get this type of object to make "findAllByJob" work; and SnapshotJob.getJobKey should produce this object-type as per blcli-documentation.


            What I need in the end is a reference (DBKey, Id, or whatever I can work with further) to a (Component)Template which in turn is referenced by a Snapshot-Job. And in the very end I need the Component-Template's name (from a specific Snapshot-Job) to give this as a parameter to "Utility simpleExportAudit" (yes, Audit ;-) )


            Thanks,

            Reinhard

            • 3. Re: Snapshot.findAllByJob - parameter jobKey wanted
              Siddu angadi

              Hi Richard,

               

              Correct if I am wrong, are you trying to find out the component template name used in the specific snapshot job. right?

               

              Thanks

              Siddu

              • 4. Re: Snapshot.findAllByJob - parameter jobKey wanted
                R V

                yes, that's right - even better would be the component template name from an audit job - but I could also work with snapshot jobs.

                • 5. Re: Snapshot.findAllByJob - parameter jobKey wanted
                  Siddu angadi

                  Here you go,

                  ##############################

                   

                  TYPE_JOB="SNAPSHOT_JOB"

                  PATH="/CLOSE_LOOP_EXEAMPLE/SNAPSHOTS"

                  NAME=SID_SNAPSHOT

                   

                   

                  blcli_execute Utility exportDependencyGraph ${TYPE_JOB} "${PATH}" "${NAME}" "C:\temp\Job.txt" false '0'

                   

                   

                  COMP_NAME=`cat /c/temp/Job.txt | grep Template | cut -d ',' -f1`

                   

                   

                  COMP_DB_KEY=`cat /c/temp/Job.txt | grep Template | cut -d ',' -f3`

                   

                   

                  echo " Component Name=${COMP_NAME}"

                  echo " Component DB Key=${COMP_DB_KEY}"

                   

                   

                   

                   

                  #############################

                   

                   

                  Thanks

                  Siddu

                  1 of 1 people found this helpful
                  • 6. Re: Snapshot.findAllByJob - parameter jobKey wanted
                    R V

                    Hi Siddu,

                     

                    thank you for that "workaround" which I think I already ran over during my hours of searching. In the end I will probably use it as we have to go on in the project.

                     

                    But I still have no idea how to get this "JobKey"...

                     

                    Thanks and regards,

                    Reinhard

                    • 7. Re: Snapshot.findAllByJob - parameter jobKey wanted
                      Siddu angadi

                      Below is the command to get Snpshot Job DB Key:

                       

                      #######

                       

                      groupName=''

                      jobName=''

                      jobType='SnapshotJob'

                      blcli_execute Job getDBKeyByTypeGroupAndName $groupName $jobName $jobType

                       

                      ####

                      • 8. Re: Snapshot.findAllByJob - parameter jobKey wanted
                        Bill Robinson

                        blcli_execute SnapshotJob getDBKeyByGroupAndName "${groupName}" "${jobName}"

                        blcli_storeenv jobKey

                        blcli_execute Job findByDBKey ${jobKey}

                        blcli_execute Job getJobKey

                        blcli_execute Utility setTargetObject

                        blcli_execute Utility storeTargetObject JobKey

                        blcli_execute Snapshot findAllByJob NAMED_OBJECT=JobKey

                        • 9. Re: Snapshot.findAllByJob - parameter jobKey wanted
                          R V

                          Hi Siddu,

                           

                          thanks for your continuing input. If it was only the DBKey I had to know, I would not have any problem. Unfortunately the blcli-documentation is not very accurate about using the words Key, DBKey, [Job]Key, Id - there are different usages in different places (i.e. namespace-methods), maybe depending on the author of the method-documentation.

                           

                          Regards,

                          Reinhard

                          • 10. Re: Snapshot.findAllByJob - parameter jobKey wanted
                            R V

                            Thanks Bill, I will have to burn this "NAMED_OBJECT"-thing somewhere in the back of my brain to remember it the next time I need it...

                             

                            Just an additional information - as I said in my second posting, the primary intent was to get a component template from the snapshot (or even better audit-) job which furthermore is included in a batch job. Here is my solution for anybody interested in (which btw doesn't use this function any longer ;-) ):

                             

                            JOB_GROUP_NAME="/Workspace/TestApp"
                            BATCH_JOB_NAME="TestApp_v1 BatchAudit Global"

                             

                            blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true

                             

                            echo "Get JobGroupId"

                            blcli_execute JobGroup groupNameToId "${JOB_GROUP_NAME}"
                            blcli_storeenv jobGroupId
                            echo "Get all Jobs for GroupId"
                            blcli_execute Job findAllByGroupId $jobGroupId false
                            blcli_execute Job getDBKey
                            blcli_execute Utility setTargetObject
                            blcli_execute Utility listPrint
                            blcli_storeenv jobKeyListe

                            echo "Traverse Job-Liste"
                            for jobKey in $jobKeyListe; do
                                blcli_execute Job findByDBKey $jobKey
                                blcli_execute Job getType
                                blcli_storeenv jobTyp   

                                # only process AuditJobs (Type 31 - see e.g. blcli-help for ImportExport.exportObject)

                                if [ $jobTyp -eq 31 ]; then
                                    echo "Audit-(Type31)-JobKey: $jobKey"

                                    echo "Get allTemplates - only one is possible"

                                    blcli_execute Job getAllTemplates
                                    blcli_storeenv allTemplates

                                    echo "Extract DBKey from (so called) map, which in fact seems to be a string-object"
                                    myTemplateKey=$(echo $allTemplates | sed 's/^{\([^=]*\)=.*/\1/')
                                    blcli_execute Template findByDBKey $myTemplateKey
                                    blcli_execute Template getName
                                    blcli_storeenv templateName
                                    echo "Here we go - TemplateName: $templateName"
                                fi
                            done

                            Regards,

                            Reinhard

                            • 11. Re: Snapshot.findAllByJob - parameter jobKey wanted
                              Bill Robinson

                              the docs did say the 'findAllByJob' needs JobKey vs a dbkey