1 2 Previous Next 17 Replies Latest reply on Jul 2, 2012 1:43 PM by Bill Robinson

    List Commands for a nameSpace



      I have been going through the BL automation documentation but I am thinking they miss some in the documents. I have a few questions listed below.


      • Is there command to get the Job Key  directly when we run the job. For now I am retrieving the jobKey by using this.

      Since $0 stores the handle of the job. I am using the following commands to retrieve the jobKey/DBKey from the handle.


      DBkey=`echo $0 | awk -F_ '{print $4}'`

      DBkey=`echo ${DBkey} | awk -F"DBKey-SJobKey-" '{print $2}'`

      echo "The value of DBKey is ${DBkey}"


      jobname=`blcli Job getJobNameByDBKey "${DBkey}"`

      echo "The name of the job being executed is ${jobname}"


      Following are the logs for the above commands.


      Info    Oct 27, 2011 4:07:27 PM    The handle is


      Info    Oct 27, 2011 4:07:29 PM    The value of DBKey is DBKey:SJobKey:6046843-51
      Info    Oct 27, 2011 4:07:33 PM    The name of the job being executed is testpword

      Info    Oct 27, 2011 4:07:44 PM    Exit Code 0


                     So instead of doing all that above, I want to get the name of the job when I execute it, assuming I do not know the JobGroup(location) or the DBKey.


      • My second question is on the same lines. For example I have a job for which I have to clear(OR)change specific parameters after it is executed. For now I am using the follow command.

      blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName "${JOBGROUP}" "${jobname}" 2 "ChangedValue"

      Now in the above command, I have to give the JobGroup as well as JobName which I DONT want to hardcode in the NSH Script command. I figured out the way to get the jobName as mentioned in my first question. Is there a way to get the jobGroup of the job being executed ???


      • My third question. Is there a command or a way to list all commands in a particular namespace, for example a nameSpace like NSHScriptJob???



      Your responses are greatly appreciated and awaited !!


      Thank you,


        • 1. List Commands for a nameSpace
          Bill Robinson

          I'm not sure i understand the 1st bit - you are running a nsh script job via the gui, and from within that job you want to get its dbkey while it is running?  for what purpose?


          for 2 - if you have the dbkey of the job you can do like:

          blcli_execute Job findByDBKey ${dbKey}

          blcli_execute Job getFullyQualifiedPath

          blcli_storeenv jobGroup


          for 3 - there's a blcli-browse or you can use the blcli help doc that should be in your start menu.  and you should look at the unreleased commands:




          also - can you describe what you are trying to do w/ this ?

          • 2. List Commands for a nameSpace

            Thank you for responding Bill. Here is what I am trying to achieve.


            I have a NSH script which uses passwords as its parameters and those parameters should be cleared after the jobs which use these NSH script is executed.


            Now I have multiple jobs which use the same NSH script.


            I have the following command in my NSH script to clear/change the password parameter after a job runs.


            blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName "${JOBGROUP}" "${JOBNAME}" 4 ""


            The above command uses JobGroup, JobName, the index of the parameter(4), and nothing between "" at the end to clear the 5th parameter (indexed 4).


            So here is the issue. This same script is used by multiple Jobs at different locations(jobGroups) and with different names(jobNames)


            I need something so I that I can generalize my script instead of hardcoding JobNames and JobGroups in the script so that any one who creates a new job with any name at any location can use my NSH script and not worry about changing anything in the script.


            I will respond about 2nd and 3rd points after I try them out.


            Thank you,


            • 3. List Commands for a nameSpace
              Bill Robinson

              what kind of passwords are these for?  user account passwords or something else?


              how does the passwd get set on the script ?

              • 4. List Commands for a nameSpace

                I am working on certificates ..so I will be giving passwords of the cert keystores in the parameters and am clearing them out after a job completes its work.

                • 5. List Commands for a nameSpace
                  Bill Robinson

                  here's a possible problem w/ this - will a single instance of a job be run by a single user and then cleared, or would it be possible for that job to be run multipe times, possible concurrently ?


                  if the later then clearing the options is likely to break the next run of the job, if you cleared the options just after someone changed them and just before they kicked off their job.  this would also be true for any kind of changes to the job parameters.

                  • 6. List Commands for a nameSpace

                    Added a parameter for jobGroup to give location and that works smooth.

                    • 7. List Commands for a nameSpace

                      Bill, I invoke it only once, so multiple invocations of the same job is not an issue here. But you bring up an interesting discussion here, we maintain a huge number of environments I shd say some hundreds of servers and 70 different environments of Websphere. For all this we maintain jobs which use same NSH scripts but have different parameters, so if I have some 10 NSH scripts, we end up maintaining those 10 jobs in 70 environments ending with 700 jobs to maintain.


                      This way, it has reached to some thousands of jobs and it's getting tedious to maintain. I have written scripts to update parameters and targets of all these jobs with one BL job but I think it's better if we can only maintain 10 jobs and let BL allow concurrent invocations for multiple environments. That reduces our jobs by 70 fold !!! That will be a blessing, is this possible with Bladelogic ??


                      Thank you,


                      • 8. Re: List Commands for a nameSpace



                        You need to develop a "Job builder". This is something that we have done at our workplace as we are in a similar situation to you.



                        Have a script which when run with certain parameters will then create brand new (but temporary) jobs in BladeLogic. These jobs will then have all their parameters set each time that they are built. This script will be run every time that you want to do a deployment. All parameters (per environment) can be stored elsewhere (text files?) and can then be read for parameter setting.


                        Then after 14 days (or the length of time of your choice), you then clear down old jobs.

                        • 9. Re: List Commands for a nameSpace
                          Bill Robinson

                          What about the parameters is different?  is that something we can maybe store in the property dictionary or figure out on the fly ?


                          How do you usually initiate the jobs ?

                          • 10. Re: List Commands for a nameSpace

                            @Bill (sorry to interrupt here, but I hope to be of help)


                            We had a similar environment to Vivek, about 7 different environments with about 10 WebSphere scripts. We've had two incarnations of our job builder. The first one worked off the property dictionary and each environment was configured in there. However it became difficult and tedious to keep the property dictionary up-to-date and required communications from the WebSphere team to be good. Eventually we realised that this was too much work.


                            In the 2nd incarnation, we do it a bit different. We run what we call a "discovery job" (it's an NSH script job really, but it discovers information in the WebSphere environment). This has a standard set of inputs and this then supplies the parameters to the job builder. This then writes out to text files which the job builder reads, indexed by an ITIL change number. Parameter names are known by a pre-determined text file with them all listed for each script.


                            All of this is initiated by an orchestration system (Opalis) which has an integration into BladeLogic. Though I guess it could all be kicked off by a schedule on a BladeLogic job.

                            • 11. Re: List Commands for a nameSpace
                              Bill Robinson

                              if you want to make sure the jobs get removed, when they are created set the AUTO_GENERATED=true property on them, and make sure you have an autogenerated cleanup policy set in blasadmin, and make sure you are running the full set of blcli cleanup commands and the jobs will be deleted after X days.


                              i was thinking if he could derive the parameters from somewhere else he may not need so many jobs to begin with, but he'd still need the cleanup.


                              even if we add nsh parameters to Execution Tasks (which are like a symlink to a job where you can set your own targets and schedule) you would still have a number of objects to content w/ so the on-the-fly plus the AUTO_GENERATED=true is the way to go imo.

                              • 12. List Commands for a nameSpace

                                Thank you for your thoughts. The problem is about concurrent invocation of a job with different parameters because I might have a situation where in I have a window for two or more environments to take a deployment or an install at the same time..hence I don't think creating and deleting jobs wouldn't be an answer to my problem.


                                Bill, yes I recently created a properties file with all different environment information...so I can make BL pick parameters from there but what about invoking that same job for different envs (meaning different parameters)at the same time ?


                                Key is to have an opportunity to allow concurrent invocations of same job with different parameters. If thats not possible, I will have to stick with all the jobs which I maintain currently.



                                • 13. List Commands for a nameSpace

                                  Hi Vivek,

                                  We have the same here with needing two (or more) deployments going out at the same time.


                                  The trick is to create two temporary jobs, one for each environment. You then change the parameters on each job individually.



                                  • 14. List Commands for a nameSpace

                                    Thanks Steve...I will give a try... Anyway BL logs can be saved if I have temporary jobs ?



                                    1 2 Previous Next