10 Replies Latest reply on Feb 1, 2012 12:53 PM by William L. Thomas, Jr.

    script to get job types

      I am trying to write a script that will remove ACL Policies from all types of Job objects. Since the command Job removeAclPolicy requires the DBKey for the job, I need to get the DB Key for each job. However, the "getDBKeyByGroupAndName" command only works for name spaces of the types of jobs (e.g. BatchJob getDBKeyByGroupAndName, DeployJob getDBKeyByGroupAndName, etc.). I am therefore looking for a way to parse through a mixed list of jobs to separate them by job type and then create a subroutine for removing specified ACL Policies for each job type. I think I have the latter part figured out but I cannot find a way to determine the job type for a specific job. At the very least I cannot find any blcli commands that will give me this information.

       

      Any suggestions?

        • 1. script to get job types
          Bill Robinson

          blcli_execute Job findAllHeadersByGroup <groupId>

          blclI_execute SJobHeader getDBKey

          blcli_execute Utility setTargetObject

          blcli_execute Utility listPrint

          blcli_storeenv dbKeys

           

          for dbKey in ${dbKeys}

          do

          Job removeAclPolicy ${dbKey} "<policyName>"

          done

          • 2. script to get job types

            Thanks for the quick reply. I'll give it a try.

             

            A couple of questions. Where do I find information on the commands Job findAllHeadersByGroup and SJobHeader getDBKey?

            • 3. Re: script to get job types
              Bill Robinson

              The unreleased commands doc.  there’s a ‘document’ about them in this community.

              1 of 1 people found this helpful
              • 4. script to get job types

                In order to run the Job findAllHeadersByGroup command, I need to get the Job groupId but in order to get the Job groupId I need to have the JobKey but in order to get the JobKey, I need to have the job type, which is the information that I won't have prior to running the script. Either a catch-22 or I am overlooking something really simple (admittedly, more likely the latter).

                • 5. Re: script to get job types
                  Bill Robinson

                  Well, you could create a smart group that shows all jobs and use that.  there may already be one of those.  otherwise we have to loop through all the job types w/ a different command.

                  1 of 1 people found this helpful
                  • 6. script to get job types

                    Unfortunately, I can't always create Smart Groups of the job types that I will want to remove ACL Policies from. I will need to create a script that recursively goes through all the job types.Worst case, is there any damage that can happen if I run the getDBKeyByGroupAndName command under a name space that does not match the job type?

                     

                    For example, I run DeployJob getDBKeyByGroupAndName against a BatchJob.

                     

                    I assume that I will just get an error message but nothing will break. But I might as well ask if I am here.

                    • 7. Re: script to get job types
                      Bill Robinson

                      So I’m confused – if you can’t create a smart group of the jobs you need to affect, how do you know what jobs you need to remove acl policies from ?  where are you getting the list of jobs to remove the policy from ?

                      • 8. Re: script to get job types

                        The use case is for jobs in particular job groups where ACL Policies need to be removed. These groups normally contain jobs of many different types. With Smart Groups, this is easy: just add a condition that the members of the Smart Group be a particular job type. Worst case, I could just add the condition, run the ACL Policy removal script; replace that condition with another condition and run the ACL Policy script for the new job type against the Smart Group, etc.

                         

                        With static groups, jobs of different types can be members of a particular group for no apparent rhyme or reason. But for whatever reason, they are all there together and there are no filtering conditions I can use to make certain I have all the jobs in the group (or even all the jobs of a particular job type that are members of the group) and only the jobs of a particular group. Thus, I was looking for a way that, when I ran the script against the static group or static list of job objects, would determine the job type and run the appropriate command.

                        • 9. Re: script to get job types
                          Bill Robinson

                          if the jobs are already in a group then my example works - just get the groupId of the group they are in:

                           

                          blcli_execute Job findAllHeadersByGroup <groupId>

                          blclI_execute SJobHeader getDBKey

                          blcli_execute Utility setTargetObject

                          blcli_execute Utility listPrint

                          blcli_storeenv dbKeys

                           

                          for dbKey in ${dbKeys}

                          do

                          Job removeAclPolicy ${dbKey} "<policyName>"

                          done

                          • 10. Re: script to get job types

                            JobGroup groupNameToId

                            D'oh!