3 Replies Latest reply on Oct 9, 2014 7:37 PM by Bill Robinson

    Validation of a smartgroup

      Hi everyone,


      I have a script that use a smartgroup and run a job.

       

      I would like to validate if the smartgroup exist and if the smartgroup is empty.

       

      There's a way to do this?

       

       

      Here's an exemple of the script:

       

       

       

      echo "Clear Targetgroups from the job patch"

      JOB_KEY_PATCH=`blcli_execute PatchingJob getDBKeyByGroupAndName "$JOB_FOLDER_PATCH" "$JOB_NAME_PATCH"`

      CLEAR_GRP_PATCH=`blcli_execute Job clearTargetGroups "$JOB_KEY_PATCH"`

       

      echo "Clear TargetServers from the Job patch"

      JOB_KEY_PATCH=`blcli_execute PatchingJob getDBKeyByGroupAndName "$JOB_FOLDER_PATCH" "$JOB_NAME_PATCH"`

      CLEAR_SRV_PATCH=`blcli_execute Job clearTargetServers "$JOB_KEY_PATCH"`

       

       

      echo "Add required smart group as Target to the Job patch"

      JOB_KEY_PATCH=`blcli_execute PatchingJob getDBKeyByGroupAndName "$JOB_FOLDER_PATCH" "$JOB_NAME_PATCH"`

      ADD_GRP_PATCH=`blcli_execute Job addTargetGroup "$JOB_KEY_PATCH" "$SMARTGRP"`

       

      echo "Run the Patching Job"

      JOB_KEY_PATCH=`blcli_execute PatchingJob getDBKeyByGroupAndName "$JOB_FOLDER_PATCH" "$JOB_NAME_PATCH"`

      JOB_RUN_KEY_PATCH=`blcli_execute PatchingJob executeJobAndWait "$JOB_KEY_PATCH"`

       

      Thank you very much!

        • 1. Re: Validation of a smartgroup
          Bill Robinson

          so first of all you are using the blcli_execute is a sub-optimal way.

          FOO=`blcli_execute xxx`

          is bad

          blcli_execute xxx

          blcli_storeenv FOO

          is right.  otherwise you are negating the purpose of using the 'performance commands'

           

          to see if a smart server group exists you can do like:

          groupName="/Some/Server/Group"

          groupType="SMART_SERVER_GROUP"

          blcli_execute Utility convertModelType "${groupType}"

          blcli_storeenv modelTypeId

          blcli_execute Group groupExistsByTypeAndName ${modelTypeId} "${groupName}"

          blcli_storeenv groupExists

           

          if [[ "${groupExists}" = "true" ]]

          then

          blcli_execute Server listServersInGroup "${groupName}"

          blcli_storeenv groupMembers

          [[ "${#groupMembers}" -gt 0 ]] && "${groupName} has ${#groupMembers}"

          fi

          • 2. Re: Validation of a smartgroup

            Hi Bill!

             

            Thanks for the answer. Now I can validate that the smartgroup exist. But, i'm not able to test if the smartgroup is empty.

            • 3. Re: Validation of a smartgroup
              Bill Robinson

              if [[ "${groupExists}" = "true" ]]

              then

              blcli_execute Server listServersInGroup "${groupName}"

              blcli_storeenv groupMembers

              [[ "${#groupMembers}" -gt 0 ]] && "${groupName} has ${#groupMembers}"

              fi

               

              ?  why won't that work ?