9 Replies Latest reply on Jul 9, 2015 1:22 PM by Eric Gauthier


    Eric Gauthier

      Hi folks,


      In BAO, I'm trying to gathered the job output of each subjob for a given BatchJob.  I cannot find many docs/link on the topics.  I had found some, with small example of nsh script to run that use command: getMemberJobRunsByBatchJobRun...


      At the moment I'm trying to gathered those using soap call to BL Web service.













          <character-set />



            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://bladelogic.com/webservices/framework/xsd" xmlns:clit="http://bladelogic.com/webservices/skeleton/clitunnel">


                <ns1:sessionId xmlns:ns1="http://bladelogic.com/webservices/framework/xsd" soapenv:mustUnderstand="0">urn:uuid:XXXXXXXXXXXXXXXXXXXXXXXX</ns1:sessionId>








                  <!--Zero or more repetitions:-->











      The response I got is this:





        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">


            <ns6:executeCommandByParamListResponse xmlns:ns6="http://bladelogic.com/webservices/skeleton/clitunnel">


                <ns5:classInstance xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd">false</ns5:classInstance>

                <ns5:comments xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd">No comments</ns5:comments>

                <ns5:executionTime xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd">0</ns5:executionTime>

                <ns5:list xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd">true</ns5:list>

                <ns5:memoryUsed xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd">0</ns5:memoryUsed>

                <ns5:realInputArguments xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd" xmlns:s731="http://www.w3.org/2001/XMLSchema-instance" xmlns:s732="http://www.w3.org/2001/XMLSchema" s731:type="s732:string">DBKey:SJobModelKeyImpl:43616-3-3654837</ns5:realInputArguments>

                <ns5:realInputArguments xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd" xmlns:s733="http://www.w3.org/2001/XMLSchema-instance" xmlns:s734="http://www.w3.org/2001/XMLSchema" s733:type="s734:string">92927</ns5:realInputArguments>

                <ns5:returnValue xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd" xmlns:s735="http://www.w3.org/2001/XMLSchema-instance" xmlns:s736="http://www.w3.org/2001/XMLSchema" s735:type="s736:string">void</ns5:returnValue>

                <ns5:returnValues xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd" xmlns:s737="http://www.w3.org/2001/XMLSchema-instance" xmlns:s738="http://www.w3.org/2001/XMLSchema" s737:type="s738:string">[com.bladelogic.om.infra.model.job.jobrun.JobRunImpl@30365234, com.bladelogic.om.infra.model.job.jobrun.JobRunImpl@cb90b841]</ns5:returnValues>

                <ns5:success xmlns:ns5="http://bladelogic.com/webservices/model/clitunnel/xsd">true</ns5:success>








      In returnValues, I see two values, which is probably because I have two sub job in my BatchJob.


      Could someone telling me what are those exactly (com.bladelogic.om.infra.model.job.jobrun.JobRunImpl@30365234, com.bladelogic.om.infra.model.job.jobrun.JobRunImpl@cb90b841)?


      Any others pointers to links, better way to collect those job results would be much appreciated.


      Many thanks in advance.

        • 1. Re: getMemberJobRunsByBatchJobRun
          Bill Robinson

          it's returning a java object.  you need to then run another blcli command against the object w/ it loaded in memory, which is not something you can do via soap.


          you need to make a custom xml command definition that returns the actual data you want w/ a sequence of blcli commands and drop that on your appserver and then call that command via soap.

          • 2. Re: getMemberJobRunsByBatchJobRun
            Yanick Girouard

            Do you absolutely have to use SOAP and blcli calls? Why not a direct SQL query? If you can get the list of job_run_ids of each child job inside a given batch job run, you can easily get the corresponding job_run_events...


            I'll see if I can figure out the API calls needed when I get back to the office, but it might be tricky to do what you want using blcli alone since you will need to individually get the logs of each child jobrun using JobRun getLogItemsByJobRunId, which requires a jobrun key that you'll have to get first... not that easy and will be a lot of blcli calls in the end.

            • 3. Re: getMemberJobRunsByBatchJobRun
              Eric Gauthier

              Thanks Bill.


              I will check this out.

              • 4. Re: getMemberJobRunsByBatchJobRun
                Eric Gauthier

                Salut Yanick!


                I like the idea, but what if they change the DB schema in an upgrade?  This solution won't work and we will have to debug/redo.  May be the best is to stick with blcli commands.


                Best regards,

                • 5. Re: getMemberJobRunsByBatchJobRun
                  Yanick Girouard

                  Unreleased commands are not supported, and may change, so you could have to redo everything anyway even if you use that. That's my point. Either way, nothing will be immune to API or db schema changes.


                  ...besides, it's much more frequent that blcli commands are changed, than db schema is, especially for core tables such as JOB, JOB_RUN, and JOB_RUN_EVENT ...

                  • 6. Re: getMemberJobRunsByBatchJobRun
                    Bill Robinson

                    But it may be easier to mod the custom complex blcli command he creates than get sql access ☺


                    If you create a new command you should create an ‘idea’ w/ the command to get a released version added to the blcli.

                    • 7. Re: getMemberJobRunsByBatchJobRun
                      Yanick Girouard

                      He already has SQL access.

                      • 8. Re: getMemberJobRunsByBatchJobRun
                        Yanick Girouard

                        Eric, try this:


                        select bjr.job_id,bjr.job_version_id,j.bl_value_id,bjr.job_run_id from batch_job_run bjr

                        inner join job j on j.job_id = bjr.job_id and j.job_version_id = bjr.job_version_id

                        where bjr.batch_job_run_id=BATCH_JOB_RUN_ID


                        This will give you the list of child job_run_ids the batch_job_run ran with the info required to generate the jobkey of each child job (in case you need to use JobRun getLogItemsByJobRunId for eample). The jobkey = DBKey:SJobModelKeyImpl:JOB_ID-JOB_VERSION_ID-BL_VALUE_ID


                        Then to get the logs for each, just do this for each job run id it returns you:


                        select server_name, event_date, event_type_id, message from job_run_event where job_run_id=JOB_RUN_ID;

                        or use the blcli command equivalent...

                        • 9. Re: getMemberJobRunsByBatchJobRun
                          Eric Gauthier



                          Using the SQL Select you provided and with another one to gathered the dbkey of subjob, I'm now able to have all the sub keys I need and then to reuse existing BAO Process we developed to collect all the job log items.


                          select CONVERT(varchar(10),bjr.job_id) + '-' + CONVERT(varchar(5),bjr.job_version_id) + '-' + CONVERT(varchar(10),j.bl_value_id) as jobdbkey, bjr.job_run_id

                            from [BLCore_DB_Dev].[dbo].[batch_job_run] bjr

                          inner join [BLCore_DB_Dev].[dbo].[JOB] j on j.job_id = bjr.job_id and j.job_version_id = bjr.job_version_id

                          where bjr.batch_job_run_id= 'JOB RUN ID'


                          Thanks a lot again!