8 Replies Latest reply on May 17, 2018 11:52 AM by Bill Robinson

    How do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey from the BLCLI ?

    Hamish marson

      Anybody? I'll apologise in advance for this question that should be a 2 minute peruse through the docs. But the online blcli reference doesn't work 9/10 times, and frustration is kicking in with the lack of clarity on most of the calls I can find. I'm sure someone thinks it's as clear as a bright blue sky...

       

      Exactly how do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey? I've tried

       

      NSHScriptJob/getDBKeyByGroupAndName

      NSHScriptJob/findJobKeyByGroupAndName

      NSHScriptJob/findByGroupAndName

       

      All of which return slightly different types of value... but none of them appear to return the type of JobKey that JobRun/abort demands...

       

      TIA

        • 2. Re: How do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey from the BLCLI ?
          Hamish marson

          Sorry, but I don't see how the instructions in that thread, Which culminates in

          blcli_execute JobRun cancel NAMED_OBJECT=jobKey ${jobRunId}

           

          match the unreleased command docs generated by the BSA server itself...

           

          Command Name : abort

          Name space : JobRun

          Command Type : Load

          Release command : false

          Description :

           

          Return type : void

          Command Input :

          Variable NameVariable TypeDescription
          jobKeycom.bladelogic.om.infra.app.service.job.JobKeyno description
          jobRunIdIntegerno description

          Invoked commands in order :

          CommandInputReturn value stored name
          JobRun.abort-api$jobKey$ $jobRunId$-

           

          Now admittedly I'm not a BLCLI expert (In fact I'm doing all this via the API, not at the shell).. but you seem to be passing the static text 'NAMED_OBJECT=jobKey' as the first parameter to the command that claims it's wanting a variable of type 'com.bladelogic.om.infra.app.service.job.JobKey'

           

           

          • 3. Re: How do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey from the BLCLI ?
            Bill Robinson
            but you seem to be passing the static text 'NAMED_OBJECT=jobKey'

            no, i'm not.

            blcli_execute Utility storeTargetObject jobKey

            stores the job key as an object i can refer to later.  not a shell variable.

            NAMED_OBJECT=foo is how you reference the object to pass it into the command, hence:

            blcli_execute JobRun cancel NAMED_OBJECT=jobKey ${jobRunId}

             

            it's wanting a variable of type

             

            no, it wants an object of type...

             

             

            so did you try running it ?  did it work ?

            • 4. Re: How do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey from the BLCLI ?
              Hamish marson

              Not working yet... The docs (Lack of) aren't helping...

               

              I take the DBKey, pass that to (the undocumented) Job/findByDBKey to get something... And then (apparently) call Job/getJobKey which is (badly?) documented as taking no input... But does apparently return a com.bladelogic.om.infra.app.service.job.JobKey. But if you don't give it any input, what's it getting the jobKey for? or is a JobKey just a static think that never changes? or changes in some mysterious way that's unconnected to the previous calls?

               

               

              H

              • 5. Re: How do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey from the BLCLI ?
                Bill Robinson
                The docs (Lack of) aren't helping...

                you mean the Unreleased blcli commands and documentation ? since you are using unreleased and unsupported commands..

                 

                I take the DBKey, pass that to (the undocumented) Job/findByDBKey to get something... And then (apparently) call Job/getJobKey which is (badly?) documented as taking no input... But does apparently return a com.bladelogic.om.infra.app.service.job.JobKey. But if you don't give it any input, what's it getting the jobKey for? or is a JobKey just a static think that never changes? or changes in some mysterious way that's unconnected to the previous calls?

                how about showing the commands you are running and what outputs you are getting. 

                • 6. Re: How do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey from the BLCLI ?
                  Hamish marson

                  Bear with me...I'm trying to take what you've got in the nsh shell and blcli and get it to work with the SOAP API

                   

                  I get the DBKey from NSHScriptJob/getDBKeyByGroupAndName and that returns something like DBKey:SJobModelKeyImpl:2003369-9-2401930

                   

                  I get a JobRunKey via JobRun/findLastRunKeyByJobKey using the DBKey as the paramater... That gets me DBKey:SJobRunModelKeyImpl:2015730-2401460

                   

                  With the JobRunKey I call JobRun/jobRunKeyToJobRunId to get 2015730

                   

                  For the job Key I have to rely on your example and the unreleased commands with no documentation...

                   

                  Call Job/findbyDBKey and get back a strange value that I have no idea what to do with (Your example doesn't seem to use it). -  com.bladelogic.om.infra.model.job.script.NSHScriptJobImpl@20cbfd38

                   

                  Then call Job/getJobKey (With no parameters - so I have no idea what it's doing or using) that returns DBKey:SJobKeyImpl:2003369-9. The API name suggests it's goign to return a jobKey from somewhere... But...

                   

                  Pass those to JobRun/abort and get....

                   

                  'Found command \'JobRun.abort\' but with mismatching arguments. Input \'DBKey:SJobKeyImpl:2003369-9\' cannot be converted to expected type : interface com.bladelogic.om.infra.app.service.job.JobKey',

                   

                  There's a couple of other commands in there though... blcli_execute Utility setTargetObject and Utility/listPrint (Again, docs are unclear - no input - not real clear on the output either).

                   

                  But setTargetObject (With no input) seems to return the same value that getJobKey returned... And listPrint (Again, no input) just returns void... So I'm discounting them as being in any way useful at present... Struggling to understand why they're in there TBH.

                  • 7. Re: How do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey from the BLCLI ?
                    Hamish marson

                    > how about showing the commands you are running and what outputs you are getting.

                     

                    See the posts above & below yours... Showing the calls being made, the parameters and the values that are coming back from them.

                    • 8. Re: How do I get a JobKey of type com.bladelogic.om.infra.app.service.job.JobKey from the BLCLI ?
                      Bill Robinson
                      For the job Key I have to rely on your example and the unreleased commands with no documentation...

                      hence why they are unreleased.  and there are docs, i put that in the last post.

                       

                      Then call Job/getJobKey (With no parameters - so I have no idea what it's doing or using) that returns

                      if you read the unreleased docs i mentioned you see that's a 'get' command that ....gets... something from the object (the job) loaded into memory.

                       

                      Pass those to JobRun/abort and get....

                      by doing what?

                      blcli_execute Utility storeTargetObject jobKey

                      and then

                      blcli_execute Job cancel NAMED_OBJECT=jobKey ${jobId}

                      ?

                       

                      or what exactly are you running ? because this works:

                      jobName="/Workspace/NSH Script Jobs/sleep"

                      blcli_execute NSHScriptJob getDBKeyByGroupAndName "${jobName%/*}" "${jobName##*/}"

                      blcli_storeenv jobKey

                      blcli_execute Job executeAndWaitForRunID ${jobKey}

                      blcli_execute JobRun getJobRunId

                      blcli_storeenv jobRunId

                      blcli_execute Job findByDBKey ${jobKey}

                      blcli_execute Job getJobKey

                      blcli_execute Utility setTargetObject

                      blcli_execute Utility storeTargetObject obj

                      sleep 10

                      blcli_execute JobRun cancel NAMED_OBJECT=obj ${jobRunId}

                      # or:

                      #blcli_execute JobRun abort NAMED_OBJECT=obj ${jobRunId}

                       

                      as does the example in the other thread.  so if you are going to say something isn't working you need to show exactly what you are running and what the output is.  and not stuff like get a JobRunKey via JobRun/findLastRunKeyByJobKey using the DBKey as the paramater. which doesn't tell me exactly what you are running.  JobRun/findLastRunKeyByJobKey using the DBKey as the parameter  is not valid syntax for the command.  show the script, show the outputs.  you might have a typo, or you are missing something from the posts that you didn't copy into your script.