5 Replies Latest reply on Apr 1, 2015 1:29 PM by Christopher Blanks

    Server Smart Group - What's using it as a target?

    Christopher Blanks

      I am currently running BSA 8.5 SP1 and undergoing a consolidation from 2 BSA installations into a third.  As we consolidate, we obviously do not want to take a bunch of stuff with us that we don't need.  That said, does anyone have a way to get "What's using this smart group as a target?"

       

      Hopefully one of the resident gurus out here has been there and done that.  :-D

       

      -Chris

        • 1. Re: Server Smart Group - What's using it as a target?
          Bill Robinson

          Best way is a db query.  what db back end are you using ?

          • 3. Re: Server Smart Group - What's using it as a target?
            Christopher Blanks

            I am certain that there is a better way to accomplish this, but here is a rough script that seems to work (though I am not certain how well).

             

            GROUP="${1}"

            JobList=""

             

            blcli_connect

             

            blcli_execute SmartServerGroup groupNameToDBKey "${GROUP}" > /dev/null

            blcli_storeenv GroupDBKey

             

            blcli_execute Job findJobKeysByServerGroupKey ${GroupDBKey} > /dev/null

            blcli_storeenv JobDBKeyList

             

            for JobDBKey in `echo ${JobDBKeyList} | sed -e 's/\[//g' -e 's/,//g' -e 's/\]//g'`

            do

              blcli_execute Job getJobNameByDBKey ${JobDBKey} > /dev/null

              blcli_storeenv JobName

             

              blcli_execute Job getGroupId ${JobDBKey} > /dev/null

              blcli_storeenv GroupId

             

              blcli_execute JobGroup idToGroupName ${GroupId} > /dev/null

              blcli_storeenv GroupName

             

              JobList="$GroupName/$JobName\n$JobList"

             

              GroupName=""

              JobName=""

            done

             

            blcli_disconnect

             

            echo ${JobList} | sort -u

             

            I'm certain that the database query will be a much better solution, but perhaps this will fuel someone's creative spirit.

            -Chris

            • 4. Re: Server Smart Group - What's using it as a target?
              Bill Robinson

              WITH temp1 (group_id, path) AS

              (

                          select group_id, cast(name as varchar(1000))

                             from blgroup bg1

                             where parent_group_id = 0

                             UNION ALL

                        select bg1.group_id,

                                   cast(bg2.path || '/' || cast(bg1.name as varchar(100)) as varchar(1000))

                             from blgroup bg1

                             inner join temp1 bg2 on bg1.parent_group_id = bg2.group_id

              ), temp2 (group_id, path) AS

              (

                          select group_id, cast(name as varchar(1000))

                             from blgroup bg1

                             where parent_group_id = 0

                             UNION ALL

                        select bg1.group_id,

                                   cast(bg2.path || '/' || cast(bg1.name as varchar(100)) as varchar(1000))

                             from blgroup bg1

                             inner join temp2 bg2 on bg1.parent_group_id = bg2.group_id

              )

              select temp2.path,j.name,temp1.path,g.name,o.name from temp1

              join blgroup g on temp1.group_id = g.group_id

              join blgroup_type gt on g.group_type_id = gt.group_type_id

              join object_type o on gt.object_type_id = o.object_type_id

              left join job_device_group jdg on g.group_id = jdg.group_id

              left join job j on jdg.job_id = j.job_id and jdg.job_version_id = j.job_version_id and j.is_latest_version = 1 and j.is_deleted = 0 and j.is_saved_explicitly = 1

              left join temp2 on j.group_id = temp2.group_id

              where g.group_type_id in (1,6)

              ;

              • 5. Re: Server Smart Group - What's using it as a target?
                Christopher Blanks

                Thanks, Bill.  This gives a complete and comprehensive list of everything that I was asking and much more.

                 

                -Chris