13 Replies Latest reply on Mar 28, 2014 12:24 PM by Krishna Yadla

    BladeLogic CLI retrieve job parameter values

    Krishna Yadla

      Running into an issue while trying to capture parameter values on NSH script job using BL CLI through Configuration Manager 7.6.0

       

       

      getNSHParams is failing with IllegalArgumentException. Basically I would like to retrieve current parameter value, replace a string in existing value and apply modified value. But not by clearing all the current values and re-apply them.

       

      blcli_execute NSHScriptJob getDBKeyByGroupAndName ${jobGroup} ${jobName}
      blcli_execute NSHScript getNSHParams

      #blcli_execute Utility setTargetObject

      #blcli_execute NSHScriptParam getName

      #blcli_execute Utility setTargetObject

      #blcli_execute Utility listPrint

      #blcli_storeenv values


      Info Sep 21, 2012 3:28:01 PM trueLOOP Copy_batchDeployListAndEars_dev01
      Info Sep 21, 2012 3:28:03 PM DBKey:SJobKey:6316835-5
      Error Sep 21, 2012 3:24:45 PM Command execution failed. java.lang.IllegalArgumentException: object is not an instance of declaring class

       

       

       

      Thank you

        • 1. Re: BladeLogic CLI retrieve job parameter values
          Bill Robinson

          blcli_execute NSHScriptJob getDBKeyByGroupAndName "/Recommended Scheduled Jobs" "Run ETL"

          blcli_execute NSHScriptJob getNSHScriptParamValues

          blcli_execute Utility setTargetObject

          blcli_execute Utility storeTargetObject values

          blcli_execute Utility listLength

          blcli_storeenv listLength

           

          for item in {0..$((${listLength}-1))}

          do

          blcli_execute Utility setTargetObject values

          blcli_execute Utility listItemSelect ${item}

          blcli_execute Utility setTargetObject

          blcli_execute NSHScriptParamValue getValue

          blcli_storeenv value

          echo "Index ${item}: value: ${value}" >> $$.out

          done

           

          will dump the values.  you'll have to use a loop w/ 'cleanNSHScriptParameterValuesByGroupAndName' and 'addNSHScriptParameterValueByGroupAndName' to re-set all the values.

          • 2. Re: BladeLogic CLI retrieve job parameter values
            Krishna Yadla

            Works perfect. Thank you! Bill for quick response.

            • 3. Re: BladeLogic CLI retrieve job parameter values
              Krishna Yadla

              How to retrieve Job Targets including Servers/ServerGroups? Trying to dump all the Job related info, identifying Job Type (Batch vs NSH Script Job), execution mode (Sequential vs Parallel) and other properties for execution. Any example would be helpful.

              • 4. Re: BladeLogic CLI retrieve job parameter values
                Bill Robinson

                Why?  what do you need to do w/ this info ?

                • 5. Re: BladeLogic CLI retrieve job parameter values
                  Krishna Yadla

                  Need to dump Job related info (JobName, Parameters, Targets & other listed in prior post) into a CSV file for audit. Currently below info is being captured.

                   

                  #jobGroup jobName paramCount paramValues

                  • 7. Re: BladeLogic CLI retrieve job parameter values
                    Krishna Yadla

                    Audit of jobs created through our BL automation. We need to review the job targets and parameters, to make sure there are no issues.

                    • 8. Re: BladeLogic CLI retrieve job parameter values
                      Bill Robinson

                      There’s a ‘Job getTargetServers’.  I don’t see anything that can resolve the target groups.

                      • 9. Re: BladeLogic CLI retrieve job parameter values
                        Krishna Yadla

                        Thanks for your input. Job getTargetServers does not exist in our current version 7.6.

                         

                        ErrorMar 26, 2014 2:23:13 PMCommand execution failed. com.bladelogic.cli.factory.CommandNotFoundException: Name space : Job has no commands by name : getTargetServers

                         

                        Is there a way to find out whether a Job is BatchJob or NSHScriptJob while iterating through results from 'Job listAllByGroup'. I tried to use Job getType, which is not working for BatchJob.

                        • 10. Re: BladeLogic CLI retrieve job parameter values
                          Bill Robinson

                          It was added in 8.2 or a 8.2 service pack.

                           

                          What’s the full list of information you need for the job ?

                          • 11. Re: BladeLogic CLI retrieve job parameter values
                            Krishna Yadla

                            Loop through jobs by group, Identify JobType & dump below values based on job type

                             

                            BatchJob
                            JobName, Targets, ContinueOnError, ExecuteByStage, OverrideTargets, ParallelExecution


                            NSHScriptJob
                            JobName, Targets, Parameters

                            • 12. Re: BladeLogic CLI retrieve job parameter values
                              Bill Robinson

                              so some sql queries might be a better way to get this info out since 7.6 doesn't have the getTargetServers.

                              so for the 1st one something like this should work (oracle):

                              select temp1.path,j.name,b.name as "Group Target",d.name as "Server Target",jov1.option_value as "Override Servers",jov2.option_value as "Continue On Errors",jov3.option_value as "Parallel" from (select group_id, sys_connect_by_path( name, '|' ) path from blgroup start with parent_group_id = 0 connect by prior group_id = parent_group_id) temp1, job j

                              join job_option_value jov1 on j.job_id = jov1.job_id and j.job_version_id = jov1.job_version_id

                              join job_option_value jov2 on j.job_id = jov2.job_id and j.job_version_id = jov2.job_version_id

                              join job_option_value jov3 on j.job_id = jov3.job_id and j.job_version_id = jov3.job_version_id

                              left join job_device jd on j.job_id = jd.job_id and jd.job_version_id = j.job_version_id

                              left join device d on jd.device_id = d.device_id

                              left join job_device_group jdg on j.job_id = jdg.job_id and j.job_version_id = jdg.job_version_id

                              left join blgroup b on jdg.group_id = b.group_id

                              where j.is_latest_version = 1

                              and j.is_deleted = 0

                              and j.is_saved_explicitly = 1

                              and jov1.option_id = 250

                              and jov2.option_id = 251

                              and jov3.option_id = 256

                              and j.object_type_id = 200

                              and temp1.group_id = j.group_id;

                               

                               

                              for the second one something like

                              select temp1.path,j.name,d.name,b.name,np.parameter_name,np.nsh_index,jnpv.value from (select group_id, sys_connect_by_path( name, '|' ) path from blgroup start with parent_group_id = 0 connect by prior group_id = parent_group_id) temp1, job j

                              join job_nsh_parameter_value jnpv on j.job_id = jnpv.job_id and j.job_version_id = jnpv.job_version_id

                              join nsh_parameter np on jnpv.depot_object_id = np.depot_object_id and jnpv.depot_object_version_id = np.depot_object_version_id and jnpv.nsh_parameter_id = np.nsh_parameter_id

                              left join job_device jd on j.job_id = jd.job_id and jd.job_version_id = j.job_version_id

                              left join device d on jd.device_id = d.device_id

                              left join job_device_group jdg on j.job_id = jdg.job_id and j.job_version_id = jdg.job_version_id

                              left join blgroup b on jdg.group_id = b.group_id

                              where j.object_type_id = 111

                              and j.is_latest_version = 1

                              and j.is_deleted = 0

                              and j.is_saved_explicitly = 1

                              and temp1.group_id = j.group_id

                              order by j.name,np.nsh_index;

                               

                               

                              you can probably clean these up a little but that would be the general idea.  also - you might be able to get the info out of bdssa, w/ some custom sql reports that run sql similar to the above.

                              :

                              1 of 1 people found this helpful
                              • 13. Re: BladeLogic CLI retrieve job parameter values
                                Krishna Yadla

                                Its very helpful. Thanks for your input.